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

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