Blame SOURCES/autofs-5.1.8-fix-incorrect-path-for-is_mounted-in-try_remount.patch

de1ab5
autofs-5.1.8 - fix incorrect path for is_mounted() in try_remount()
de1ab5
de1ab5
From: Ian Kent <raven@themaw.net>
de1ab5
de1ab5
A regression was introduced when the offset mount handling was rewritten.
de1ab5
de1ab5
It resulted in an incorrect path sometimes being used in an is_mounted()
de1ab5
check.
de1ab5
de1ab5
Signed-off-by: Ian Kent <raven@themaw.net>
de1ab5
---
de1ab5
 CHANGELOG    |    1 +
de1ab5
 lib/mounts.c |   26 +++++++++++++++++++++-----
de1ab5
 2 files changed, 22 insertions(+), 5 deletions(-)
de1ab5
de1ab5
--- autofs-5.1.7.orig/CHANGELOG
de1ab5
+++ autofs-5.1.7/CHANGELOG
de1ab5
@@ -111,6 +111,7 @@
de1ab5
 - fix deadlock with hosts map reload.
de1ab5
 - fix memory leak in update_hosts_mounts().
de1ab5
 - fix minus only option handling in concat_options().
de1ab5
+- fix incorrect path for is_mounted() in try_remount().
de1ab5
 
de1ab5
 25/01/2021 autofs-5.1.7
de1ab5
 - make bind mounts propagation slave by default.
de1ab5
--- autofs-5.1.7.orig/lib/mounts.c
de1ab5
+++ autofs-5.1.7/lib/mounts.c
de1ab5
@@ -2803,14 +2803,30 @@ int try_remount(struct autofs_point *ap,
de1ab5
 			ap->flags &= ~MOUNT_FLAG_DIR_CREATED;
de1ab5
 		else
de1ab5
 			ap->flags |= MOUNT_FLAG_DIR_CREATED;
de1ab5
+		goto done;
de1ab5
+	}
de1ab5
+
de1ab5
+	me->flags &= ~MOUNT_FLAG_DIR_CREATED;
de1ab5
+	/* Direct or offset mount, key is full path */
de1ab5
+	if (MM_PARENT(me)->key[0] == '/') {
de1ab5
+		if (!is_mounted(MM_PARENT(me)->key, MNTS_REAL))
de1ab5
+			me->flags |= MOUNT_FLAG_DIR_CREATED;
de1ab5
 	} else {
de1ab5
-		me->flags &= ~MOUNT_FLAG_DIR_CREATED;
de1ab5
-		if (type == t_offset) {
de1ab5
-			if (!is_mounted(MM_PARENT(me)->key, MNTS_REAL))
de1ab5
-				me->flags |= MOUNT_FLAG_DIR_CREATED;
de1ab5
+		char *p_key = MM_PARENT(me)->key;
de1ab5
+		char mp[PATH_MAX + 1];
de1ab5
+		int len;
de1ab5
+
de1ab5
+		len = mount_fullpath(mp, PATH_MAX, ap->path, ap->len, p_key);
de1ab5
+		if (len > PATH_MAX) {
de1ab5
+			/* This should never happen due to earlier checks */
de1ab5
+			error(ap->logopt, "mountpoint path too long");
de1ab5
+			return 0;
de1ab5
 		}
de1ab5
-	}
de1ab5
 
de1ab5
+		if (!is_mounted(mp, MNTS_REAL))
de1ab5
+			me->flags |= MOUNT_FLAG_DIR_CREATED;
de1ab5
+	}
de1ab5
+done:
de1ab5
 	/*
de1ab5
 	 * Either we opened the mount or we're re-reading the map.
de1ab5
 	 * If we opened the mount and ioctlfd is not -1 we have