diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2006-06-08 14:45:50 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2006-06-08 14:45:50 +0000 |
commit | 0bb6ec3a5fabaf3fde15d9bcdbf8a5897c191708 (patch) | |
tree | 718cf2bfb57c4c1914bb05f40ff0e4fbcbb18757 | |
parent | 5f25d4ea2a5fdcdfa098574a83cc1a62672e7436 (diff) |
do not set the gid, noted by solar; ok djm
-rw-r--r-- | usr.bin/ssh/readpass.c | 4 | ||||
-rw-r--r-- | usr.bin/ssh/sshconnect.c | 4 | ||||
-rw-r--r-- | usr.bin/ssh/sshconnect2.c | 4 | ||||
-rw-r--r-- | usr.bin/ssh/uidswap.c | 12 | ||||
-rw-r--r-- | usr.bin/ssh/uidswap.h | 3 |
5 files changed, 17 insertions, 10 deletions
diff --git a/usr.bin/ssh/readpass.c b/usr.bin/ssh/readpass.c index 02cf8a94688..da020065ad2 100644 --- a/usr.bin/ssh/readpass.c +++ b/usr.bin/ssh/readpass.c @@ -1,4 +1,4 @@ -/* $OpenBSD: readpass.c,v 1.38 2006/06/06 10:20:20 markus Exp $ */ +/* $OpenBSD: readpass.c,v 1.39 2006/06/08 14:45:49 markus Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * @@ -60,7 +60,7 @@ ssh_askpass(char *askpass, const char *msg) return NULL; } if (pid == 0) { - permanently_set_uid(getpwuid(getuid())); + permanently_drop_suid(getuid()); close(p[0]); if (dup2(p[1], STDOUT_FILENO) < 0) fatal("ssh_askpass: dup2: %s", strerror(errno)); diff --git a/usr.bin/ssh/sshconnect.c b/usr.bin/ssh/sshconnect.c index bcb5e94457d..30d88853c0a 100644 --- a/usr.bin/ssh/sshconnect.c +++ b/usr.bin/ssh/sshconnect.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshconnect.c,v 1.183 2006/06/06 10:20:20 markus Exp $ */ +/* $OpenBSD: sshconnect.c,v 1.184 2006/06/08 14:45:49 markus Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -91,7 +91,7 @@ ssh_proxy_connect(const char *host, u_short port, const char *proxy_command) char *argv[10]; /* Child. Permanently give up superuser privileges. */ - permanently_set_uid(getpwuid(original_real_uid)); + permanently_drop_suid(original_real_uid); /* Redirect stdin and stdout. */ close(pin[1]); diff --git a/usr.bin/ssh/sshconnect2.c b/usr.bin/ssh/sshconnect2.c index 16ab3d0f052..c0fd928609c 100644 --- a/usr.bin/ssh/sshconnect2.c +++ b/usr.bin/ssh/sshconnect2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshconnect2.c,v 1.154 2006/06/06 10:20:20 markus Exp $ */ +/* $OpenBSD: sshconnect2.c,v 1.155 2006/06/08 14:45:49 markus Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * @@ -1252,7 +1252,7 @@ ssh_keysign(Key *key, u_char **sigp, u_int *lenp, return -1; } if (pid == 0) { - permanently_set_uid(getpwuid(getuid())); + permanently_drop_suid(getuid()); close(from[0]); if (dup2(from[1], STDOUT_FILENO) < 0) fatal("ssh_keysign: dup2: %s", strerror(errno)); diff --git a/usr.bin/ssh/uidswap.c b/usr.bin/ssh/uidswap.c index 75a1d7cb467..60b378b2c40 100644 --- a/usr.bin/ssh/uidswap.c +++ b/usr.bin/ssh/uidswap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uidswap.c,v 1.28 2006/06/06 10:20:20 markus Exp $ */ +/* $OpenBSD: uidswap.c,v 1.29 2006/06/08 14:45:49 markus Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -111,8 +111,6 @@ restore_uid(void) void permanently_set_uid(struct passwd *pw) { - if (pw == NULL) - fatal("permanently_set_uid: no user given"); if (temporarily_use_uid_effective) fatal("permanently_set_uid: temporarily_use_uid effective"); debug("permanently_set_uid: %u/%u", (u_int)pw->pw_uid, @@ -122,3 +120,11 @@ permanently_set_uid(struct passwd *pw) if (setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) != 0) fatal("setresuid %u: %s", (u_int)pw->pw_uid, strerror(errno)); } + +void +permanently_drop_suid(uid_t uid) +{ + debug("permanently_drop_suid: %u", (u_int)uid); + if (setresuid(uid, uid, uid) != 0) + fatal("setresuid %u: %s", (u_int)uid, strerror(errno)); +} diff --git a/usr.bin/ssh/uidswap.h b/usr.bin/ssh/uidswap.h index 967ea9c4d32..f827782d5b2 100644 --- a/usr.bin/ssh/uidswap.h +++ b/usr.bin/ssh/uidswap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uidswap.h,v 1.10 2006/03/25 22:22:43 djm Exp $ */ +/* $OpenBSD: uidswap.h,v 1.11 2006/06/08 14:45:49 markus Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> @@ -18,5 +18,6 @@ void temporarily_use_uid(struct passwd *); void restore_uid(void); void permanently_set_uid(struct passwd *); +void permanently_drop_suid(uid_t); #endif /* UIDSWAP_H */ |