From 927ded6be6bddefb57909a1c24255ac23643b6dc Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 23 Aug 2017 13:50:04 +0200 Subject: [PATCH] su: enable TIOCSCTTY and minor changes Signed-off-by: Karel Zak --- login-utils/su-common.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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); -- 2.47.3