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

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