Sophie

Sophie

distrib > Mageia > 9 > armv7hl > media > core-release-src > by-pkgid > bbc17d603c1242243c2fce94e0548f45 > files > 1

pam_mount-2.19-1.mga9.src.rpm

diff -uNrp pam_mount-2.15.orig/config/pam_mount.conf.xml pam_mount-2.15/config/pam_mount.conf.xml
--- pam_mount-2.15.orig/config/pam_mount.conf.xml	2014-12-01 08:35:30.000000000 -0500
+++ pam_mount-2.15/config/pam_mount.conf.xml	2015-03-12 14:10:39.700289595 -0400
@@ -39,6 +39,9 @@
 		<!-- pam_mount parameters: Volume-related -->
 
 <mkmountpoint enable="1" remove="true" />
+<!--
+<ismountpoint mountover="true" />
+-->
 
 
 </pam_mount>
diff -uNrp pam_mount-2.15.orig/config/pam_mount.conf.xml.dtd pam_mount-2.15/config/pam_mount.conf.xml.dtd
--- pam_mount-2.15.orig/config/pam_mount.conf.xml.dtd	2014-12-01 08:35:30.000000000 -0500
+++ pam_mount-2.15/config/pam_mount.conf.xml.dtd	2015-03-12 14:11:44.480521337 -0400
@@ -1,9 +1,9 @@
 <!ELEMENT pam_mount
 	(debug?,volume*,luserconf?,mntoptions*,
-	path?,logout?,mkmountpoint?,fsck?,cifsmount?,
-	smbmount?,smbumount?,ncpmount?,ncpumount?,fusemount?,
-	fuseumount?,fd0ssh?,ofl?,umount?,
-	lclmount?,cryptmount?,nfsmount?,pmvarrun?,
+	path?,logout?,mkmountpoint?,ismountpoint?,
+	fsck?,cifsmount?,smbmount?,smbumount?,ncpmount?,
+	ncpumount?,fusemount?,fuseumount?,fd0ssh?,ofl?,
+	umount?,lclmount?,cryptmount?,nfsmount?,pmvarrun?,
 	msg-authpw?,msg-sessionpw?)>
 <!ELEMENT debug EMPTY>
 <!ATTLIST debug
@@ -13,6 +13,10 @@
 	enable CDATA #IMPLIED
 	remove CDATA #IMPLIED
 >
+<!ELEMENT ismountpoint EMPTY>
+<!ATTLIST ismountpoint
+	mountover CDATA #IMPLIED
+>
 <!ATTLIST fsckloop
 	device CDATA #IMPLIED
 >
diff -uNrp pam_mount-2.15.orig/doc/pam_mount.conf.5.in pam_mount-2.15/doc/pam_mount.conf.5.in
--- pam_mount-2.15.orig/doc/pam_mount.conf.5.in	2014-12-01 08:35:30.000000000 -0500
+++ pam_mount-2.15/doc/pam_mount.conf.5.in	2015-03-12 14:10:15.470202916 -0400
@@ -212,6 +212,12 @@ to create one using the \fBenable\fP att
 this way are retained after logout, but \fBremove\fP may be set to \fBtrue\fP
 to remove the mountpoint again, \fIbut only\fP if it was automatically created
 by pam_mount in the same session before.
+.TP
+\fB<ismountpoint mountover="true" />\fP
+Controls whether pam_mount will mount over an active mountpoint.  If a
+mountpoint is already active, pam_mount can be instructed to mount over it
+using the \fBmountover\fP attribute. Normally, pam_mount will not mount over
+an active mountpoint.
 .SS Auxiliary programs
 .PP
 Some mount programs need special default parameters to properly function. It is
diff -uNrp pam_mount-2.15.orig/src/mount.c pam_mount-2.15/src/mount.c
--- pam_mount-2.15.orig/src/mount.c	2014-12-01 08:35:30.000000000 -0500
+++ pam_mount-2.15/src/mount.c	2015-03-12 14:23:21.643015433 -0400
@@ -35,6 +35,7 @@
 
 /* Functions */
 static inline bool mkmountpoint(struct vol *, const char *);
+static inline bool ismountpoint(const char *);
 
 //-----------------------------------------------------------------------------
 /**
@@ -376,6 +377,46 @@ static bool mkmountpoint(struct vol *vol
 }
 
 /**
+ * ismountpoint - determine if directory is already an active mountpoint
+ * @d:		directory to check
+ *
+ * Checks to see if the directory already is an active mountpoint.
+ */
+static bool ismountpoint(const char *d)
+{
+	struct stat sb;
+	hxmc_t *dtmp;
+	char *last;
+	bool newdev = false;
+	dev_t device;
+	dev_t olddev = 0;
+
+	dtmp = HXmc_strinit(d);
+	if (dtmp == NULL || HXmc_strcat(&dtmp, "/") == NULL) {
+		l0g("HXmc_strinit: %s\n", strerror(errno));
+		HXmc_free(dtmp);
+		return true;
+	}
+	w4rn("%s: checking /\n", __func__);
+	if (stat("/", &sb) != 0)
+		return true;
+	olddev = sb.st_dev;
+	last = dtmp;
+	while ((last = strchr(last + 1, '/')) != NULL) {
+		*last = '\0';
+		w4rn("%s: checking %s\n", __func__, dtmp);
+		if (stat(dtmp, &sb) != 0)
+			return true;
+		device = sb.st_dev;
+		newdev = (device != olddev);
+		olddev = device;
+		*last = '/';
+	}
+	HXmc_free(dtmp);
+	return newdev;
+}
+
+/**
  * do_unmount -
  * @config:	current config
  * @vpt:	volume descriptor
@@ -635,6 +676,11 @@ int do_mount(const struct config *config
 			return 0;
 		}
 	}
+	if (!config->mountover && ismountpoint(vpt->mountpoint)) {
+		l0g("mount point %s is already an active mount point (pam_mount not "
+		    "configured to mount over it)\n", vpt->mountpoint);
+		return 0;
+	}
 
 	if (config->command[vpt->type]->items == 0) {
 		l0g("proper mount command not defined in "
diff -uNrp pam_mount-2.15.orig/src/pam_mount.h pam_mount-2.15/src/pam_mount.h
--- pam_mount-2.15.orig/src/pam_mount.h	2014-12-01 08:35:30.000000000 -0500
+++ pam_mount-2.15/src/pam_mount.h	2015-03-12 14:16:06.981460411 -0400
@@ -99,7 +99,7 @@ struct config {
 	/* user logging in */
 	char *user;
 	unsigned int debug;
-	bool mkmntpoint, rmdir_mntpt;
+	bool mkmntpoint, rmdir_mntpt, mountover;
 	bool seen_mntoptions_require, seen_mntoptions_allow;
 	hxmc_t *luserconf;
 	struct HXdeque *command[_CMD_MAX];
diff -uNrp pam_mount-2.15.orig/src/rdconf1.c pam_mount-2.15/src/rdconf1.c
--- pam_mount-2.15.orig/src/rdconf1.c	2014-12-01 08:35:30.000000000 -0500
+++ pam_mount-2.15/src/rdconf1.c	2015-03-12 14:01:25.168302867 -0400
@@ -759,6 +759,16 @@ static const char *rc_mkmountpoint(xmlNo
 	return NULL;
 }
 
+static const char *rc_ismountpoint(xmlNode *node, struct config *config,
+    unsigned int command)
+{
+	char *s;
+	if ((s = xml_getprop(node, "mountover")) != NULL)
+		config->mountover = parse_bool(s);
+	free(s);
+	return NULL;
+}
+
 static const char *rc_mntoptions(xmlNode *node, struct config *config,
     unsigned int command)
 {
@@ -1454,6 +1464,7 @@ static const struct callbackmap cf_tags[
 	{"logout",          rc_logout,              CMD_NONE},
 	{"luserconf",       rc_luserconf,           CMD_NONE},
 	{"mkmountpoint",    rc_mkmountpoint,        CMD_NONE},
+	{"ismountpoint",    rc_ismountpoint,        CMD_NONE},
 	{"mntoptions",      rc_mntoptions,          CMD_NONE},
 	{"msg-authpw",      rc_string,              CMDA_AUTHPW},
 	{"msg-sessionpw",   rc_string,              CMDA_SESSIONPW},