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