Blame SOURCES/autofs-5.0.7-fix-null-map-entry-order-handling.patch

ab3a3d
autofs-5.0.7 - fix null map entry order handling
ab3a3d
ab3a3d
From: Ian Kent <ikent@redhat.com>
ab3a3d
ab3a3d
If a null map entry appears after a corresponding indirect map entry
ab3a3d
autofs doesn't handle it properly.
ab3a3d
ab3a3d
Since it appears after the map entry it should'nt affect it but autofs
ab3a3d
doesn't account for this case and assumes the map entry is already
ab3a3d
mounted and tries to shut it down causing attempted access to facilities
ab3a3d
that don't exist.
ab3a3d
---
ab3a3d
ab3a3d
 CHANGELOG    |    1 +
ab3a3d
 lib/master.c |   32 +++++++++++++++++++++++++++++---
ab3a3d
 2 files changed, 30 insertions(+), 3 deletions(-)
ab3a3d
ab3a3d
ab3a3d
diff --git a/CHANGELOG b/CHANGELOG
ab3a3d
index 7b8d185..79cf673 100644
ab3a3d
--- a/CHANGELOG
ab3a3d
+++ b/CHANGELOG
ab3a3d
@@ -7,6 +7,7 @@
ab3a3d
 - fix typo in automount(8).
ab3a3d
 - dont wait forever to restart.
ab3a3d
 - add timeout option description to man page.
ab3a3d
+- fix null map entry order handling.
ab3a3d
 
ab3a3d
 25/07/2012 autofs-5.0.7
ab3a3d
 =======================
ab3a3d
diff --git a/lib/master.c b/lib/master.c
ab3a3d
index 904b13d..a0e62f2 100644
ab3a3d
--- a/lib/master.c
ab3a3d
+++ b/lib/master.c
ab3a3d
@@ -1179,9 +1179,35 @@ int master_mount_mounts(struct master *master, time_t age, int readall)
ab3a3d
 
ab3a3d
 		cache_readlock(nc);
ab3a3d
 		ne = cache_lookup_distinct(nc, this->path);
ab3a3d
-		if (ne && this->age > ne->age) {
ab3a3d
+		/*
ab3a3d
+		 * If this path matched a nulled entry the master map entry
ab3a3d
+		 * must be an indirect mount so the master map entry line
ab3a3d
+		 * number may be obtained from this->maps.
ab3a3d
+		 */
ab3a3d
+		if (ne) {
ab3a3d
+			int lineno = ne->age;
ab3a3d
 			cache_unlock(nc);
ab3a3d
-			st_add_task(ap, ST_SHUTDOWN_PENDING);
ab3a3d
+
ab3a3d
+			/* null entry appears after map entry */
ab3a3d
+			if (this->maps->master_line < lineno) {
ab3a3d
+				warn(ap->logopt,
ab3a3d
+				     "ignoring null entry that appears after "
ab3a3d
+				     "existing entry for %s", this->path);
ab3a3d
+				goto cont;
ab3a3d
+			}
ab3a3d
+			if (ap->state != ST_INIT) {
ab3a3d
+				st_add_task(ap, ST_SHUTDOWN_PENDING);
ab3a3d
+				continue;
ab3a3d
+			}
ab3a3d
+			/*
ab3a3d
+			 * The map entry hasn't been started yet and we've
ab3a3d
+			 * seen a preceeding null map entry for it so just
ab3a3d
+			 * delete it from the master map entry list so it
ab3a3d
+			 * doesn't get in the road.
ab3a3d
+			 */
ab3a3d
+			list_del_init(&this->list);
ab3a3d
+			master_free_mapent_sources(ap->entry, 1);
ab3a3d
+			master_free_mapent(ap->entry);
ab3a3d
 			continue;
ab3a3d
 		}
ab3a3d
 		nested = cache_partial_match(nc, this->path);
ab3a3d
@@ -1194,7 +1220,7 @@ int master_mount_mounts(struct master *master, time_t age, int readall)
ab3a3d
 				cache_delete(nc, nested->key);
ab3a3d
 		}
ab3a3d
 		cache_unlock(nc);
ab3a3d
-
ab3a3d
+cont:
ab3a3d
 		st_mutex_lock();
ab3a3d
 
ab3a3d
 		state_pipe = this->ap->state_pipe[1];