summaryrefslogtreecommitdiffstats
path: root/crypto/openssh/uidswap.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2005-06-05 15:40:50 +0000
committerdes <des@FreeBSD.org>2005-06-05 15:40:50 +0000
commit11a09ab416e21c995885dc0e5847151627094217 (patch)
tree7767975616a98948a7ef791c43b28a21711a22c7 /crypto/openssh/uidswap.c
parentd5d493f03ae792146848e3cba16bb9e667c73125 (diff)
downloadFreeBSD-src-11a09ab416e21c995885dc0e5847151627094217.zip
FreeBSD-src-11a09ab416e21c995885dc0e5847151627094217.tar.gz
Vendor import of OpenSSH 4.0p1.
Diffstat (limited to 'crypto/openssh/uidswap.c')
-rw-r--r--crypto/openssh/uidswap.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/crypto/openssh/uidswap.c b/crypto/openssh/uidswap.c
index 44c4cb6..aab7064eb 100644
--- a/crypto/openssh/uidswap.c
+++ b/crypto/openssh/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;
@@ -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) {
OpenPOWER on IntegriCloud