Blame SOURCES/autofs-5.1.2-fix-included-master-map-not-found-return.patch

306fa1
autofs-5.1.2 - fix included master map not found return
306fa1
306fa1
From: Ian Kent <raven@themaw.net>
306fa1
306fa1
When retrying the master map read at startup a not found return is needed
306fa1
when there is no map rather than an unknown or unavailable for the retry
306fa1
logic to work.
306fa1
306fa1
Signed-off-by: Ian Kent <raven@themaw.net>
306fa1
---
306fa1
 CHANGELOG             |    1 +
306fa1
 daemon/lookup.c       |    6 ++++--
306fa1
 modules/lookup_file.c |   18 ++++++++++++------
306fa1
 3 files changed, 17 insertions(+), 8 deletions(-)
306fa1
306fa1
--- autofs-5.0.7.orig/CHANGELOG
306fa1
+++ autofs-5.0.7/CHANGELOG
306fa1
@@ -208,6 +208,7 @@
306fa1
 - add config option to supress not found log message.
306fa1
 - wait for master map available at start.
306fa1
 - add master read wait option.
306fa1
+- fix included master map not found return.
306fa1
 
306fa1
 25/07/2012 autofs-5.0.7
306fa1
 =======================
306fa1
--- autofs-5.0.7.orig/daemon/lookup.c
306fa1
+++ autofs-5.0.7/daemon/lookup.c
306fa1
@@ -241,7 +241,7 @@ int lookup_nss_read_master(struct master
306fa1
 	}
306fa1
 
306fa1
 	/* First one gets it */
306fa1
-	result = NSS_STATUS_UNKNOWN;
306fa1
+	result = NSS_STATUS_SUCCESS;
306fa1
 	head = &nsslist;
306fa1
 	list_for_each(p, head) {
306fa1
 		struct nss_source *this;
306fa1
@@ -282,8 +282,10 @@ int lookup_nss_read_master(struct master
306fa1
 			}
306fa1
 		}
306fa1
 
306fa1
-		if (result == NSS_STATUS_UNKNOWN) {
306fa1
+		if (result == NSS_STATUS_UNKNOWN ||
306fa1
+		    result == NSS_STATUS_NOTFOUND) {
306fa1
 			debug(logopt, "no map - continuing to next source");
306fa1
+			result = NSS_STATUS_SUCCESS;
306fa1
 			continue;
306fa1
 		}
306fa1
 
306fa1
--- autofs-5.0.7.orig/modules/lookup_file.c
306fa1
+++ autofs-5.0.7/modules/lookup_file.c
306fa1
@@ -463,6 +463,8 @@ int lookup_read_master(struct master *ma
306fa1
 
306fa1
 	f = open_fopen_r(ctxt->mapname);
306fa1
 	if (!f) {
306fa1
+		if (errno == ENOENT)
306fa1
+			return NSS_STATUS_NOTFOUND;
306fa1
 		error(logopt,
306fa1
 		      MODPREFIX "could not open master map file %s",
306fa1
 		      ctxt->mapname);
306fa1
@@ -506,12 +508,14 @@ int lookup_read_master(struct master *ma
306fa1
 				     MODPREFIX
306fa1
 				     "failed to read included master map %s",
306fa1
 				     master->name);
306fa1
-				/*
306fa1
-				 * If we're starting up wee need the whole
306fa1
-				 * master map initially, so tell the upper
306fa1
-				 * layer to retry.
306fa1
-				 */
306fa1
-				master->read_fail = 1;
306fa1
+				if (status != NSS_STATUS_NOTFOUND) {
306fa1
+					/*
306fa1
+					 * If we're starting up wee need the whole
306fa1
+					 * master map initially, so tell the upper
306fa1
+					 * layer to retry.
306fa1
+					 */
306fa1
+					master->read_fail = 1;
306fa1
+				}
306fa1
 			}
306fa1
 			master->depth--;
306fa1
 			master->recurse = 0;
306fa1
@@ -712,6 +716,8 @@ int lookup_read_map(struct autofs_point
306fa1
 
306fa1
 	f = open_fopen_r(ctxt->mapname);
306fa1
 	if (!f) {
306fa1
+		if (errno == ENOENT)
306fa1
+			return NSS_STATUS_NOTFOUND;
306fa1
 		error(ap->logopt,
306fa1
 		      MODPREFIX "could not open map file %s", ctxt->mapname);
306fa1
 		return NSS_STATUS_UNAVAIL;