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

4d476f
autofs-5.1.1 - make find_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_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 |   30 +++++++++++++++++++-----------
4d476f
 2 files changed, 20 insertions(+), 11 deletions(-)
4d476f
4d476f
--- autofs-5.0.7.orig/CHANGELOG
4d476f
+++ autofs-5.0.7/CHANGELOG
4d476f
@@ -176,6 +176,7 @@
4d476f
 - make do_connect() return a status.
4d476f
 - make connect_to_server() return a status.
4d476f
 - make find_dc_server() return a status.
4d476f
+- make find_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
@@ -871,14 +871,14 @@ static int find_dc_server(unsigned logop
4d476f
 	return ret;
4d476f
 }
4d476f
 
4d476f
-static LDAP *find_server(unsigned logopt, struct lookup_context *ctxt)
4d476f
+static int find_server(unsigned logopt,
4d476f
+		       LDAP **ldap, struct lookup_context *ctxt)
4d476f
 {
4d476f
-	LDAP *ldap = NULL;
4d476f
-	struct ldap_uri *this;
4d476f
+	struct ldap_uri *this = NULL;
4d476f
 	struct list_head *p, *first;
4d476f
 	struct dclist *dclist;
4d476f
 	char *uri = NULL;
4d476f
-	int ret;
4d476f
+	int ret = NSS_STATUS_UNAVAIL;
4d476f
 
4d476f
 	uris_mutex_lock(ctxt);
4d476f
 	dclist = ctxt->dclist;
4d476f
@@ -892,6 +892,8 @@ static LDAP *find_server(unsigned logopt
4d476f
 	/* Try each uri, save point in server list upon success */
4d476f
 	p = first->next;
4d476f
 	while(p != first) {
4d476f
+		int rv;
4d476f
+
4d476f
 		/* Skip list head */
4d476f
 		if (p == ctxt->uris) {
4d476f
 			p = p->next;
4d476f
@@ -901,12 +903,15 @@ static LDAP *find_server(unsigned logopt
4d476f
 		if (!strstr(this->uri, ":///")) {
4d476f
 			uri = strdup(this->uri);
4d476f
 			debug(logopt, "trying server uri %s", uri);
4d476f
-			ret = connect_to_server(logopt, &ldap, uri, ctxt);
4d476f
-			if (ret == NSS_STATUS_SUCCESS) {
4d476f
+			rv = connect_to_server(logopt, ldap, uri, ctxt);
4d476f
+			if (rv == NSS_STATUS_SUCCESS) {
4d476f
+				ret = NSS_STATUS_SUCCESS;
4d476f
 				info(logopt, "connected to uri %s", uri);
4d476f
 				free(uri);
4d476f
 				break;
4d476f
 			}
4d476f
+			if (rv == NSS_STATUS_NOTFOUND)
4d476f
+				ret = NSS_STATUS_NOTFOUND;
4d476f
 		} else {
4d476f
 			if (dclist)
4d476f
 				uri = strdup(dclist->uri);
4d476f
@@ -920,11 +925,14 @@ static LDAP *find_server(unsigned logopt
4d476f
 				dclist = tmp;
4d476f
 				uri = strdup(dclist->uri);
4d476f
 			}
4d476f
-			ret = find_dc_server(logopt, &ldap, uri, ctxt);
4d476f
-			if (ret == NSS_STATUS_SUCCESS) {
4d476f
+			rv = find_dc_server(logopt, ldap, uri, ctxt);
4d476f
+			if (rv == NSS_STATUS_SUCCESS) {
4d476f
+				ret = NSS_STATUS_SUCCESS;
4d476f
 				free(uri);
4d476f
 				break;
4d476f
 			}
4d476f
+			if (rv == NSS_STATUS_NOTFOUND)
4d476f
+				ret = NSS_STATUS_NOTFOUND;
4d476f
 		}
4d476f
 		free(uri);
4d476f
 		uri = NULL;
4d476f
@@ -950,7 +958,7 @@ static LDAP *find_server(unsigned logopt
4d476f
 	}
4d476f
 	uris_mutex_unlock(ctxt);
4d476f
 
4d476f
-	return ldap;
4d476f
+	return ret;
4d476f
 }
4d476f
 
4d476f
 static LDAP *do_reconnect(unsigned logopt, struct lookup_context *ctxt)
4d476f
@@ -1023,8 +1031,8 @@ find_server:
4d476f
 #endif
4d476f
 
4d476f
 	/* Current server failed, try the rest or dc connection */
4d476f
-	ldap = find_server(logopt, ctxt);
4d476f
-	if (!ldap)
4d476f
+	ret = find_server(logopt, &ldap, ctxt);
4d476f
+	if (ret != NSS_STATUS_SUCCESS)
4d476f
 		error(logopt, MODPREFIX "failed to find available server");
4d476f
 
4d476f
 	return ldap;