]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
agetty: make --autologin useful with --skip-login (prompt)
authorKarel Zak <kzak@redhat.com>
Mon, 19 Nov 2012 09:54:58 +0000 (10:54 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 19 Nov 2012 09:54:58 +0000 (10:54 +0100)
The --autologin prints

hostname login: username (automatic login)

message. This commit allows to suppress the message at all if
--skip-login (aka skip prompt) is specified.

It means that

agetty --skip-login --noissue --autologin foouser

does completely silent autologin.

Addresses: https://github.com/karelzak/util-linux/issues/21
Signed-off-by: Karel Zak <kzak@redhat.com>
term-utils/agetty.c

index 2480f7ddeb78cd233570f25aee432b760bb1bd85..152fc9106c4905319753bcb9f275f5844cf857b8 100644 (file)
@@ -375,13 +375,17 @@ int main(int argc, char **argv)
        }
 
        chardata = init_chardata;
+
+       if (options.autolog) {
+               debug("doing auto login\n");
+               username = options.autolog;
+       }
+
        if ((options.flags & F_NOPROMPT) == 0) {
                if (options.autolog) {
-                       /* Do the auto login. */
-                       debug("doing auto login\n");
+                       /* Autologin prompt */
                        do_prompt(&options, &termios);
                        printf("%s%s (automatic login)\n", LOGIN, options.autolog);
-                       username = options.autolog;
                } else {
                        /* Read the login name. */
                        debug("reading login name\n");
@@ -1357,7 +1361,7 @@ static void do_prompt(struct options *op, struct termios *tp)
                        free(hn);
                }
        }
-       if (op->autolog == (char*)0) {
+       if (!op->autolog) {
                /* Always show login prompt. */
                write_all(STDOUT_FILENO, LOGIN, sizeof(LOGIN) - 1);
        }