diff options
author | Miles Bader <miles@gnu.org> | 1997-05-27 01:49:49 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 1997-05-27 01:49:49 +0000 |
commit | 60ce5e1e96837e07170f0ea80393af60f1e7e395 (patch) | |
tree | 5cafdf234dccc5e7457e24fda110c21a9e94a73e /libshouldbeinlibc/ugids-auth.c | |
parent | 2266f58d69f71acd70188db66c26d5d56e39eaf3 (diff) |
Initial checkin
Diffstat (limited to 'libshouldbeinlibc/ugids-auth.c')
-rw-r--r-- | libshouldbeinlibc/ugids-auth.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/libshouldbeinlibc/ugids-auth.c b/libshouldbeinlibc/ugids-auth.c new file mode 100644 index 00000000..89af3848 --- /dev/null +++ b/libshouldbeinlibc/ugids-auth.c @@ -0,0 +1,52 @@ +/* Translate user and group ids to/from auth ports + + Copyright (C) 1997 Free Software Foundation, Inc. + + Written by Miles Bader <miles@gnu.ai.mit.edu> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include <stdlib.h> +#include <hurd.h> + +#include "ugids.h" + +/* Make an auth port from UGIDS and return it in AUTH, using authority in + both the auth port FROM and the current auth port. */ +error_t +ugids_make_auth (const struct ugids *ugids, auth_t from, auth_t *auth) +{ + auth_t cur_auth = getauth (); + error_t err = + auth_makeauth (cur_auth, &from, MACH_MSG_TYPE_COPY_SEND, + (from == MACH_PORT_NULL) ? 0 : 1, + ugids->eff_uids.ids, ugids->eff_uids.num, + ugids->avail_uids.ids, ugids->avail_uids.num, + ugids->eff_gids.ids, ugids->eff_gids.num, + ugids->avail_gids.ids, ugids->avail_gids.num, + auth); + mach_port_deallocate (mach_task_self (), cur_auth); + return err; +} + +/* Merge the ids from the auth port AUTH into UGIDS. */ +error_t +ugids_merge_auth (struct ugids *ugids, auth_t auth) +{ + return + idvec_merge_auth (&ugids->eff_uids, &ugids->avail_uids, + &ugids->eff_gids, &ugids->avail_gids, + auth); +} |