pam-hooks - Linux-PAM module for login/logout hooks

pam-hooks is a tiny teeny PAM module enabling the execution of hook scripts when a PAM session is opened or closed. The typical use case (actually, my use case) is the need of doing some per-user set-up when a user logs via a PAM-aware login mechanism (e.g. GDM in my case) and/or the need of doing some per-user clean-up when the user logs out.

In order to use pam-hooks you need to add a line like the following at the end of the PAM configuration file of the service you want the hooks to be attached to (e.g. /etc/pam.d/gdm):

session required pam_hooks.so /some/where/pam-hook param1 ... paramN

The script /some/where/pam-hook will be invoked both when the corresponding PAM session will be opened and when it will be closed. The script will be executed using system() (so beware of what you do!), and passed the following arguments in the following order:

  • all the positional parameters appended to the PAM configuration line (will be param1 ... paramN in the sample line above)
  • a single tag argument which will be one of "open" (passed when the session is being opened), "close" (passed when the session is being closed)
  • a single username argument, corresponding to the user which is being opening/closing the session

Download

pam-hooks is freely distributed under the GNU General Public License; it is available here for download:

  • changelog, aka news
  • latest version 0.2.0:
    • tarball (sources): .tar.gz
    • Debian source package: .dsc
    • Debian (amd64) binary package: .deb
  • old versions (sources only): 0.0.1