diff -urN mingetty-0.9.4.orig/mingetty.8 mingetty-0.9.4/mingetty.8 --- mingetty-0.9.4.orig/mingetty.8 2004-03-08 00:35:30.000000000 +0100 +++ mingetty-0.9.4/mingetty.8 2004-03-08 02:14:18.000000000 +0100 @@ -3,7 +3,7 @@ mingetty \- minimal getty for consoles .SH SYNOPSIS .B mingetty -[\-\-noclear] [\-\-long\-hostname] [\-\-autologin username] +[\-\-noclear] [\-\-long\-hostname] [\-\-autologin username] [\-\-defaultlogin username] .I tty .PP .SH DESCRIPTION @@ -58,6 +58,9 @@ will revert to performing normal interactive logins for all subsequent login requests. .TP +.B \-\-defaultlogin username +Log the specified user when no username is supplied in the prompt. +.TP .B \-\-mono Set terminal type to "linux-m" instead of default "linux" (for mono consoles) .TP diff -urN mingetty-0.9.4.orig/mingetty.c mingetty-0.9.4/mingetty.c --- mingetty-0.9.4.orig/mingetty.c 2004-03-08 00:35:30.000000000 +0100 +++ mingetty-0.9.4/mingetty.c 2004-03-08 01:51:19.000000000 +0100 @@ -17,7 +17,7 @@ * should be very reliable. For a modem getty, I'd also use nothing else * but mgetty. * - * Usage: mingetty [--noclear] [--autologin username] tty + * Usage: mingetty [--noclear] [--autologin username] [--defaultlogin username] tty * Example entry in /etc/inittab: 1:123:respawn:/sbin/mingetty tty1 * * This program is free software; you can redistribute it and/or @@ -100,6 +100,8 @@ static int longhostname = 0; /* If supplied, attempt an automatic login with this username. */ static char *autologin_name = NULL; +/* If no login supplied, attempt a default login with this username. */ +static char *defaultlogin_name = NULL; /* Set mono terminal type */ static int mono_term = 0; /* Log onto remote host */ @@ -350,6 +352,27 @@ } } +/* + * defaultlogin_ok -- returns 1 if it's okay to do default-login when: + * there was a login name passed with the --defaultlogin option; and + * the defaultlogin_name contains only "nice" characters; + * return 0 otherwise. + */ +static int defaultlogin_ok(void) +{ + char c, *cp; + + /* An all-alphanumeric defaultlogin name must be supplied. */ + if (defaultlogin_name == NULL || defaultlogin_name[0] == '\0') + return 0; + for (cp = defaultlogin_name; (c = *cp); cp++) + if (!isalnum(c) && c != '_') + return 0; + + /* All tests are okay, so grant the defaultlogin request. */ + return 1; +} + /* do_prompt - show login prompt, optionally preceded by /etc/issue contents */ static void do_prompt (void) { @@ -378,7 +401,13 @@ } #endif write (1, hn, strlen (hn)); - write (1, LOGIN, sizeof (LOGIN) - 1); + write (1, LOGIN, sizeof (LOGIN) - 3); + if(defaultlogin_ok()) { + write (1, " (", 2); + write (1, defaultlogin_name, strlen(defaultlogin_name)); + write (1, ")", 1); + }; + write (1, ": ", 2); } /* get_logname - get user name, establish speed, erase, kill, eol */ @@ -410,6 +439,7 @@ else *bp++ = c; } + if(defaultlogin_ok()) break; } return logname; } @@ -484,6 +514,7 @@ { "noclear", no_argument, &noclear, 1}, { "long-hostname", no_argument, &longhostname, 1}, { "autologin", required_argument, NULL, 'a'}, + { "defaultlogin", required_argument, NULL, 'd'}, { "mono", no_argument, &mono_term, 1}, { "remote-host", required_argument, NULL, 2}, { "login-program", required_argument, NULL, 3}, @@ -522,6 +553,9 @@ case 'a': autologin_name = optarg; break; + case 'd': + defaultlogin_name = optarg; + break; default: usage (); } @@ -564,6 +598,12 @@ if (autologin_ok()) { execl (_PATH_LOGIN, _PATH_LOGIN, "-f", autologin_name, NULL); } else { + + if (defaultlogin_ok()) { + logname = get_logname (); + if(*logname == 0) + execl (_PATH_LOGIN, _PATH_LOGIN, "--", defaultlogin_name, NULL); + } else while ((logname = get_logname ()) == 0); if (!remote_login) {