summaryrefslogtreecommitdiff
path: root/usr.bin/ssh
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2002-05-13 15:53:20 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2002-05-13 15:53:20 +0000
commit04b0e06af0a03c19824f92a0548e0729bb9a444a (patch)
tree481811a683cc3b9e6ced1813dbb63fb0956af06f /usr.bin/ssh
parentd9ba81d009ea7f002ad4ea20a2b0da22663b49b9 (diff)
Call setsid() in the child after sshd accepts the connection and forks.
This is needed for privsep which calls setlogin() when it changes uids. Without this, there is a race where the login name of an existing connection, as returned by getlogin(), may be changed to the privsep user (sshd). markus@ OK
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r--usr.bin/ssh/sshd.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/usr.bin/ssh/sshd.c b/usr.bin/ssh/sshd.c
index ec01386a148..7e92e0ab744 100644
--- a/usr.bin/ssh/sshd.c
+++ b/usr.bin/ssh/sshd.c
@@ -42,7 +42,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshd.c,v 1.240 2002/04/23 22:16:29 djm Exp $");
+RCSID("$OpenBSD: sshd.c,v 1.241 2002/05/13 15:53:19 millert Exp $");
#include <openssl/dh.h>
#include <openssl/bn.h>
@@ -1292,6 +1292,14 @@ main(int ac, char **av)
/* This is the child processing a new connection. */
/*
+ * Create a new session and process group since the 4.4BSD
+ * setlogin() affects the entire process group. We don't
+ * want the child to be able to affect the parent.
+ */
+ if (setsid() < 0)
+ error("setsid: %.100s", strerror(errno));
+
+ /*
* Disable the key regeneration alarm. We will not regenerate the
* key since we are no longer in a position to give it to anyone. We
* will not restart on SIGHUP since it no longer makes sense.