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