]>
sourceware.org Git - glibc.git/blob - sysdeps/mach/hurd/setresuid.c
1 /* setresuid -- set effective user ID, real user ID, and saved-set user ID
2 Copyright (C) 2002, 2005 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25 /* Set the effective user ID, real user ID, and saved-set user ID,
26 of the calling process to EUID, RUID, and SUID, respectively. */
28 __setresuid (uid_t euid
, uid_t ruid
, uid_t suid
)
32 uid_t auids
[2] = { ruid
, suid
};
35 __mutex_lock (&_hurd_id
.lock
);
36 err
= _hurd_check_ids ();
40 /* Make a new auth handle which has EUID as the first element in the
41 list of effective uids. */
43 if (_hurd_id
.gen
.nuids
> 0)
45 _hurd_id
.gen
.uids
[0] = euid
;
48 if (_hurd_id
.aux
.nuids
> 1)
50 _hurd_id
.aux
.uids
[0] = ruid
;
51 _hurd_id
.aux
.uids
[1] = suid
;
55 err
= __USEPORT (AUTH
, __auth_makeauth
56 (port
, NULL
, MACH_MSG_TYPE_COPY_SEND
, 0,
57 _hurd_id
.gen
.nuids
? _hurd_id
.gen
.uids
: &euid
,
58 _hurd_id
.gen
.nuids
?: 1,
59 _hurd_id
.aux
.nuids
> 1 ? _hurd_id
.aux
.uids
: auids
,
60 _hurd_id
.aux
.nuids
> 1 ? _hurd_id
.aux
.nuids
: 2,
61 _hurd_id
.gen
.gids
, _hurd_id
.gen
.ngids
,
62 _hurd_id
.aux
.gids
, _hurd_id
.aux
.ngids
,
66 __mutex_unlock (&_hurd_id
.lock
);
70 return __hurd_fail (err
);
72 /* Install the new handle and reauthenticate everything. */
73 err
= __setauth (newauth
);
74 __mach_port_deallocate (__mach_task_self (), newauth
);
77 libc_hidden_def (__setresuid
)
78 weak_alias (__setresuid
, setresuid
)
This page took 0.037761 seconds and 5 git commands to generate.