2 Unix SMB/CIFS implementation.
3 setXXid() functions for Samba.
4 Copyright (C) Jeremy Allison 2012
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "system/passwd.h"
23 #include "include/includes.h"
25 #ifdef UID_WRAPPER_REPLACE
35 #ifdef samba_setresuid
36 #undef samba_setresuid
47 #ifdef samba_setresgid
48 #undef samba_setresgid
51 #ifdef samba_setgroups
52 #undef samba_setgroups
55 /* uid_wrapper will have redefined these. */
56 int samba_setresuid(uid_t ruid, uid_t euid, uid_t suid);
57 int samba_setresgid(gid_t rgid, gid_t egid, gid_t sgid);
58 int samba_setreuid(uid_t ruid, uid_t euid);
59 int samba_setregid(gid_t rgid, gid_t egid);
60 int samba_seteuid(uid_t euid);
61 int samba_setegid(gid_t egid);
62 int samba_setuid(uid_t uid);
63 int samba_setgid(gid_t gid);
64 int samba_setuidx(int flags, uid_t uid);
65 int samba_setgidx(int flags, gid_t gid);
66 int samba_setgroups(size_t setlen, const gid_t *gidset);
71 #include "../lib/util/setid.h"
73 /* All the setXX[ug]id functions and setgroups Samba uses. */
74 int samba_setresuid(uid_t ruid, uid_t euid, uid_t suid)
76 #if defined(HAVE_SETRESUID)
77 return setresuid(ruid, euid, suid);
84 int samba_setresgid(gid_t rgid, gid_t egid, gid_t sgid)
86 #if defined(HAVE_SETRESGID)
87 return setresgid(rgid, egid, sgid);
94 int samba_setreuid(uid_t ruid, uid_t euid)
96 #if defined(HAVE_SETREUID)
97 return setreuid(ruid, euid);
104 int samba_setregid(gid_t rgid, gid_t egid)
106 #if defined(HAVE_SETREGID)
107 return setregid(rgid, egid);
114 int samba_seteuid(uid_t euid)
116 #if defined(HAVE_SETEUID)
117 return seteuid(euid);
124 int samba_setegid(gid_t egid)
126 #if defined(HAVE_SETEGID)
127 return setegid(egid);
134 int samba_setuid(uid_t uid)
136 #if defined(HAVE_SETUID)
144 int samba_setgid(gid_t gid)
146 #if defined(HAVE_SETGID)
154 int samba_setuidx(int flags, uid_t uid)
156 #if defined(HAVE_SETUIDX)
157 return setuidx(flags, uid);
164 int samba_setgidx(int flags, gid_t gid)
166 #if defined(HAVE_SETGIDX)
167 return setgidx(flags, gid);
174 int samba_setgroups(size_t setlen, const gid_t *gidset)
176 #if defined(HAVE_SETGROUPS)
177 return setgroups(setlen, gidset);