summaryrefslogtreecommitdiffstats
path: root/term-utils/agetty.c
diff options
context:
space:
mode:
authorKarel Zak2012-11-19 10:54:58 +0100
committerKarel Zak2012-11-19 10:54:58 +0100
commit933956cb499e12d0d0e5228b6de34ffa5c9a9e08 (patch)
tree4cb2b681197990deb5d118598680aaf19e07585f /term-utils/agetty.c
parentuuidgen: fix --random (diff)
downloadkernel-qcow2-util-linux-933956cb499e12d0d0e5228b6de34ffa5c9a9e08.tar.gz
kernel-qcow2-util-linux-933956cb499e12d0d0e5228b6de34ffa5c9a9e08.tar.xz
kernel-qcow2-util-linux-933956cb499e12d0d0e5228b6de34ffa5c9a9e08.zip
agetty: make --autologin useful with --skip-login (prompt)
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>
Diffstat (limited to 'term-utils/agetty.c')
-rw-r--r--term-utils/agetty.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index 2480f7dde..152fc9106 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -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);
}