Blob Blame History Raw
autofs-5.1.2 - make lookup_nss_read_master() return nss status

From: Ian Kent <raven@themaw.net>

Currently lookup_nss_read_master() uses a boolean return but in order
for the master map retry read to function properly when trying to read
plus included maps it needs to return an NSS status instead.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG             |    1 +
 daemon/lookup.c       |   14 ++++++++++----
 modules/lookup_dir.c  |    2 +-
 modules/lookup_file.c |    2 +-
 4 files changed, 13 insertions(+), 6 deletions(-)

--- autofs-5.0.7.orig/CHANGELOG
+++ autofs-5.0.7/CHANGELOG
@@ -212,6 +212,7 @@
 - dont exit on master map read fail timeout.
 - set sane default master read wait timeout.
 - don't return until after master map retry read.
+- make lookup_nss_read_master() return nss status.
 
 25/07/2012 autofs-5.0.7
 =======================
--- autofs-5.0.7.orig/daemon/lookup.c
+++ autofs-5.0.7/daemon/lookup.c
@@ -175,7 +175,7 @@ int lookup_nss_read_master(struct master
 		if (result == NSS_STATUS_UNAVAIL)
 			master->read_fail = 1;
 
-		return !result;
+		return result;
 	} else {
 		char *name = master->name;
 		char *tmp;
@@ -225,7 +225,7 @@ int lookup_nss_read_master(struct master
 				if (result == NSS_STATUS_UNAVAIL)
 					master->read_fail = 1;
 
-				return !result;
+				return result;
 			}
 		}
 	}
@@ -237,7 +237,7 @@ int lookup_nss_read_master(struct master
 		if (!list_empty(&nsslist))
 			free_sources(&nsslist);
 		error(logopt, "can't to read name service switch config.");
-		return 0;
+		return NSS_STATUS_UNAVAIL;
 	}
 
 	/* First one gets it */
@@ -282,6 +282,12 @@ int lookup_nss_read_master(struct master
 			}
 		}
 
+		/* We've been instructed to move onto the next source */
+		if (result == NSS_STATUS_TRYAGAIN) {
+			result = NSS_STATUS_SUCCESS;
+			continue;
+		}
+
 		if (result == NSS_STATUS_UNKNOWN ||
 		    result == NSS_STATUS_NOTFOUND) {
 			debug(logopt, "no map - continuing to next source");
@@ -302,7 +308,7 @@ int lookup_nss_read_master(struct master
 	if (!list_empty(&nsslist))
 		free_sources(&nsslist);
 
-	return !result;
+	return result;
 }
 
 static int do_read_map(struct autofs_point *ap, struct map_source *map, time_t age)
--- autofs-5.0.7.orig/modules/lookup_dir.c
+++ autofs-5.0.7/modules/lookup_dir.c
@@ -154,7 +154,7 @@ static int include_file(struct master *m
 	master->depth++;
 	debug(logopt, MODPREFIX "include: %s", master->name);
 	status = lookup_nss_read_master(master, age);
-	if (!status) {
+	if (status != NSS_STATUS_SUCCESS) {
 		warn(logopt,
 		     MODPREFIX
 		     "failed to read included master map %s",
--- autofs-5.0.7.orig/modules/lookup_file.c
+++ autofs-5.0.7/modules/lookup_file.c
@@ -503,7 +503,7 @@ int lookup_read_master(struct master *ma
 				master->recurse = 1;
 			master->depth++;
 			status = lookup_nss_read_master(master, age);
-			if (!status) {
+			if (status != NSS_STATUS_SUCCESS) {
 				warn(logopt,
 				     MODPREFIX
 				     "failed to read included master map %s",