summaryrefslogtreecommitdiff
path: root/uidswap.c
diff options
context:
space:
mode:
Diffstat (limited to 'uidswap.c')
-rw-r--r--uidswap.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/uidswap.c b/uidswap.c
index 44c4cb626..fa3d7a3b1 100644
--- a/uidswap.c
+++ b/uidswap.c
@@ -200,10 +200,12 @@ permanently_set_uid(struct passwd *pw)
200 fatal("setuid %u: %.100s", (u_int)pw->pw_uid, strerror(errno)); 200 fatal("setuid %u: %.100s", (u_int)pw->pw_uid, strerror(errno));
201#endif 201#endif
202 202
203#ifndef HAVE_CYGWIN
203 /* Try restoration of GID if changed (test clearing of saved gid) */ 204 /* Try restoration of GID if changed (test clearing of saved gid) */
204 if (old_gid != pw->pw_gid && 205 if (old_gid != pw->pw_gid && pw->pw_uid != 0 &&
205 (setgid(old_gid) != -1 || setegid(old_gid) != -1)) 206 (setgid(old_gid) != -1 || setegid(old_gid) != -1))
206 fatal("%s: was able to restore old [e]gid", __func__); 207 fatal("%s: was able to restore old [e]gid", __func__);
208#endif
207 209
208 /* Verify GID drop was successful */ 210 /* Verify GID drop was successful */
209 if (getgid() != pw->pw_gid || getegid() != pw->pw_gid) { 211 if (getgid() != pw->pw_gid || getegid() != pw->pw_gid) {