Hi,I had a look into this and at least for my use case (mounting a crypto volume). The mount check fails because the device name gets mangled through the device mapper. The attached patch works around this.
@Martin can you check if this helps you?@Jan can you give some feedback if this makes sense or do you have a better idea how to solve this?
Cheers Jochen * martin f krafft <madd...@debian.org> [2017-10-04 14:40]:
also sprach Jochen Sprickerhof <jspri...@debian.org> [2017-10-04 11:41 +0200]:> I thought part of the deal with libpam-mount was that it kept > a session counter and only mounted if (!mounted) and only > unmounted if (mounted && n == 0) I assume it does not, but I didn't check the sources.modify_pm_count is the function that modifies the per-user counter: https://sources.debian.net/src/libpam-mount/2.16-3/src/pmvarrun.c/#L209 man pmvarrun(8)… pmt_already_mounted checks mtab for whether a volume is already mounted: https://sources.debian.net/src/libpam-mount/2.16-3/src/mount.c/#L140 So I'd say that this functionality is included, and if it's not working as expected, then there's a bug. -- .''`. martin f. krafft <madduck@d.o> @martinkrafft : :' : proud Debian developer `. `'` http://people.debian.org/~madduck `- Debian - when you have better things to do than fixing systems "courage is not the absence of fear, but the decision that something else is more important than fear." -- ambrose redmoon
From ff79a904fc7fd2c71f6afe5504902a2563f6738a Mon Sep 17 00:00:00 2001 From: Jochen Sprickerhof <jspri...@debian.org> Date: Mon, 25 Dec 2017 20:13:41 +0100 Subject: [PATCH] Add patch for mount point comparison --- ...re-source-when-checking-if-it-s-already-m.patch | 33 ++++++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 34 insertions(+) create mode 100644 debian/patches/0014-Don-t-compare-source-when-checking-if-it-s-already-m.patch diff --git a/debian/patches/0014-Don-t-compare-source-when-checking-if-it-s-already-m.patch b/debian/patches/0014-Don-t-compare-source-when-checking-if-it-s-already-m.patch new file mode 100644 index 0000000..dc1d2f2 --- /dev/null +++ b/debian/patches/0014-Don-t-compare-source-when-checking-if-it-s-already-m.patch @@ -0,0 +1,33 @@ +From: Jochen Sprickerhof <jspri...@debian.org> +Date: Mon, 25 Dec 2017 21:05:34 +0100 +Subject: Don't compare source when checking if it's already mounted + +When mounting encrypted volumes, vpt->volume would be something like +/dev/sdaX but source would be /dev/mapper/_dev_sdaX. This way +pmt_utabent_matches would always return false. +--- + src/mount.c | 7 +------ + 1 file changed, 1 insertion(+), 6 deletions(-) + +diff --git a/src/mount.c b/src/mount.c +index 6c0d795..f0a4e3d 100644 +--- a/src/mount.c ++++ b/src/mount.c +@@ -124,16 +124,11 @@ static void run_ofl(const struct config *const config, const char *mntpt, + */ + static bool pmt_utabent_matches(const struct vol *vpt, struct libmnt_fs *fs) + { +- int (*xcmp)(const char *, const char *); +- const char *source = mnt_fs_get_source(fs); + const char *target = mnt_fs_get_target(fs); + bool result = false; + +- xcmp = fstype2_icase(vpt->type) ? strcasecmp : strcmp; +- if (source != NULL) +- result = xcmp(vpt->volume, source) == 0; + if (target != NULL) +- result &= strcmp(vpt->mountpoint, target) == 0; ++ result = strcmp(vpt->mountpoint, target) == 0; + return result; + } + diff --git a/debian/patches/series b/debian/patches/series index 165cd52..22fcc9d 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -11,3 +11,4 @@ 0011-Fix-fd0ssh-name-according-to-version-in-hxtools.patch 013-fix-doc-target 014-allow-luserconf-outside-home +0014-Don-t-compare-source-when-checking-if-it-s-already-m.patch -- 2.15.1
signature.asc
Description: PGP signature