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

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