|
Lines 134-140
temporarily_use_uid(struct passwd *pw)
Link Here
|
| 134 |
void |
134 |
void |
| 135 |
permanently_drop_suid(uid_t uid) |
135 |
permanently_drop_suid(uid_t uid) |
| 136 |
{ |
136 |
{ |
| 137 |
#ifndef HAVE_CYGWIN |
137 |
#ifndef NO_UID_RESTORATION_TEST |
| 138 |
uid_t old_uid = getuid(); |
138 |
uid_t old_uid = getuid(); |
| 139 |
#endif |
139 |
#endif |
| 140 |
|
140 |
|
|
Lines 142-148
permanently_drop_suid(uid_t uid)
Link Here
|
| 142 |
if (setresuid(uid, uid, uid) < 0) |
142 |
if (setresuid(uid, uid, uid) < 0) |
| 143 |
fatal("setresuid %u: %.100s", (u_int)uid, strerror(errno)); |
143 |
fatal("setresuid %u: %.100s", (u_int)uid, strerror(errno)); |
| 144 |
|
144 |
|
| 145 |
#ifndef HAVE_CYGWIN |
145 |
#ifndef NO_UID_RESTORATION_TEST |
| 146 |
/* Try restoration of UID if changed (test clearing of saved uid) */ |
146 |
/* Try restoration of UID if changed (test clearing of saved uid) */ |
| 147 |
if (old_uid != uid && |
147 |
if (old_uid != uid && |
| 148 |
(setuid(old_uid) != -1 || seteuid(old_uid) != -1)) |
148 |
(setuid(old_uid) != -1 || seteuid(old_uid) != -1)) |
|
Lines 199-205
restore_uid(void)
Link Here
|
| 199 |
void |
199 |
void |
| 200 |
permanently_set_uid(struct passwd *pw) |
200 |
permanently_set_uid(struct passwd *pw) |
| 201 |
{ |
201 |
{ |
| 202 |
#ifndef HAVE_CYGWIN |
202 |
#ifndef NO_UID_RESTORATION_TEST |
| 203 |
uid_t old_uid = getuid(); |
203 |
uid_t old_uid = getuid(); |
| 204 |
gid_t old_gid = getgid(); |
204 |
gid_t old_gid = getgid(); |
| 205 |
#endif |
205 |
#endif |
|
Lines 227-233
permanently_set_uid(struct passwd *pw)
Link Here
|
| 227 |
if (setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) < 0) |
227 |
if (setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) < 0) |
| 228 |
fatal("setresuid %u: %.100s", (u_int)pw->pw_uid, strerror(errno)); |
228 |
fatal("setresuid %u: %.100s", (u_int)pw->pw_uid, strerror(errno)); |
| 229 |
|
229 |
|
| 230 |
#ifndef HAVE_CYGWIN |
230 |
#ifndef NO_UID_RESTORATION_TEST |
| 231 |
/* Try restoration of GID if changed (test clearing of saved gid) */ |
231 |
/* Try restoration of GID if changed (test clearing of saved gid) */ |
| 232 |
if (old_gid != pw->pw_gid && pw->pw_uid != 0 && |
232 |
if (old_gid != pw->pw_gid && pw->pw_uid != 0 && |
| 233 |
(setgid(old_gid) != -1 || setegid(old_gid) != -1)) |
233 |
(setgid(old_gid) != -1 || setegid(old_gid) != -1)) |
|
Lines 241-247
permanently_set_uid(struct passwd *pw)
Link Here
|
| 241 |
(u_int)pw->pw_gid); |
241 |
(u_int)pw->pw_gid); |
| 242 |
} |
242 |
} |
| 243 |
|
243 |
|
| 244 |
#ifndef HAVE_CYGWIN |
244 |
#ifndef NO_UID_RESTORATION_TEST |
| 245 |
/* Try restoration of UID if changed (test clearing of saved uid) */ |
245 |
/* Try restoration of UID if changed (test clearing of saved uid) */ |
| 246 |
if (old_uid != pw->pw_uid && |
246 |
if (old_uid != pw->pw_uid && |
| 247 |
(setuid(old_uid) != -1 || seteuid(old_uid) != -1)) |
247 |
(setuid(old_uid) != -1 || seteuid(old_uid) != -1)) |
| 248 |
- |
|
|