summaryrefslogtreecommitdiff
path: root/uidswap.c
diff options
context:
space:
mode:
Diffstat (limited to 'uidswap.c')
-rw-r--r--uidswap.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/uidswap.c b/uidswap.c
index 44c4cb626..aab7064eb 100644
--- a/uidswap.c
+++ b/uidswap.c
@@ -56,10 +56,12 @@ temporarily_use_uid(struct passwd *pw)
56 debug("temporarily_use_uid: %u/%u (e=%u/%u)", 56 debug("temporarily_use_uid: %u/%u (e=%u/%u)",
57 (u_int)pw->pw_uid, (u_int)pw->pw_gid, 57 (u_int)pw->pw_uid, (u_int)pw->pw_gid,
58 (u_int)saved_euid, (u_int)saved_egid); 58 (u_int)saved_euid, (u_int)saved_egid);
59#ifndef HAVE_CYGWIN
59 if (saved_euid != 0) { 60 if (saved_euid != 0) {
60 privileged = 0; 61 privileged = 0;
61 return; 62 return;
62 } 63 }
64#endif
63#else 65#else
64 if (geteuid() != 0) { 66 if (geteuid() != 0) {
65 privileged = 0; 67 privileged = 0;
@@ -200,10 +202,12 @@ permanently_set_uid(struct passwd *pw)
200 fatal("setuid %u: %.100s", (u_int)pw->pw_uid, strerror(errno)); 202 fatal("setuid %u: %.100s", (u_int)pw->pw_uid, strerror(errno));
201#endif 203#endif
202 204
205#ifndef HAVE_CYGWIN
203 /* Try restoration of GID if changed (test clearing of saved gid) */ 206 /* Try restoration of GID if changed (test clearing of saved gid) */
204 if (old_gid != pw->pw_gid && 207 if (old_gid != pw->pw_gid && pw->pw_uid != 0 &&
205 (setgid(old_gid) != -1 || setegid(old_gid) != -1)) 208 (setgid(old_gid) != -1 || setegid(old_gid) != -1))
206 fatal("%s: was able to restore old [e]gid", __func__); 209 fatal("%s: was able to restore old [e]gid", __func__);
210#endif
207 211
208 /* Verify GID drop was successful */ 212 /* Verify GID drop was successful */
209 if (getgid() != pw->pw_gid || getegid() != pw->pw_gid) { 213 if (getgid() != pw->pw_gid || getegid() != pw->pw_gid) {