Blame SOURCES/autofs-5.1.8-fix-handling-of-incorrect-return-from-umount_ent.patch

b07c2e
autofs-5.1.8 - fix handling of incorrect return from umount_ent()
b07c2e
b07c2e
From: Ian Kent <raven@themaw.net>
b07c2e
b07c2e
Commit 0210535df4b ("autofs-5.1.0 - gaurd against incorrect umount
b07c2e
return") guards against umount_ent() returning a fail when the mount
b07c2e
has actually been umounted.
b07c2e
b07c2e
But we also see umount_ent() return success when in fact the mount has
b07c2e
not been umounted leading to incorrect handling of automounts.
b07c2e
b07c2e
So checking the return of umount_ent() isn't always giving the correct
b07c2e
result in more than just one case, consequently we should ignore the
b07c2e
result from the spawned umount(8) and check if the mount has in fact
b07c2e
been umounted.
b07c2e
b07c2e
Signed-off-by: Ian Kent <raven@themaw.net>
b07c2e
---
b07c2e
 CHANGELOG          |    1 +
b07c2e
 daemon/automount.c |    3 +--
b07c2e
 lib/mounts.c       |   19 ++++++++++---------
b07c2e
 3 files changed, 12 insertions(+), 11 deletions(-)
b07c2e
b07c2e
--- autofs-5.1.4.orig/CHANGELOG
b07c2e
+++ autofs-5.1.4/CHANGELOG
b07c2e
@@ -93,6 +93,7 @@
b07c2e
 - avoid calling pthread_getspecific() with NULL key_thread_attempt_id.
b07c2e
 - fix sysconf(3) return handling.
b07c2e
 - remove nonstrict parameter from tree_mapent_umount_offsets().
b07c2e
+- fix handling of incorrect return from umount_ent().
b07c2e
 
b07c2e
 xx/xx/2018 autofs-5.1.5
b07c2e
 - fix flag file permission.
b07c2e
--- autofs-5.1.4.orig/daemon/automount.c
b07c2e
+++ autofs-5.1.4/daemon/automount.c
b07c2e
@@ -606,8 +606,7 @@ static int umount_subtree_mounts(struct
b07c2e
 		struct mnt_list *mnt;
b07c2e
 
b07c2e
 		debug(ap->logopt, "unmounting dir = %s", path);
b07c2e
-		if (umount_ent(ap, path) &&
b07c2e
-		    is_mounted(path, MNTS_REAL)) {
b07c2e
+		if (umount_ent(ap, path)) {
b07c2e
 			warn(ap->logopt, "could not umount dir %s", path);
b07c2e
 			left++;
b07c2e
 			goto done;
b07c2e
--- autofs-5.1.4.orig/lib/mounts.c
b07c2e
+++ autofs-5.1.4/lib/mounts.c
b07c2e
@@ -1869,8 +1869,7 @@ static int tree_mapent_umount_offset(str
b07c2e
 	 */
b07c2e
 	if (oe->ioctlfd != -1 ||
b07c2e
 	    is_mounted(oe->key, MNTS_REAL)) {
b07c2e
-		if (umount_ent(ap, oe->key) &&
b07c2e
-		    is_mounted(oe->key, MNTS_REAL)) {
b07c2e
+		if (umount_ent(ap, oe->key)) {
b07c2e
 			debug(ap->logopt,
b07c2e
 			      "offset %s has active mount, invalidate",
b07c2e
 			      oe->key);
b07c2e
@@ -2010,8 +2009,7 @@ int tree_mapent_umount_offsets(struct ma
b07c2e
 		 */
b07c2e
 		if (is_mounted(mp, MNTS_REAL)) {
b07c2e
 			info(ap->logopt, "unmounting dir = %s", mp);
b07c2e
-			if (umount_ent(ap, mp) &&
b07c2e
-			    is_mounted(mp, MNTS_REAL)) {
b07c2e
+			if (umount_ent(ap, mp)) {
b07c2e
 				if (!tree_mapent_mount_offsets(oe, 1))
b07c2e
 					warn(ap->logopt,
b07c2e
 					     "failed to remount offset triggers");
b07c2e
@@ -2982,6 +2980,7 @@ void set_direct_mount_tree_catatonic(str
b07c2e
 
b07c2e
 int umount_ent(struct autofs_point *ap, const char *path)
b07c2e
 {
b07c2e
+	unsigned int mounted;
b07c2e
 	int rv;
b07c2e
 
b07c2e
 	if (ap->state != ST_SHUTDOWN_FORCE)
b07c2e
@@ -2993,6 +2992,8 @@ int umount_ent(struct autofs_point *ap,
b07c2e
 		rv = spawn_umount(ap->logopt, "-l", path, NULL);
b07c2e
 	}
b07c2e
 
b07c2e
+	mounted = is_mounted(path, MNTS_REAL);
b07c2e
+
b07c2e
 	if (rv && (ap->state == ST_SHUTDOWN_FORCE || ap->state == ST_SHUTDOWN)) {
b07c2e
 		/*
b07c2e
 		 * Verify that we actually unmounted the thing.  This is a
b07c2e
@@ -3004,20 +3005,20 @@ int umount_ent(struct autofs_point *ap,
b07c2e
 		 * so that we do not try to call rmdir_path on the
b07c2e
 		 * directory.
b07c2e
 		 */
b07c2e
-		if (is_mounted(path, MNTS_REAL)) {
b07c2e
+		if (mounted) {
b07c2e
 			crit(ap->logopt,
b07c2e
 			     "the umount binary reported that %s was "
b07c2e
 			     "unmounted, but there is still something "
b07c2e
 			     "mounted on this path.", path);
b07c2e
-			rv = -1;
b07c2e
+			mounted = -1;
b07c2e
 		}
b07c2e
 	}
b07c2e
 
b07c2e
-	/* On success, check for mounted mount and remove it if found */
b07c2e
-	if (!rv)
b07c2e
+	/* If mount is gone remove it from mounted mounts list. */
b07c2e
+	if (!mounted)
b07c2e
 		mnts_remove_mount(path, MNTS_MOUNTED);
b07c2e
 
b07c2e
-	return rv;
b07c2e
+	return mounted;
b07c2e
 }
b07c2e
 
b07c2e
 int umount_amd_ext_mount(struct autofs_point *ap, const char *path)