]> andersk Git - openssh.git/blobdiff - uidswap.c
- (tim) [configure.ac] Bug #1149. Changes in QNX section only. Patch by
[openssh.git] / uidswap.c
index e652161af938e2c2a0e22ad73f7646b6cd27a60e..aab7064eb16de2143ab4035b8296ee91001b2830 100644 (file)
--- a/uidswap.c
+++ b/uidswap.c
@@ -56,10 +56,12 @@ temporarily_use_uid(struct passwd *pw)
        debug("temporarily_use_uid: %u/%u (e=%u/%u)",
            (u_int)pw->pw_uid, (u_int)pw->pw_gid,
            (u_int)saved_euid, (u_int)saved_egid);
+#ifndef HAVE_CYGWIN
        if (saved_euid != 0) {
                privileged = 0;
                return;
        }
+#endif
 #else
        if (geteuid() != 0) {
                privileged = 0;
@@ -79,7 +81,7 @@ temporarily_use_uid(struct passwd *pw)
                if (getgroups(saved_egroupslen, saved_egroups) < 0)
                        fatal("getgroups: %.100s", strerror(errno));
        } else { /* saved_egroupslen == 0 */
-               if (saved_egroups)
+               if (saved_egroups != NULL)
                        xfree(saved_egroups);
        }
 
@@ -200,10 +202,12 @@ permanently_set_uid(struct passwd *pw)
                fatal("setuid %u: %.100s", (u_int)pw->pw_uid, strerror(errno));
 #endif
 
+#ifndef HAVE_CYGWIN
        /* Try restoration of GID if changed (test clearing of saved gid) */
-       if (old_gid != pw->pw_gid &&
+       if (old_gid != pw->pw_gid && pw->pw_uid != 0 &&
            (setgid(old_gid) != -1 || setegid(old_gid) != -1))
                fatal("%s: was able to restore old [e]gid", __func__);
+#endif
 
        /* Verify GID drop was successful */
        if (getgid() != pw->pw_gid || getegid() != pw->pw_gid) {
This page took 0.056479 seconds and 4 git commands to generate.