when you first boot, and you're greeted with the warm glow of a black screen and flashing prompt, what program is that? What program handles evaluation of the credentials? Or rather, what component of the source code is it? I may be confusing myself, but I think the various user shells are loaded after user authentication.
... which might mean that bash is launched in single user mode, then bash checks credentials & launches a user shell? (I think this is how it works)
(Im interested in adding a feature to the credential checking process, but I'm looking at bash source code, and I'm not sure where to begin. )
I have only a rudimentary understanding myself, however I'll post this to get you started:
First, you don't log in to a shell, you log in to a (virtual) terminal.
a
getty
program opens a tty port, prompts for a login name and invokes a login program (/bin/login
by default - although Linux'sagetty
may be configured to use a non-standard login program)the login program performs authentication and session setup, including initializing the environment and invoking the user's login shell.
In current Ubuntu systems,
getty
is managed as a systemd service (ex.[email protected]
for the virtual terminal tty1), andlogin
uses the Pluggable Authentication Modules (PAM) subsystem for authentication - in particular, thepam_unix
module is "for traditional password authentication".For your stated goal ("adding a feature to the credential checking process") you would probably want to look at implementing a custom PAM module, and inserting it into an appropriate place in the PAM stack; a template for that is described here:
See also:
10.1. Logins via terminals from the Linux System Administrators Guide: Chapter 10. Logging In And Out
The archwiki getty page