PAM_LASTLOG(8)

๐Ÿ’– PAM_LASTLOG(8) ๐Ÿ’–

okay bestie, gather round, because we're about to talk about pam_lastlog โ€” that's the Linux-PAM Manual page for the lastlog module, and yes she's a whole vibe. ๐ŸŽ€


โœจ NAME โœจ

pam_lastlog โ€” a PAM module that shows you the date of your last login and does the inactive-account lockout thing. she does both. she's multitasking. ๐Ÿ’…


๐ŸŒธ SYNOPSIS ๐ŸŒธ

pam_lastlog.so [debug] [silent] [never] [nodate] [nohost] [noterm]
               [nowtmp] [noupdate] [showfailed] [inactive=<days>]
               [unlimited]

look at all those brackets, so many options, she's flexible fr fr ๐Ÿฆ‹


๐Ÿ’œ DESCRIPTION ๐Ÿ’œ

okay so pam_lastlog is a PAM module that displays a line of info about the user's last login. and on top of that, she also maintains the /var/log/lastlog file. upkeep queen ๐Ÿ‘‘

some applications do this whole thing themselves, lowkey. and in those cases? this module is not necessary. so don't be extra. ๐Ÿ™ˆ

here's the tea: the module checks the LASTLOG_UID_MAX option in /etc/login.defs, and it does not update or display last login records for users whose UID is higher than that value. if the option isn't there, or its value is invalid, then no user ID limit gets applied at all. no cap. โœจ

and if the module gets called in the auth or account phase? then accounts that weren't used recently enough get disallowed from logging in ๐Ÿ’€. but โ€” and this is important โ€” the check is not performed for the root account, so root never gets locked out. also not performed for users with a UID higher than the LASTLOG_UID_MAX value. periodt.


๐ŸŽ€ OPTIONS ๐ŸŽ€

  • debug โ€” prints debug information. she's telling you everything, oversharing era ๐Ÿ’ฌ
  • silent โ€” don't tell the user about any previous login, just update the /var/log/lastlog file. ngl this one does not affect the display of bad login attempts, so those still show up.
  • never โ€” if the /var/log/lastlog file has no old entries for the user, say that the user has never previously logged in, with a welcome message. aww. ๐Ÿซถ
  • nodate โ€” don't display the date of the last login. keeping it mysterious โœจ
  • noterm โ€” don't display the terminal name where the last login was attempted.
  • nohost โ€” don't indicate which host the last login was attempted from.
  • nowtmp โ€” don't update the wtmp entry.
  • noupdate โ€” don't update any file. zero updates. none. ๐Ÿ’€
  • showfailed โ€” display the number of failed login attempts and the date of the last failed attempt from btmp. (the date is not displayed when nodate is specified, so keep that in mind bestie)
  • inactive=<days> โ€” this one is specifically for the auth or account phase. it sets how many days after the user's last login the user gets locked out by the module. the default value is 90. ninety. ninety days of not logging in and you're out ๐Ÿšช
  • unlimited โ€” if the fsize limit is set, this option can override it, which prevents failures on systems with large UID values that lead lastlog to become a huge sparse file. huge sparse file is giving chaos ngl ๐Ÿ˜ญ

๐Ÿ‘‘ MODULE TYPES PROVIDED ๐Ÿ‘‘

the auth and account module types let you lock out users who didn't log in recently enough. ๐Ÿ”’

the session module type is provided for displaying the info about the last login and/or updating the lastlog and wtmp files. ๐ŸŒˆ


โญ RETURN VALUES โญ

  • PAM_SUCCESS โ€” everything was successful. we love a happy ending ๐Ÿ’–
  • PAM_SERVICE_ERR โ€” internal service module error. not her fault, it's internal ๐Ÿ˜ญ
  • PAM_USER_UNKNOWN โ€” user not known. who is she?? ๐Ÿ’€
  • PAM_AUTH_ERR โ€” user locked out in the auth or account phase due to inactivity.
  • PAM_IGNORE โ€” there was an error while reading the lastlog file in the auth or account phase, so the inactivity of the user can't be determined. shrug, we tried ๐Ÿคท

๐ŸŒˆ EXAMPLES ๐ŸŒˆ

drop this line into /etc/pam.d/login to display the last login time of a user:

session  required  pam_lastlog.so nowtmp

and if you wanna reject a user when they haven't logged in during the previous 50 days, use this line:

auth  required  pam_lastlog.so inactive=50

slay. copy, paste, done. โœจ


๐Ÿ“ FILES ๐Ÿ“

  • /var/log/lastlog โ€” the lastlog logging file. this is where the receipts live ๐Ÿงพ

๐Ÿฆ‹ SEE ALSO ๐Ÿฆ‹

limits.conf(5), pam.conf(5), pam.d(5), pam(7)

go read those too, bestie, the lore is deep ๐Ÿ“š


๐Ÿ’œ AUTHOR ๐Ÿ’œ

pam_lastlog was written by Andrew G. Morgan <morgan@kernel.org>.

inactive account lock out added by Tomรกลก Mrรกz <tm@t8m.info>.


and that's the whole page, no notes ๐Ÿ’… this was Linux-PAM Manual, version dated 09/03/2021 โ€” thanks for coming to my ted talk, mwah ๐Ÿซถโœจ

๐Ÿ“ฆ where this page comes from