pam_mount: Fixing multiple mounts in Debian 9

Building a backported Debian package

pam_mount: Fixing multiple mounts in Debian 9

We recently stumbled across a problem with pam_mount on Debian 9 mounting users’ home and group directories from an SMB share multiple times upon user login for all running sessions. On each login, in parallel or subsequently, pam_mount mounted these directories. Additionaly, on logout the directories have not been cleanly unmounted. This resulted in a huge confusing mount table of superfluous mounts.

The problem is known and has been fixed in Debian 10 (buster/testing). But since we want to stay on Debian 9 (stretch/stable) and no backport of the pam_mount package existed, we built the backport ourselves to fix the multi-mount issue. To do this we followed the Building Tutorial on the Debian wiki.

Install build toolchain

For building the backported libpam-mount Debian package, we need to install dpkg-dev and devscripts from stable and a newer version of debhelper from testing through the backports repository.

echo "deb-src http://deb.debian.org/debian buster main" >> /etc/apt/sources.list
echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list
apt-get update
apt-get install dpkg-dev devscripts
apt-get -t stretch-backports install debhelper

Install source package and its dependencies

Next we fetch the source code of libpam-mount and install the necessary build dependencies.

apt-get source libpam-mount
apt-get build-dep libpam-mount

Build and install package

Then we build the Debian package and finally install it.

cd libpam-mount-2.16
debuild -i -us -uc -b
dpkg -i ../libpam-mount_2.16-9_amd64.deb

Unfortunately, then another problem showed up.

Error reading login count from pmvarrun

The program pmvarrun was missing, which keeps track of the session count. Without pmvarrun when there are multiple open login sessions and one of them was logged out, also the mounts got unmounted and became unavailable for the other still running sessions. We forgot to install the package libpam-mount-bin, which we also just built. So this is solved very quickly.

dpkg -i ../libpam-mount-bin_2.16-9_amd64.deb

The multiple mounting problem and unwanted unmounts through logging out from a second session should now be fixed.

References

[1] Bug report and fix: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=627085
[2] Building Tutorial: https://wiki.debian.org/BuildingTutorial