Package: libpam-mount
Version: 0.9.25-3
Severity: normal
Tags: patch

if the mount point contains links then only the real path is stored in mtab.
So, at the next check, process fails to see that volume is already mounted and 
mounts it twice.

Patch included doubles the path check : with original volume path and its 
realpath. 
In case of match with realpath, return the original volume path.

-- System Information:
Debian Release: 3.1
Architecture: i386 (i686)
Kernel: Linux 2.6.11.11
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages libpam-mount depends on:
ii  libc6                  2.3.2.ds1-22      GNU C Library: Shared libraries an
ii  libglib2.0-0           2.6.4-1           The GLib library of C routines
ii  libssl0.9.7            0.9.7e-3          SSL shared libraries
ii  mount                  2.12p-4           Tools for mounting and manipulatin
ii  zlib1g                 1:1.2.2-4.sarge.2 compression library - runtime

-- no debconf information
diff -ru pam_mount-0.9.25/src/mount.c libpam-mount-0.9.25-x/src/mount.c
--- pam_mount-0.9.25/src/mount.c	2005-05-16 06:11:30.000000000 +0200
+++ libpam-mount-0.9.25-x/src/mount.c	2005-09-19 15:46:53.000000000 +0200
@@ -128,6 +128,7 @@
 			   fmt_ptrn_t *vinfo)
 {
 	char match[PATH_MAX + 1];
+	char realvolmntpt[PATH_MAX + 1];
 	int mounted = 0;
 #if defined(__linux__)
 	FILE *mtab;
@@ -186,6 +187,15 @@
 		l0g("pam_mount: %s\n", "could not open /etc/mtab");
 		return -1;
 	}
+	if (!realpath(config->volume[vol].mountpoint, realvolmntpt)) {
+		w4rn("pam_mount: can't get realpath of volume (%s)\n", config->volume[vol].mountpoint);
+		strncpy(realvolmntpt, config->volume[vol].mountpoint, PATH_MAX);
+		realvolmntpt[PATH_MAX] = 0x00;
+	} else {
+		realvolmntpt[PATH_MAX] = 0x00;
+		w4rn("pam_mount: realpath of volume (%s) is (%s)\n", config->volume[vol].mountpoint, realvolmntpt);
+	}
+
 	w4rn("pam_mount: checking to see if %s is already mounted at %s\n",
 	     match, config->volume[vol].mountpoint);
 	while ((mtab_record = getmntent(mtab)) != NULL) {
@@ -215,9 +225,14 @@
 			strncpy(mntpt, mtab_record->mnt_dir, PATH_MAX);
 			mntpt[PATH_MAX] = 0x00;
 			mounted = 1;
-			if (!strcmp(mtab_record->mnt_dir,
-				    config->volume[vol].mountpoint)) {
-				strncpy(mntpt, mtab_record->mnt_dir,
+			if (
+				(!strcmp(mtab_record->mnt_dir,
+				    config->volume[vol].mountpoint))
+				||
+				(!strcmp(mtab_record->mnt_dir,
+				    realvolmntpt))
+				) {
+				strncpy(mntpt, config->volume[vol].mountpoint,
 					PATH_MAX);
 				mntpt[PATH_MAX] = 0x00;
 				break;

Reply via email to