File autofs-5.0.6-properly-handle-errors-in-lookup_nss_mount.patch of Package autofs.6209

From 92766c97cecf49f4a4914a2f2d905f2daa9cdc41 Mon Sep 17 00:00:00 2001
From: Jeff Mahoney <>
Date: Tue, 3 May 2016 22:29:35 -0400
Subject: [PATCH 2/2] autofs: properly handle errors in lookup_nss_mount
References: bsc#968918
Patch-mainline: 5.1.2
Git-commit: b1b271204a291b80318d4232530a82a79321d751

The 'result' variable is initialized to 0 and inconsistently
set in the main while loop.  If the map is expired, the strdup("ldap")
fails, or we end up bailing on an sss source with an amd map, and we're
processing the only map in the list or check_nss_result indicates that
we should continue even when we have NSS_STATUS_SUCCESS, we'll return
success when a failure has occured.

Without this change, the end result is still a failure for the user.
The caller attempting to traverse the map will eventually receive
ELOOP once the kernel has reached its internal automount/link follow
limit.  We will have just wasted a bunch of time in the interim.  This
behavior was observed on a system that was affected by the missing
map->age update fixed in the previous patch.
 daemon/lookup.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/daemon/lookup.c b/daemon/lookup.c
index 0129f75..173f53e 100644
--- a/daemon/lookup.c
+++ b/daemon/lookup.c
@@ -1073,7 +1073,7 @@ int lookup_nss_mount(struct autofs_point *ap, struct map_source *source, const c
 	struct nss_source *this;
 	struct map_source *map;
 	enum nsswitch_status status;
-	int result = 0;
+	int result = NSS_STATUS_UNKNOWN;
 	 * For each map source (ie. each entry for the mount
@@ -1092,6 +1092,7 @@ int lookup_nss_mount(struct autofs_point *ap, struct map_source *source, const c
 		 * the map entry was last updated.
 		if (entry->age > map->age) {
+			status = NSS_STATUS_UNAVAIL;
 			map = map->next;
@@ -1113,6 +1114,7 @@ int lookup_nss_mount(struct autofs_point *ap, struct map_source *source, const c
 				char *tmp = strdup("ldap");
 				if (!tmp) {
 					map = map->next;
+					status = NSS_STATUS_TRYAGAIN;
 				map->type = tmp;
openSUSE Build Service is sponsored by