Blame SOURCES/autofs-5.1.6-fix-unlink-mounts-umount-order.patch

213b36
autofs-5.1.6 - fix unlink mounts umount order
213b36
213b36
From: Ian Kent <raven@themaw.net>
213b36
213b36
The recent changes to mount table handling to support the "ignore"
213b36
autofs pseudo option resulted in the incorrect umount order being used
213b36
in the unlink_mount_tree() function.
213b36
213b36
To fix this change unlink_mount_tree() to use the existing get_mnt_list()
213b36
function to construct a correctly ordered list for the umounts.
213b36
213b36
Signed-off-by: Ian Kent <raven@themaw.net>
213b36
---
213b36
 CHANGELOG    |    1 +
213b36
 lib/mounts.c |   39 +++++++++------------------------------
213b36
 2 files changed, 10 insertions(+), 30 deletions(-)
213b36
213b36
--- autofs-5.1.4.orig/CHANGELOG
213b36
+++ autofs-5.1.4/CHANGELOG
213b36
@@ -84,6 +84,7 @@ xx/xx/2018 autofs-5.1.5
213b36
 - mount_nfs.c fix local rdma share not mounting.
213b36
 - fix incorrect systemctl command syntax in autofs(8).
213b36
 - fix direct mount unlink_mount_tree() path.
213b36
+- fix unlink mounts umount order.
213b36
 
213b36
 19/12/2017 autofs-5.1.4
213b36
 - fix spec file url.
213b36
--- autofs-5.1.4.orig/lib/mounts.c
213b36
+++ autofs-5.1.4/lib/mounts.c
213b36
@@ -951,42 +951,21 @@ local_getmntent_r(FILE *tab, struct mnte
213b36
 
213b36
 int unlink_mount_tree(struct autofs_point *ap, const char *mp)
213b36
 {
213b36
-	FILE *tab;
213b36
-	struct mntent *mnt;
213b36
-	struct mntent mnt_wrk;
213b36
-	char buf[PATH_MAX * 3];
213b36
-	unsigned int mp_len = strlen(mp);
213b36
+	struct mnt_list *mnts, *mnt;
213b36
 	int rv, ret = 1;
213b36
 
213b36
-	tab = open_fopen_r(_PROC_MOUNTS);
213b36
-	if (!tab) {
213b36
-		char *estr = strerror_r(errno, buf, PATH_MAX - 1);
213b36
-		logerr("fopen: %s", estr);
213b36
+	mnts = get_mnt_list(mp, 1);
213b36
+	if (!mnts)
213b36
 		return 0;
213b36
-	}
213b36
-
213b36
-	while ((mnt = local_getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) {
213b36
-		unsigned int mnt_dir_len;
213b36
-		int is_autofs;
213b36
-
213b36
-		if (strncmp(mnt->mnt_dir, mp, mp_len))
213b36
-			continue;
213b36
-
213b36
-		mnt_dir_len = strlen(mnt->mnt_dir);
213b36
-		is_autofs = !strcmp(mnt->mnt_type, "autofs");
213b36
-
213b36
-		if (mnt_dir_len == mp_len && !is_autofs) {
213b36
-			ret = 0;
213b36
-			break;
213b36
-		}
213b36
 
213b36
-		if (is_autofs)
213b36
-			rv = umount2(mnt->mnt_dir, MNT_DETACH);
213b36
+	for (mnt = mnts; mnt; mnt = mnt->next) {
213b36
+		if (mnt->flags | MNTS_AUTOFS)
213b36
+			rv = umount2(mnt->mp, MNT_DETACH);
213b36
 		else
213b36
-			rv = spawn_umount(ap->logopt, "-l", mnt->mnt_dir, NULL);
213b36
+			rv = spawn_umount(ap->logopt, "-l", mnt->mp, NULL);
213b36
 		if (rv == -1) {
213b36
 			debug(ap->logopt,
213b36
-			      "can't unlink %s from mount tree", mnt->mnt_dir);
213b36
+			      "can't unlink %s from mount tree", mnt->mp);
213b36
 
213b36
 			switch (errno) {
213b36
 			case EINVAL:
213b36
@@ -1002,7 +981,7 @@ int unlink_mount_tree(struct autofs_poin
213b36
 			}
213b36
 		}
213b36
 	}
213b36
-	fclose(tab);
213b36
+	free_mnt_list(mnts);
213b36
 
213b36
 	return ret;
213b36
 }