]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
su: enable TIOCSCTTY and minor changes
authorKarel Zak <kzak@redhat.com>
Wed, 23 Aug 2017 11:50:04 +0000 (13:50 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 18 Sep 2017 09:49:11 +0000 (11:49 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/su-common.c

index 7725d1558d92cc90aa6d9a7d7f77e71eccd8d882..6c5c6eb772f9d3bbf7619d582d091397e5ceaed4 100644 (file)
@@ -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 <shell>             run <shell> 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);