2 * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de. All rights reserved.
3 * Copyright 2002-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
4 * Distributed under the terms of the MIT License.
20 #include <errno_private.h>
25 set_errno_if_necessary(const T
& result
)
42 return _kern_getgid(true);
49 return _kern_getuid(true);
56 return _kern_getgid(false);
63 return _kern_getuid(false);
70 return set_errno_if_necessary(_kern_setregid(gid
, (gid_t
)-1, true));
77 return set_errno_if_necessary(_kern_setreuid(uid
, (uid_t
)-1, true));
84 return set_errno_if_necessary(_kern_setregid((gid_t
)-1, gid
, false));
91 return set_errno_if_necessary(_kern_setreuid((uid_t
)-1, uid
, false));
96 setregid(gid_t rgid
, gid_t egid
)
98 return set_errno_if_necessary(_kern_setregid(rgid
, egid
, false));
103 setreuid(uid_t ruid
, uid_t euid
)
105 return set_errno_if_necessary(_kern_setreuid(ruid
, euid
, false));
110 getgroups(int groupCount
, gid_t groupList
[])
112 return set_errno_if_necessary(_kern_getgroups(groupCount
, groupList
));
117 setgroups(int groupCount
, const gid_t
* groupList
)
119 return set_errno_if_necessary(_kern_setgroups(groupCount
, groupList
));
122 // NOTE: getgrouplist() and initgroups() are implemented in grp.cpp.