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

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