#define serial_tty_option(opt, flag) \
(((opt)->flags & (F_VCONSOLE|(flag))) == (flag))
+/* Default banner printed when the login program is not available. */
+#define DEFAULT_NOLOGIN_MESSAGE N_("This system does not permit logins.")
+
static int wait_for_term_input(struct agetty_issue *ie, int fd);
+static void wait_for_login_program(struct agetty_options *op);
static void do_prompt(struct agetty_issue *ie, struct agetty_options *op, struct termios *tp);
static char *get_logname(struct agetty_issue *ie, struct agetty_options *op,
struct termios *tp, struct chardata *cp);
fputs(_(" --long-hostname show full qualified hostname\n"), out);
fputs(_(" --erase-chars <string> additional backspace chars\n"), out);
fputs(_(" --kill-chars <string> additional kill chars\n"), out);
+ fputs(_(" --nologin-message <msg> message shown when login program is missing\n"), out);
fputs(_(" --chdir <directory> chdir before the login\n"), out);
fputs(_(" --delay <number> sleep seconds before prompt\n"), out);
fputs(_(" --nice <number> run login with this priority\n"), out);
RELOAD_OPTION,
LIST_SPEEDS_OPTION,
ISSUE_SHOW_OPTION,
+ NOLOGIN_MESSAGE_OPTION,
};
static const struct option longopts[] = {
{ "8bits", no_argument, NULL, '8' },
{ "help", no_argument, NULL, HELP_OPTION },
{ "erase-chars", required_argument, NULL, ERASE_CHARS_OPTION },
{ "kill-chars", required_argument, NULL, KILL_CHARS_OPTION },
+ { "nologin-message", required_argument, NULL, NOLOGIN_MESSAGE_OPTION },
{ NULL, 0, NULL, 0 }
};
case KILL_CHARS_OPTION:
op->killchars = optarg;
break;
+ case NOLOGIN_MESSAGE_OPTION:
+ op->nologin_message = optarg;
+ break;
case RELOAD_OPTION:
agetty_reload();
exit(EXIT_SUCCESS);
INIT_CHARDATA(&chardata);
+ /*
+ * If the login program is missing or not executable there is no way to
+ * log in. Show a banner and wait until it becomes available instead of
+ * prompting for a username that can never be used.
+ */
+ wait_for_login_program(&options);
+
if (options.autolog) {
debug("doing auto login\n");
options.username = options.autolog;
}
+/*
+ * Block until the login program is executable.
+ *
+ * On systems without a shell or /bin/login there is no point in showing the
+ * issue file and prompting for a username, because the login program can never
+ * be executed. Instead of running into a confusing dead end, print a short
+ * banner and wait for the user to press Enter, then re-check whether the login
+ * program has become available (for example because an administrator installed
+ * it at runtime). As soon as the login program is executable we return and the
+ * normal prompt flow continues.
+ */
+static void wait_for_login_program(struct agetty_options *op)
+{
+ const char *message = op->nologin_message ?
+ op->nologin_message : _(DEFAULT_NOLOGIN_MESSAGE);
+
+ while (access(op->login, X_OK) != 0) {
+ printf("%s\n", message);
+ fflush(stdout);
+
+ /* Wait for Enter, then re-check the login program. */
+ if (getc(stdin) == EOF)
+ return;
+ }
+}
+
static void do_prompt(struct agetty_issue *ie, struct agetty_options *op, struct termios *tp)
{
#ifdef AGETTY_RELOAD
This program does not use the _/etc/gettydefs_ (System V) or _/etc/gettytab_ (SunOS 4) files.
+If the login program (by default _/bin/login_, or the program given with *--login-program*) is missing or not executable, then logging in is impossible. In that case *agetty* does not display the issue file or prompt for a login name. Instead it prints a short message ("This system does not permit logins." by default, configurable with *--nologin-message*) and waits for the user to press Enter. On Enter it re-checks whether the login program has become available, for example because an administrator installed it at runtime, and either continues with the normal prompt or shows the message again.
+
== ARGUMENTS
_port_::
*--kill-chars* _string_::
This option specifies additional characters that should be interpreted as a kill ("ignore all previous characters") when the user types the login name. The default additional 'kill' has been '@', but since util-linux 2.23 no additional kill characters are enabled by default.
+*--nologin-message* _string_::
+Use _string_ as the message that is shown when the login program is missing or not executable, instead of the default "This system does not permit logins." See the *DESCRIPTION* above for details about this behavior.
+
*--chdir* _directory_::
Change directory before the login.