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

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