Blob Blame History Raw
autofs-5.1.5 - fix unlink_mount_tree() not umounting mounts

From: Ian Kent <raven@themaw.net>

At some point a check matching process group id of mounts was added to
the unlink_mount_tree() function so that mounts not matching the group
id of the calling process would be skipped.

But unlink_mount_tree() is meant to force a cleanup of mounts from a
previous automount process so the process group of the current process
can never match so all mounts are skipped.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG         |    1 +
 daemon/direct.c   |    7 -------
 daemon/indirect.c |    9 ---------
 include/mounts.h  |    1 -
 lib/mounts.c      |   20 --------------------
 5 files changed, 1 insertion(+), 37 deletions(-)

--- autofs-5.0.7.orig/CHANGELOG
+++ autofs-5.0.7/CHANGELOG
@@ -333,6 +333,7 @@
 - remove unused function reverse_mnt_list().
 - remove a couple of old debug messages.
 - fix amd entry memory leak.
+- fix unlink_mount_tree() not umounting mounts.
 
 25/07/2012 autofs-5.0.7
 =======================
--- autofs-5.0.7.orig/daemon/direct.c
+++ autofs-5.0.7/daemon/direct.c
@@ -264,10 +264,6 @@ static int unlink_mount_tree(struct auto
 {
 	struct list_head *p;
 	int rv, ret;
-	pid_t pgrp = getpgrp();
-	char spgrp[20];
-
-	sprintf(spgrp, "pgrp=%d", pgrp);
 
 	ret = 1;
 	list_for_each(p, list) {
@@ -275,9 +271,6 @@ static int unlink_mount_tree(struct auto
 
 		mnt = list_entry(p, struct mnt_list, list);
 
-		if (strstr(mnt->opts, spgrp))
-			continue;
-
 		if (strcmp(mnt->fs_type, "autofs"))
 			rv = spawn_umount(ap->logopt, "-l", mnt->path, NULL);
 		else
--- autofs-5.0.7.orig/daemon/indirect.c
+++ autofs-5.0.7/daemon/indirect.c
@@ -44,19 +44,10 @@ static int unlink_mount_tree(struct auto
 {
 	struct mnt_list *this;
 	int rv, ret;
-	pid_t pgrp = getpgrp();
-	char spgrp[20];
-
-	sprintf(spgrp, "pgrp=%d", pgrp);
 
 	ret = 1;
 	this = mnts;
 	while (this) {
-		if (strstr(this->opts, spgrp)) {
-			this = this->next;
-			continue;
-		}
-
 		if (strcmp(this->fs_type, "autofs"))
 			rv = spawn_umount(ap->logopt, "-l", this->path, NULL);
 		else
--- autofs-5.0.7.orig/include/mounts.h
+++ autofs-5.0.7/include/mounts.h
@@ -53,7 +53,6 @@ struct mnt_list {
 	char *fs_name;
 	char *fs_type;
 	char *opts;
-	pid_t owner;
 	/*
 	 * List operations ie. get_mnt_list.
 	 */
--- autofs-5.0.7.orig/lib/mounts.c
+++ autofs-5.0.7/lib/mounts.c
@@ -799,7 +799,6 @@ struct mnt_list *get_mnt_list(const char
 	struct mntent *mnt;
 	struct mnt_list *ent, *mptr, *last;
 	struct mnt_list *list = NULL;
-	char *pgrp;
 	size_t len;
 
 	if (!path || !pathlen || pathlen > PATH_MAX)
@@ -880,15 +879,6 @@ struct mnt_list *get_mnt_list(const char
 			return NULL;
 		}
 		strcpy(ent->opts, mnt->mnt_opts);
-
-		ent->owner = 0;
-		pgrp = strstr(mnt->mnt_opts, "pgrp=");
-		if (pgrp) {
-			char *end = strchr(pgrp, ',');
-			if (end)
-				*end = '\0';
-			sscanf(pgrp, "pgrp=%d", &ent->owner);
-		}
 	}
 	endmntent(tab);
 
@@ -1062,7 +1052,6 @@ struct mnt_list *tree_make_mnt_tree(cons
 	struct mntent *mnt;
 	struct mnt_list *ent, *mptr;
 	struct mnt_list *tree = NULL;
-	char *pgrp;
 	size_t plen;
 	int eq;
 
@@ -1141,15 +1130,6 @@ struct mnt_list *tree_make_mnt_tree(cons
 		}
 		strcpy(ent->opts, mnt->mnt_opts);
 
-		ent->owner = 0;
-		pgrp = strstr(mnt->mnt_opts, "pgrp=");
-		if (pgrp) {
-			char *end = strchr(pgrp, ',');
-			if (end)
-				*end = '\0';
-			sscanf(pgrp, "pgrp=%d", &ent->owner);
-		}
-
 		mptr = tree;
 		while (mptr) {
 			int elen = strlen(ent->path);