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

306fa1
autofs-5.1.1 - make connect_to_server() return a status
306fa1
306fa1
From: Ian Kent <raven@themaw.net>
306fa1
306fa1
In the ldap lookup module the do_reconnect() call doesn't distinguish
306fa1
between no entry found and service unavailable.
306fa1
306fa1
If service unavailable gets returned from a master map read it results
306fa1
in autofs not updating the mounts. A notfound return doesn't because it
306fa1
indicates the map doesn't exist so updating the mounts isn't a problem
306fa1
as it can be when the source is unavailable.
306fa1
306fa1
Next step in the update of do_reconnect() is to make connect_to_server()
306fa1
return a status instead of an LDAP handle and pass back the LDAP handle
306fa1
via a function parameter.
306fa1
306fa1
Signed-off-by: Ian Kent <raven@themaw.net>
306fa1
---
306fa1
 CHANGELOG             |    1 +
306fa1
 modules/lookup_ldap.c |   25 ++++++++++++++-----------
306fa1
 2 files changed, 15 insertions(+), 11 deletions(-)
306fa1
306fa1
--- autofs-5.0.7.orig/CHANGELOG
306fa1
+++ autofs-5.0.7/CHANGELOG
306fa1
@@ -174,6 +174,7 @@
306fa1
 - fix return handling in sss lookup module.
306fa1
 - move query dn calculation from do_bind() to do_connect().
306fa1
 - make do_connect() return a status.
306fa1
+- make connect_to_server() return a status.
306fa1
 
306fa1
 25/07/2012 autofs-5.0.7
306fa1
 =======================
306fa1
--- autofs-5.0.7.orig/modules/lookup_ldap.c
306fa1
+++ autofs-5.0.7/modules/lookup_ldap.c
306fa1
@@ -824,20 +824,19 @@ next:
306fa1
 	return timestamp;
306fa1
 }
306fa1
 
306fa1
-static LDAP *connect_to_server(unsigned logopt, const char *uri, struct lookup_context *ctxt)
306fa1
+static int connect_to_server(unsigned logopt, LDAP **ldap,
306fa1
+			     const char *uri, struct lookup_context *ctxt)
306fa1
 {
306fa1
-	LDAP *ldap;
306fa1
 	int ret;
306fa1
 
306fa1
-	ret = do_connect(logopt, &ldap, uri, ctxt);
306fa1
+	ret = do_connect(logopt, ldap, uri, ctxt);
306fa1
 	if (ret != NSS_STATUS_SUCCESS) {
306fa1
 		warn(logopt,
306fa1
 		     MODPREFIX "couldn't connect to server %s",
306fa1
 		     uri ? uri : "default");
306fa1
-		return NULL;
306fa1
 	}
306fa1
 
306fa1
-	return ldap;
306fa1
+	return ret;
306fa1
 }
306fa1
 
306fa1
 static LDAP *find_dc_server(unsigned logopt, const char *uri, struct lookup_context *ctxt)
306fa1
@@ -852,9 +851,11 @@ static LDAP *find_dc_server(unsigned log
306fa1
 	tok = strtok_r(str, " ", &ptr);
306fa1
 	while (tok) {
306fa1
 		const char *this = (const char *) tok;
306fa1
+		int ret;
306fa1
+
306fa1
 		debug(logopt, "trying server uri %s", this);
306fa1
-		ldap = connect_to_server(logopt, this, ctxt);
306fa1
-		if (ldap) {
306fa1
+		ret = connect_to_server(logopt, &ldap, this, ctxt);
306fa1
+		if (ret == NSS_STATUS_SUCCESS) {
306fa1
 			info(logopt, "connected to uri %s", this);
306fa1
 			free(str);
306fa1
 			return ldap;
306fa1
@@ -874,6 +875,7 @@ static LDAP *find_server(unsigned logopt
306fa1
 	struct list_head *p, *first;
306fa1
 	struct dclist *dclist;
306fa1
 	char *uri = NULL;
306fa1
+	int ret;
306fa1
 
306fa1
 	uris_mutex_lock(ctxt);
306fa1
 	dclist = ctxt->dclist;
306fa1
@@ -896,8 +898,8 @@ static LDAP *find_server(unsigned logopt
306fa1
 		if (!strstr(this->uri, ":///")) {
306fa1
 			uri = strdup(this->uri);
306fa1
 			debug(logopt, "trying server uri %s", uri);
306fa1
-			ldap = connect_to_server(logopt, uri, ctxt);
306fa1
-			if (ldap) {
306fa1
+			ret = connect_to_server(logopt, &ldap, uri, ctxt);
306fa1
+			if (ret == NSS_STATUS_SUCCESS) {
306fa1
 				info(logopt, "connected to uri %s", uri);
306fa1
 				free(uri);
306fa1
 				break;
306fa1
@@ -962,7 +964,8 @@ static LDAP *do_reconnect(unsigned logop
306fa1
 			ldapinit_mutex_lock();
306fa1
 			autofs_sasl_dispose(ctxt);
306fa1
 			ldapinit_mutex_unlock();
306fa1
-			ldap = connect_to_server(logopt, ctxt->server, ctxt);
306fa1
+			ret = connect_to_server(logopt, &ldap,
306fa1
+						ctxt->server, ctxt);
306fa1
 		}
306fa1
 #endif
306fa1
 		return ldap;
306fa1
@@ -1001,7 +1004,7 @@ static LDAP *do_reconnect(unsigned logop
306fa1
 		ldapinit_mutex_lock();
306fa1
 		autofs_sasl_dispose(ctxt);
306fa1
 		ldapinit_mutex_unlock();
306fa1
-		ldap = connect_to_server(logopt, ctxt->uri->uri, ctxt);
306fa1
+		ret = connect_to_server(logopt, &ldap, ctxt->uri->uri, ctxt);
306fa1
 	}
306fa1
 #endif
306fa1
 	if (ldap)