From: Karel Zak Date: Wed, 23 Aug 2017 11:50:04 +0000 (+0200) Subject: su: enable TIOCSCTTY and minor changes X-Git-Tag: v2.31-rc1~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=927ded6be6bddefb57909a1c24255ac23643b6dc;p=thirdparty%2Futil-linux.git su: enable TIOCSCTTY and minor changes Signed-off-by: Karel Zak --- diff --git a/login-utils/su-common.c b/login-utils/su-common.c index 7725d1558d..6c5c6eb772 100644 --- a/login-utils/su-common.c +++ b/login-utils/su-common.c @@ -227,7 +227,7 @@ static void pty_init_slave(struct su_context *su) { DBG(PTY, ul_debug("initialize slave")); - ioctl(su->pty_slave, TIOCSCTTY, 0); + ioctl(su->pty_slave, TIOCSCTTY, 1); close(su->pty_master); dup2(su->pty_slave, STDIN_FILENO); @@ -1074,7 +1074,7 @@ static void usage_common(void) " and do not create a new session\n"), stdout); fputs(_(" -f, --fast pass -f to the shell (for csh or tcsh)\n"), stdout); fputs(_(" -s, --shell run if /etc/shells allows it\n"), stdout); - fputs(_(" -P, --pty create pseudo-terminal session\n"), stdout); + fputs(_(" -P, --pty create a new pseudo-terminal\n"), stdout); fputs(USAGE_SEPARATOR, stdout); printf(USAGE_HELP_OPTIONS(33)); @@ -1386,8 +1386,10 @@ int su_main(int argc, char **argv, int mode) /* Now we're in the child. */ change_identity(su->pwd); - if (!su->same_session || su->pty) + if (!su->same_session || su->pty) { + DBG(MISC, ul_debug("call setsid()")); setsid(); + } if (su->pty) pty_init_slave(su);