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

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