summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2004-07-28 08:56:23 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2004-07-28 08:56:23 +0000
commit675615bf2e9a8f1c5af4be98ef468b02f9256355 (patch)
tree2362eacde3db1c3c3efd269598ea7a6dfc406f5f
parent2e103e4475f18e18b0face557d708dfe1f8a96e8 (diff)
call setsid() _before_ re-exec
-rw-r--r--usr.bin/ssh/sshd.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/usr.bin/ssh/sshd.c b/usr.bin/ssh/sshd.c
index 64ffd771942..0ed454b320e 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.299 2004/07/17 05:31:41 dtucker Exp $");
+RCSID("$OpenBSD: sshd.c,v 1.300 2004/07/28 08:56:22 markus Exp $");
#include <openssl/dh.h>
#include <openssl/bn.h>
@@ -1486,6 +1486,14 @@ main(int ac, char **av)
/* This is the child processing a new connection. */
setproctitle("%s", "[accepted]");
+ /*
+ * 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 (!debug_flag && !inetd_flag && setsid() < 0)
+ error("setsid: %.100s", strerror(errno));
+
if (rexec_flag) {
int fd;
@@ -1526,14 +1534,6 @@ main(int ac, char **av)
}
/*
- * 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 (!debug_flag && !inetd_flag && 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.