]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
su: add --pty option
authorKarel Zak <kzak@redhat.com>
Thu, 17 Aug 2017 10:07:35 +0000 (12:07 +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
login-utils/su.1

index ff96a18c51a46abe8be8e3c56b30a9a19616f544..265f5fd624d9168fab5e30e05e5e9ca01d641e0d 100644 (file)
@@ -137,6 +137,7 @@ struct su_context {
                     suppress_pam_info:1,       /* don't print PAM info messages (Last login, etc.). */
                     pam_has_session :1,        /* PAM session opened */
                     pam_has_cred :1,           /* PAM cred established */
+                    pty :1,                    /* create pseudo-terminal */
                     restricted :1;             /* false for root user */
 };
 
@@ -704,6 +705,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(USAGE_SEPARATOR, stdout);
        printf(USAGE_HELP_OPTIONS(33));
@@ -827,6 +829,7 @@ int su_main(int argc, char **argv, int mode)
                {"fast", no_argument, NULL, 'f'},
                {"login", no_argument, NULL, 'l'},
                {"preserve-environment", no_argument, NULL, 'p'},
+               {"pty", no_argument, NULL, 'P'},
                {"shell", required_argument, NULL, 's'},
                {"group", required_argument, NULL, 'g'},
                {"supp-group", required_argument, NULL, 'G'},
@@ -845,7 +848,7 @@ int su_main(int argc, char **argv, int mode)
        su->conv.appdata_ptr = (void *) su;
 
        while ((optc =
-               getopt_long(argc, argv, "c:fg:G:lmps:u:hV", longopts,
+               getopt_long(argc, argv, "c:fg:G:lmpPs:u:hV", longopts,
                            NULL)) != -1) {
                switch (optc) {
                case 'c':
@@ -880,6 +883,10 @@ int su_main(int argc, char **argv, int mode)
                        su->change_environment = false;
                        break;
 
+               case 'P':
+                       su->pty = 1;
+                       break;
+
                case 's':
                        shell = optarg;
                        break;
index 26fbfe3db204ef67a10163ae40651f89f90c5c8a..4939be86bbdf0e76a3918b0d8c05a7743f3a3b6f 100644 (file)
@@ -106,6 +106,9 @@ nor
 .BR LOGNAME .
 This option is ignored if the option \fB\-\-login\fR is specified.
 .TP
+.BR \-P , " \-\-pty"
+Create pseudo-terminal for the session.
+.TP
 .BR \-s , " \-\-shell" = \fIshell
 Run the specified \fIshell\fR instead of the default.  The shell to run is
 selected according to the following rules, in order: