Introducing pam_rundir

As a user of a Linux system, you should have a runtime directory available for applications. Such a thing is even defined in the XDG Base Directory Specifications, as $XDG_RUNTIME_DIR -- and it is quite likely that you do have one set up.

You may have a session manager or some other component of your system handling this directory for you, in which case the following likely won't be of much interest to you. If you do not have a $XDG_RUNTIME_DIR however, let me introduce a little PAM module to take care of it.

I'm running Arch Linux, as under Arch one would usually use systemd-logind as session manager, which takes care of $XDG_RUNTIME_DIR for you. I do not run systemd however, and as such I was left without anything to handle it for me.

So after looking for a solution, as that's a nice thing to have, and failing to find one, I wrote myself a little PAM module to do just that: pam_rundir

It's a small PAM module that can be used to provide user runtime directory, as per the previously mentioned specs. It will create the directory (with correct ownership/permissions) on login, and remove it on log out (unless there's another session active, of course). And it'll set the environment variable $XDG_RUNTIME_DIR to its full path, as you'd expect.

That's it, but when you don't have something handling it, that's all you need. As usual all the links (download, source code, etc) can be found on the pam_rundir page.

Top of Page