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

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