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

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