|
|
306fa1 |
autofs-5.1.1 - make find_dc_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_dc_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 | 27 +++++++++++++++------------
|
|
|
306fa1 |
2 files changed, 16 insertions(+), 12 deletions(-)
|
|
|
306fa1 |
|
|
|
306fa1 |
--- autofs-5.0.7.orig/CHANGELOG
|
|
|
306fa1 |
+++ autofs-5.0.7/CHANGELOG
|
|
|
306fa1 |
@@ -175,6 +175,7 @@
|
|
|
306fa1 |
- move query dn calculation from do_bind() to do_connect().
|
|
|
306fa1 |
- make do_connect() return a status.
|
|
|
306fa1 |
- make connect_to_server() return a status.
|
|
|
306fa1 |
+- make find_dc_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 |
@@ -839,33 +839,36 @@ static int connect_to_server(unsigned lo
|
|
|
306fa1 |
return ret;
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|
|
|
306fa1 |
-static LDAP *find_dc_server(unsigned logopt, const char *uri, struct lookup_context *ctxt)
|
|
|
306fa1 |
+static int find_dc_server(unsigned logopt, LDAP **ldap,
|
|
|
306fa1 |
+ const char *uri, struct lookup_context *ctxt)
|
|
|
306fa1 |
{
|
|
|
306fa1 |
char *str, *tok, *ptr = NULL;
|
|
|
306fa1 |
- LDAP *ldap = NULL;
|
|
|
306fa1 |
+ int ret = NSS_STATUS_UNAVAIL;
|
|
|
306fa1 |
|
|
|
306fa1 |
str = strdup(uri);
|
|
|
306fa1 |
if (!str)
|
|
|
306fa1 |
- return NULL;
|
|
|
306fa1 |
+ return ret;
|
|
|
306fa1 |
|
|
|
306fa1 |
tok = strtok_r(str, " ", &ptr);
|
|
|
306fa1 |
while (tok) {
|
|
|
306fa1 |
const char *this = (const char *) tok;
|
|
|
306fa1 |
- int ret;
|
|
|
306fa1 |
+ int rv;
|
|
|
306fa1 |
|
|
|
306fa1 |
debug(logopt, "trying server uri %s", this);
|
|
|
306fa1 |
- ret = connect_to_server(logopt, &ldap, this, ctxt);
|
|
|
306fa1 |
- if (ret == NSS_STATUS_SUCCESS) {
|
|
|
306fa1 |
+ rv = connect_to_server(logopt, ldap, this, ctxt);
|
|
|
306fa1 |
+ if (rv == NSS_STATUS_SUCCESS) {
|
|
|
306fa1 |
info(logopt, "connected to uri %s", this);
|
|
|
306fa1 |
free(str);
|
|
|
306fa1 |
- return ldap;
|
|
|
306fa1 |
+ return rv;
|
|
|
306fa1 |
}
|
|
|
306fa1 |
+ if (rv == NSS_STATUS_NOTFOUND)
|
|
|
306fa1 |
+ ret = NSS_STATUS_NOTFOUND;
|
|
|
306fa1 |
tok = strtok_r(NULL, " ", &ptr);
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|
|
|
306fa1 |
free(str);
|
|
|
306fa1 |
|
|
|
306fa1 |
- return NULL;
|
|
|
306fa1 |
+ return ret;
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|
|
|
306fa1 |
static LDAP *find_server(unsigned logopt, struct lookup_context *ctxt)
|
|
|
306fa1 |
@@ -917,8 +920,8 @@ static LDAP *find_server(unsigned logopt
|
|
|
306fa1 |
dclist = tmp;
|
|
|
306fa1 |
uri = strdup(dclist->uri);
|
|
|
306fa1 |
}
|
|
|
306fa1 |
- ldap = find_dc_server(logopt, uri, ctxt);
|
|
|
306fa1 |
- if (ldap) {
|
|
|
306fa1 |
+ ret = find_dc_server(logopt, &ldap, uri, ctxt);
|
|
|
306fa1 |
+ if (ret == NSS_STATUS_SUCCESS) {
|
|
|
306fa1 |
free(uri);
|
|
|
306fa1 |
break;
|
|
|
306fa1 |
}
|
|
|
306fa1 |
@@ -972,8 +975,8 @@ static LDAP *do_reconnect(unsigned logop
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|
|
|
306fa1 |
if (ctxt->dclist) {
|
|
|
306fa1 |
- ldap = find_dc_server(logopt, ctxt->dclist->uri, ctxt);
|
|
|
306fa1 |
- if (ldap)
|
|
|
306fa1 |
+ ret = find_dc_server(logopt, &ldap, ctxt->dclist->uri, ctxt);
|
|
|
306fa1 |
+ if (ret == NSS_STATUS_SUCCESS)
|
|
|
306fa1 |
return ldap;
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|