Blame SOURCES/autofs-5.1.1-make-find_dc_server-return-a-status.patch

304803
autofs-5.1.1 - make find_dc_server() return a status
304803
304803
From: Ian Kent <raven@themaw.net>
304803
304803
In the ldap lookup module the do_reconnect() call doesn't distinguish
304803
between no entry found and service unavailable.
304803
304803
If service unavailable gets returned from a master map read it results
304803
in autofs not updating the mounts. A notfound return doesn't because it
304803
indicates the map doesn't exist so updating the mounts isn't a problem
304803
as it can be when the source is unavailable.
304803
304803
Next step in the update of do_reconnect() is to make find_dc_server()
304803
return a status instead of an LDAP handle and pass back the LDAP handle
304803
via a function parameter.
304803
304803
Signed-off-by: Ian Kent <raven@themaw.net>
304803
---
304803
 CHANGELOG             |    1 +
304803
 modules/lookup_ldap.c |   27 +++++++++++++++------------
304803
 2 files changed, 16 insertions(+), 12 deletions(-)
304803
304803
--- autofs-5.0.7.orig/CHANGELOG
304803
+++ autofs-5.0.7/CHANGELOG
304803
@@ -175,6 +175,7 @@
304803
 - move query dn calculation from do_bind() to do_connect().
304803
 - make do_connect() return a status.
304803
 - make connect_to_server() return a status.
304803
+- make find_dc_server() return a status.
304803
 
304803
 25/07/2012 autofs-5.0.7
304803
 =======================
304803
--- autofs-5.0.7.orig/modules/lookup_ldap.c
304803
+++ autofs-5.0.7/modules/lookup_ldap.c
304803
@@ -839,33 +839,36 @@ static int connect_to_server(unsigned lo
304803
 	return ret;
304803
 }
304803
 
304803
-static LDAP *find_dc_server(unsigned logopt, const char *uri, struct lookup_context *ctxt)
304803
+static int find_dc_server(unsigned logopt, LDAP **ldap,
304803
+			  const char *uri, struct lookup_context *ctxt)
304803
 {
304803
 	char *str, *tok, *ptr = NULL;
304803
-	LDAP *ldap = NULL;
304803
+	int ret = NSS_STATUS_UNAVAIL;
304803
 
304803
 	str = strdup(uri);
304803
 	if (!str)
304803
-		return NULL;
304803
+		return ret;
304803
 
304803
 	tok = strtok_r(str, " ", &ptr);
304803
 	while (tok) {
304803
 		const char *this = (const char *) tok;
304803
-		int ret;
304803
+		int rv;
304803
 
304803
 		debug(logopt, "trying server uri %s", this);
304803
-		ret = connect_to_server(logopt, &ldap, this, ctxt);
304803
-		if (ret == NSS_STATUS_SUCCESS) {
304803
+		rv = connect_to_server(logopt, ldap, this, ctxt);
304803
+		if (rv == NSS_STATUS_SUCCESS) {
304803
 			info(logopt, "connected to uri %s", this);
304803
 			free(str);
304803
-			return ldap;
304803
+			return rv;
304803
 		}
304803
+		if (rv == NSS_STATUS_NOTFOUND)
304803
+			ret = NSS_STATUS_NOTFOUND;
304803
 		tok = strtok_r(NULL, " ", &ptr);
304803
 	}
304803
 
304803
 	free(str);
304803
 
304803
-	return NULL;
304803
+	return ret;
304803
 }
304803
 
304803
 static LDAP *find_server(unsigned logopt, struct lookup_context *ctxt)
304803
@@ -917,8 +920,8 @@ static LDAP *find_server(unsigned logopt
304803
 				dclist = tmp;
304803
 				uri = strdup(dclist->uri);
304803
 			}
304803
-			ldap = find_dc_server(logopt, uri, ctxt);
304803
-			if (ldap) {
304803
+			ret = find_dc_server(logopt, &ldap, uri, ctxt);
304803
+			if (ret == NSS_STATUS_SUCCESS) {
304803
 				free(uri);
304803
 				break;
304803
 			}
304803
@@ -972,8 +975,8 @@ static LDAP *do_reconnect(unsigned logop
304803
 	}
304803
 
304803
 	if (ctxt->dclist) {
304803
-		ldap = find_dc_server(logopt, ctxt->dclist->uri, ctxt);
304803
-		if (ldap)
304803
+		ret = find_dc_server(logopt, &ldap, ctxt->dclist->uri, ctxt);
304803
+		if (ret == NSS_STATUS_SUCCESS)
304803
 			return ldap;
304803
 	}
304803