5

I am wondering how the login actually works. It certainly is not part of the kernel, because I can set the login to use ldap for example, or keep using /etc/passwd; but the kernel certainly is able to use information from it to perform authentication and authorization activities.

There is also a systemd daemon, called logind which seems to start up the whole login mechanism.

Is there any design document I can look at, or can someone describe it here?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Sambatyon
  • 153
  • 1
  • 6

2 Answers2

8

The login binary is pretty straightforward (in principle). It's just a program that runs as root user (started, indirectly through getty or an X display manager, from init, the first user-space process). It performs authentication of the logging-in user, and if that is successful, changes user (using one of the setuid() family of system calls), sets appropriate environment variables, umask, etc, and exec()s a login shell.

It may be instructive to read the source code, but if you do so, you'll find it easiest (assuming the standard shadow-utils login that Debian installs) to read it assuming USE_PAM is not set, at least until you are comfortable with its operation, or you'll find too much distraction.

Toby Speight
  • 8,460
  • 3
  • 26
  • 50
4

This site seems like a really good place to start. It has a discussion of /etc/passwd as well as PAM. I think you are really looking for a description of PAM. If you are looking to implement something for a specific use, you can edit your question to give us an idea of what you are trying to accomplish.

user1794469
  • 3,909
  • 1
  • 23
  • 42
  • 1
    Whilst this may theoretically answer the question, [it would be preferable](//meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – slm Jul 17 '15 at 01:49