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

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