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

304803
autofs-5.1.1 - make connect_to_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 connect_to_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 |   25 ++++++++++++++-----------
304803
 2 files changed, 15 insertions(+), 11 deletions(-)
304803
304803
--- autofs-5.0.7.orig/CHANGELOG
304803
+++ autofs-5.0.7/CHANGELOG
304803
@@ -174,6 +174,7 @@
304803
 - fix return handling in sss lookup module.
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
 
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
@@ -824,20 +824,19 @@ next:
304803
 	return timestamp;
304803
 }
304803
 
304803
-static LDAP *connect_to_server(unsigned logopt, const char *uri, struct lookup_context *ctxt)
304803
+static int connect_to_server(unsigned logopt, LDAP **ldap,
304803
+			     const char *uri, struct lookup_context *ctxt)
304803
 {
304803
-	LDAP *ldap;
304803
 	int ret;
304803
 
304803
-	ret = do_connect(logopt, &ldap, uri, ctxt);
304803
+	ret = do_connect(logopt, ldap, uri, ctxt);
304803
 	if (ret != NSS_STATUS_SUCCESS) {
304803
 		warn(logopt,
304803
 		     MODPREFIX "couldn't connect to server %s",
304803
 		     uri ? uri : "default");
304803
-		return NULL;
304803
 	}
304803
 
304803
-	return ldap;
304803
+	return ret;
304803
 }
304803
 
304803
 static LDAP *find_dc_server(unsigned logopt, const char *uri, struct lookup_context *ctxt)
304803
@@ -852,9 +851,11 @@ static LDAP *find_dc_server(unsigned log
304803
 	tok = strtok_r(str, " ", &ptr);
304803
 	while (tok) {
304803
 		const char *this = (const char *) tok;
304803
+		int ret;
304803
+
304803
 		debug(logopt, "trying server uri %s", this);
304803
-		ldap = connect_to_server(logopt, this, ctxt);
304803
-		if (ldap) {
304803
+		ret = connect_to_server(logopt, &ldap, this, ctxt);
304803
+		if (ret == NSS_STATUS_SUCCESS) {
304803
 			info(logopt, "connected to uri %s", this);
304803
 			free(str);
304803
 			return ldap;
304803
@@ -874,6 +875,7 @@ static LDAP *find_server(unsigned logopt
304803
 	struct list_head *p, *first;
304803
 	struct dclist *dclist;
304803
 	char *uri = NULL;
304803
+	int ret;
304803
 
304803
 	uris_mutex_lock(ctxt);
304803
 	dclist = ctxt->dclist;
304803
@@ -896,8 +898,8 @@ static LDAP *find_server(unsigned logopt
304803
 		if (!strstr(this->uri, ":///")) {
304803
 			uri = strdup(this->uri);
304803
 			debug(logopt, "trying server uri %s", uri);
304803
-			ldap = connect_to_server(logopt, uri, ctxt);
304803
-			if (ldap) {
304803
+			ret = connect_to_server(logopt, &ldap, uri, ctxt);
304803
+			if (ret == NSS_STATUS_SUCCESS) {
304803
 				info(logopt, "connected to uri %s", uri);
304803
 				free(uri);
304803
 				break;
304803
@@ -962,7 +964,8 @@ static LDAP *do_reconnect(unsigned logop
304803
 			ldapinit_mutex_lock();
304803
 			autofs_sasl_dispose(ctxt);
304803
 			ldapinit_mutex_unlock();
304803
-			ldap = connect_to_server(logopt, ctxt->server, ctxt);
304803
+			ret = connect_to_server(logopt, &ldap,
304803
+						ctxt->server, ctxt);
304803
 		}
304803
 #endif
304803
 		return ldap;
304803
@@ -1001,7 +1004,7 @@ static LDAP *do_reconnect(unsigned logop
304803
 		ldapinit_mutex_lock();
304803
 		autofs_sasl_dispose(ctxt);
304803
 		ldapinit_mutex_unlock();
304803
-		ldap = connect_to_server(logopt, ctxt->uri->uri, ctxt);
304803
+		ret = connect_to_server(logopt, &ldap, ctxt->uri->uri, ctxt);
304803
 	}
304803
 #endif
304803
 	if (ldap)