Blob Blame History Raw
autofs-5.0.5 - fix master map source server unavailable handling

From: Ian Kent <raven@themaw.net>

If we get an NSS_STATUS_UNAVAIL from any server when trying to read
the master map we have no choice but to not update mounted automounts
because we can't know what entries may have come from the server that
isn't avialable. So we leave everything the way it is and wait until
the next re-read to update our mounts.
---

 CHANGELOG             |    1 +
 daemon/automount.c    |    5 +++--
 daemon/lookup.c       |    9 +++++++++
 include/master.h      |    1 +
 lib/master.c          |    9 ++++++++-
 modules/lookup_file.c |    2 --
 6 files changed, 22 insertions(+), 5 deletions(-)


--- autofs-5.0.5.orig/CHANGELOG
+++ autofs-5.0.5/CHANGELOG
@@ -28,6 +28,7 @@
 - add locality as valid ldap master map attribute.
 - add locality as valid ldap master map attribute fix.
 - add simple bind authentication.
+- fix master map source server unavailable handling.
 
 03/09/2009 autofs-5.0.5
 -----------------------
--- autofs-5.0.5.orig/daemon/automount.c
+++ autofs-5.0.5/daemon/automount.c
@@ -1478,7 +1478,6 @@ static void handle_mounts_cleanup(void *
 		master_free_mapent_sources(ap->entry, 1);
 		master_free_mapent(ap->entry);
 	}
-	master_mutex_unlock();
 
 	if (clean) {
 		if (rmdir(path) == -1) {
@@ -1497,7 +1496,9 @@ static void handle_mounts_cleanup(void *
 	 */
 	if (!submount)
 		pthread_kill(state_mach_thid, SIGTERM);
-	
+
+	master_mutex_unlock();
+
 	return;
 }
 
--- autofs-5.0.5.orig/daemon/lookup.c
+++ autofs-5.0.5/daemon/lookup.c
@@ -157,6 +157,9 @@ int lookup_nss_read_master(struct master
 			result = do_read_master(master, "file", age);
 		}
 
+		if (result == NSS_STATUS_UNAVAIL)
+			master->read_fail = 1;
+
 		return !result;
 	} else {
 		char *name = master->name;
@@ -194,6 +197,9 @@ int lookup_nss_read_master(struct master
 				result = do_read_master(master, source, age);
 				master->name = name;
 
+				if (result == NSS_STATUS_UNAVAIL)
+					master->read_fail = 1;
+
 				return !result;
 			}
 		}
@@ -248,6 +254,9 @@ int lookup_nss_read_master(struct master
 			continue;
 		}
 
+		if (result == NSS_STATUS_UNAVAIL)
+			master->read_fail = 1;
+
 		status = check_nss_result(this, result);
 		if (status >= 0) {
 			free_sources(&nsslist);
--- autofs-5.0.5.orig/include/master.h
+++ autofs-5.0.5/include/master.h
@@ -56,6 +56,7 @@ struct master {
 	unsigned int recurse;
 	unsigned int depth;
 	unsigned int reading;
+	unsigned int read_fail;
 	unsigned int default_ghost;
 	unsigned int default_logging;
 	unsigned int default_timeout;
--- autofs-5.0.5.orig/lib/master.c
+++ autofs-5.0.5/lib/master.c
@@ -794,6 +794,7 @@ struct master *master_new(const char *na
 	master->recurse = 0;
 	master->depth = 0;
 	master->reading = 0;
+	master->read_fail = 0;
 	master->default_ghost = ghost;
 	master->default_timeout = timeout;
 	master->default_logging = defaults_get_logging();
@@ -821,7 +822,13 @@ int master_read_master(struct master *ma
 	master_init_scan();
 
 	lookup_nss_read_master(master, age);
-	master_mount_mounts(master, age, readall);
+	if (!master->read_fail)
+		master_mount_mounts(master, age, readall);
+	else {
+		master->read_fail = 0;
+		if (!readall)
+			master_mount_mounts(master, age, readall);
+	}
 
 	master_mutex_lock();
 
--- autofs-5.0.5.orig/modules/lookup_file.c
+++ autofs-5.0.5/modules/lookup_file.c
@@ -656,8 +656,6 @@ int lookup_read_map(struct autofs_point 
 			if (!status) {
 				warn(ap->logopt,
 				     "failed to read included map %s", key);
-				fclose(f);
-				return NSS_STATUS_UNAVAIL;
 			}
 		} else {
 			char *s_key;