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

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