Skip to content

agetty: handle systems without a shell or /bin/login#4437

Open
mvanhorn wants to merge 2 commits into
util-linux:masterfrom
mvanhorn:feat/4117-agetty-no-login-message
Open

agetty: handle systems without a shell or /bin/login#4437
mvanhorn wants to merge 2 commits into
util-linux:masterfrom
mvanhorn:feat/4117-agetty-no-login-message

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

Summary

Make agetty handle systems that have no shell and therefore no /bin/login. Before showing the issue file and prompting for a username, agetty now checks whether the login program is executable. If it is not, agetty prints a short banner instead of prompting, and waits for the user to press Enter to re-check.

A new --nologin-message option lets the banner text be customized. The default message is "This system does not permit logins."

Why this matters

This implements the request in #4117. Today agetty displays the issue file and prompts for a username even when login is impossible, producing a confusing dead end for the user. The behavior:

  • When the login program (default /bin/login, or the program set with --login-program) is missing or not executable, agetty prints the banner and does not prompt for a username or attempt to spawn login.
  • On Enter, agetty re-evaluates the access(X_OK) check, so an administrator who installs the login program at runtime can proceed without rebooting. If it is still missing, the banner is shown again.
  • When the login program exists and is executable, the normal issue and prompt flow is unchanged.

The check uses the resolved login path (op->login, defaulting to _PATH_LOGIN), so pointing -l/--login-program at a non-existent path triggers the same behavior.

Testing

util-linux builds on Linux only, so the change was validated by code review and a standalone syntax check of the new function (gcc -Wall -Wextra -fsyntax-only, clean). The CI build will exercise the full compile.

Manual scenarios to verify:

  • Login program present and executable: normal issue + username prompt, unchanged.
  • Login program missing or non-executable: banner shown, no username prompt, no spawn attempt.
  • Start with login missing, press Enter after it becomes available: agetty proceeds to the prompt; if still missing, banner re-shown.
  • -l pointing at a non-existent path: same banner behavior.

Closes #4117

When the login program (default /bin/login, or the one set with
--login-program) is missing or not executable, logging in is impossible.
Previously agetty still displayed the issue file and prompted for a
username, producing a confusing dead end.

Before prompting, check whether the login program is executable with
access(X_OK). If it is not, print a short banner ("This system does not
permit logins." by default, configurable with --nologin-message) and
wait for the user to press Enter, then re-check so an administrator who
installs the login program at runtime can proceed without a reboot. The
normal prompt flow is unaffected when the login program exists.

Add --nologin-message to override the banner text and document the new
behavior in agetty.8.adoc.

Closes util-linux#4117
@poettering

Copy link
Copy Markdown
Contributor

Lovely! thank you!

Comment thread agetty-cmd/agetty.c Outdated
Comment on lines +660 to +663
/* Wait for Enter, then re-check the login program. */
if (getc(stdin) == EOF)
return;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this actually wait for Enter? It seems any key would work, if the input is not buffered. If it is buffered, it'd wait until Enter, and then do a tight loop. I think the EOF condition shouldn't fire, if this is connected to a console. I don't understand this loop.

@karelzak

Copy link
Copy Markdown
Collaborator

Thanks! Notes:

  • DEFAULT_NOLOGIN_MESSAGE can be confusing for users, as it does not suggest a recheck by pressing any key
  • aggety supports --chroot command line option, I think wait_for_login_program() should not be called in this case

Address review notes from Karel: reword DEFAULT_NOLOGIN_MESSAGE so it
tells the user a keypress re-checks for the login program, and skip
wait_for_login_program() when --chroot is used since the path check
would test the wrong root. Update the man page accordingly.

Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
@mvanhorn

mvanhorn commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

Both notes addressed in 6a187af: the default message now reads 'Login is currently unavailable. Press any key to check again.' (which matches the actual behavior - the wait is a getc, so any key triggers the re-check), and wait_for_login_program() is skipped when --chroot is set, since the pre-chroot path check would test the wrong root. Man page updated to match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFE: agetty: add supports for systems that do not have a shell or /bin/login installed

4 participants