From 675615bf2e9a8f1c5af4be98ef468b02f9256355 Mon Sep 17 00:00:00 2001 From: Markus Friedl Date: Wed, 28 Jul 2004 08:56:23 +0000 Subject: call setsid() _before_ re-exec --- usr.bin/ssh/sshd.c | 18 +++++++++--------- 1 file 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 #include @@ -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; @@ -1525,14 +1533,6 @@ main(int ac, char **av) sock_in, sock_out, newsock, startup_pipe, config_s[0]); } - /* - * 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 -- cgit v1.2.3