Bug in login with utmprecord?
Stef Bon <[email protected]> Mon, 17 Oct 2005 00:05:46 +0200
| Newsgroups | gmane.linux.pld.shadow.general |
|---|---|
| Message-ID | <[email protected]> |
Hello all, In another thread I've looked closely at the behaviour of login concerning the utmprecords. It looks like login does not store the right pid in the utmp record. To test this, I did: first do su, from the konsole, to become root. Then I start login, end enter my credentials. I look with the command "who -u" to the users logged in, I see: who -u --snip root su[6041] Oct 14 10:25 ? 6041 sbon pts/1 Oct 14 10:25 00:02 6124 And when I look at the processes with "ps aux" I get: --snip root 6124 0.0 0.7 6544 2020 ? S 10:25 0:00 login --sbon sbon 6183 0.0 0.7 5396 1972 pts/1 Ss 10:25 0:00 -bash Now when I look at this, this can't be right! In the utmp file the pid of the login process is stored (output of who), and not of the userprocess: bash (6183: output of ps)!! This looks like a bug to me. When I look to the source of login, I can explain this very easy: in entry in the utmpdatabase is written before forking (creating a childprocess for the user to enter his shell) and so the pid is taken of the parent (login) process, and not of the child (shell). Am I right on this?? Stef Bon PS When I look to another way to login, kdm, this is handled ok. I discovered this difference in behaviour working on my hint to execute scripts at the begin and the end of a usersession, using PAM. Look at: http://www.linuxfromscratch.org/hints/read.html