|
|
516ab0 |
autofs-5.1.1 - fix return handling of do_reconnect() in ldap module
|
|
|
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 |
Finally make do_reconnect() return a status instead of an LDAP handle
|
|
|
516ab0 |
and pass back the LDAP handle via a function parameter.
|
|
|
516ab0 |
|
|
|
516ab0 |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
516ab0 |
---
|
|
|
516ab0 |
CHANGELOG | 1
|
|
|
516ab0 |
modules/lookup_ldap.c | 78 ++++++++++++++++++++++++++++----------------------
|
|
|
516ab0 |
2 files changed, 46 insertions(+), 33 deletions(-)
|
|
|
516ab0 |
|
|
|
516ab0 |
--- autofs-5.0.7.orig/CHANGELOG
|
|
|
516ab0 |
+++ autofs-5.0.7/CHANGELOG
|
|
|
516ab0 |
@@ -177,6 +177,7 @@
|
|
|
516ab0 |
- make connect_to_server() return a status.
|
|
|
516ab0 |
- make find_dc_server() return a status.
|
|
|
516ab0 |
- make find_server() return a status.
|
|
|
516ab0 |
+- fix return handling of do_reconnect() in ldap module.
|
|
|
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 |
@@ -961,31 +961,33 @@ static int find_server(unsigned logopt,
|
|
|
516ab0 |
return ret;
|
|
|
516ab0 |
}
|
|
|
516ab0 |
|
|
|
516ab0 |
-static LDAP *do_reconnect(unsigned logopt, struct lookup_context *ctxt)
|
|
|
516ab0 |
+static int do_reconnect(unsigned logopt,
|
|
|
516ab0 |
+ LDAP **ldap, struct lookup_context *ctxt)
|
|
|
516ab0 |
{
|
|
|
516ab0 |
- LDAP *ldap = NULL;
|
|
|
516ab0 |
- int ret;
|
|
|
516ab0 |
+ int ret = NSS_STATUS_UNAVAIL;
|
|
|
516ab0 |
+ int dcrv = NSS_STATUS_SUCCESS;
|
|
|
516ab0 |
+ int rv = NSS_STATUS_SUCCESS;
|
|
|
516ab0 |
|
|
|
516ab0 |
if (ctxt->server || !ctxt->uris) {
|
|
|
516ab0 |
- ret = do_connect(logopt, &ldap, ctxt->server, ctxt);
|
|
|
516ab0 |
+ ret = do_connect(logopt, ldap, ctxt->server, ctxt);
|
|
|
516ab0 |
#ifdef WITH_SASL
|
|
|
516ab0 |
/* Dispose of the sasl authentication connection and try again. */
|
|
|
516ab0 |
- if (ret != NSS_STATUS_SUCCESS &&
|
|
|
516ab0 |
- ctxt->auth_required & LDAP_NEED_AUTH) {
|
|
|
516ab0 |
+ if (ctxt->auth_required & LDAP_NEED_AUTH &&
|
|
|
516ab0 |
+ ret != NSS_STATUS_SUCCESS && ret != NSS_STATUS_NOTFOUND) {
|
|
|
516ab0 |
ldapinit_mutex_lock();
|
|
|
516ab0 |
autofs_sasl_dispose(ctxt);
|
|
|
516ab0 |
ldapinit_mutex_unlock();
|
|
|
516ab0 |
- ret = connect_to_server(logopt, &ldap,
|
|
|
516ab0 |
+ ret = connect_to_server(logopt, ldap,
|
|
|
516ab0 |
ctxt->server, ctxt);
|
|
|
516ab0 |
}
|
|
|
516ab0 |
#endif
|
|
|
516ab0 |
- return ldap;
|
|
|
516ab0 |
+ return ret;
|
|
|
516ab0 |
}
|
|
|
516ab0 |
|
|
|
516ab0 |
if (ctxt->dclist) {
|
|
|
516ab0 |
- ret = find_dc_server(logopt, &ldap, ctxt->dclist->uri, ctxt);
|
|
|
516ab0 |
- if (ret == NSS_STATUS_SUCCESS)
|
|
|
516ab0 |
- return ldap;
|
|
|
516ab0 |
+ dcrv = find_dc_server(logopt, ldap, ctxt->dclist->uri, ctxt);
|
|
|
516ab0 |
+ if (dcrv == NSS_STATUS_SUCCESS)
|
|
|
516ab0 |
+ return dcrv;
|
|
|
516ab0 |
}
|
|
|
516ab0 |
|
|
|
516ab0 |
uris_mutex_lock(ctxt);
|
|
|
516ab0 |
@@ -1004,22 +1006,22 @@ static LDAP *do_reconnect(unsigned logop
|
|
|
516ab0 |
if (!ctxt->uri)
|
|
|
516ab0 |
goto find_server;
|
|
|
516ab0 |
|
|
|
516ab0 |
- ret = do_connect(logopt, &ldap, ctxt->uri->uri, ctxt);
|
|
|
516ab0 |
+ rv = do_connect(logopt, ldap, ctxt->uri->uri, ctxt);
|
|
|
516ab0 |
#ifdef WITH_SASL
|
|
|
516ab0 |
/*
|
|
|
516ab0 |
* Dispose of the sasl authentication connection and try the
|
|
|
516ab0 |
* current server again before trying other servers in the list.
|
|
|
516ab0 |
*/
|
|
|
516ab0 |
- if (ret != NSS_STATUS_SUCCESS &&
|
|
|
516ab0 |
- ctxt->auth_required & LDAP_NEED_AUTH) {
|
|
|
516ab0 |
+ if (ctxt->auth_required & LDAP_NEED_AUTH &&
|
|
|
516ab0 |
+ rv != NSS_STATUS_SUCCESS && rv != NSS_STATUS_NOTFOUND) {
|
|
|
516ab0 |
ldapinit_mutex_lock();
|
|
|
516ab0 |
autofs_sasl_dispose(ctxt);
|
|
|
516ab0 |
ldapinit_mutex_unlock();
|
|
|
516ab0 |
- ret = connect_to_server(logopt, &ldap, ctxt->uri->uri, ctxt);
|
|
|
516ab0 |
+ rv = connect_to_server(logopt, ldap, ctxt->uri->uri, ctxt);
|
|
|
516ab0 |
}
|
|
|
516ab0 |
#endif
|
|
|
516ab0 |
- if (ldap)
|
|
|
516ab0 |
- return ldap;
|
|
|
516ab0 |
+ if (rv == NSS_STATUS_SUCCESS)
|
|
|
516ab0 |
+ return rv;
|
|
|
516ab0 |
|
|
|
516ab0 |
/* Failed to connect, try to find a new server */
|
|
|
516ab0 |
|
|
|
516ab0 |
@@ -1031,11 +1033,16 @@ find_server:
|
|
|
516ab0 |
#endif
|
|
|
516ab0 |
|
|
|
516ab0 |
/* Current server failed, try the rest or dc connection */
|
|
|
516ab0 |
- ret = find_server(logopt, &ldap, ctxt);
|
|
|
516ab0 |
- if (ret != NSS_STATUS_SUCCESS)
|
|
|
516ab0 |
+ ret = find_server(logopt, ldap, ctxt);
|
|
|
516ab0 |
+ if (ret != NSS_STATUS_SUCCESS) {
|
|
|
516ab0 |
+ if (ret == NSS_STATUS_NOTFOUND ||
|
|
|
516ab0 |
+ dcrv == NSS_STATUS_NOTFOUND ||
|
|
|
516ab0 |
+ rv == NSS_STATUS_NOTFOUND)
|
|
|
516ab0 |
+ ret = NSS_STATUS_NOTFOUND;
|
|
|
516ab0 |
error(logopt, MODPREFIX "failed to find available server");
|
|
|
516ab0 |
+ }
|
|
|
516ab0 |
|
|
|
516ab0 |
- return ldap;
|
|
|
516ab0 |
+ return ret;
|
|
|
516ab0 |
}
|
|
|
516ab0 |
|
|
|
516ab0 |
int get_property(unsigned logopt, xmlNodePtr node, const char *prop, char **value)
|
|
|
516ab0 |
@@ -1841,12 +1848,12 @@ int lookup_read_master(struct master *ma
|
|
|
516ab0 |
char **values = NULL;
|
|
|
516ab0 |
char *attrs[3];
|
|
|
516ab0 |
int scope = LDAP_SCOPE_SUBTREE;
|
|
|
516ab0 |
- LDAP *ldap;
|
|
|
516ab0 |
+ LDAP *ldap = NULL;
|
|
|
516ab0 |
|
|
|
516ab0 |
/* Initialize the LDAP context. */
|
|
|
516ab0 |
- ldap = do_reconnect(logopt, ctxt);
|
|
|
516ab0 |
- if (!ldap)
|
|
|
516ab0 |
- return NSS_STATUS_UNAVAIL;
|
|
|
516ab0 |
+ rv = do_reconnect(logopt, &ldap, ctxt);
|
|
|
516ab0 |
+ if (rv)
|
|
|
516ab0 |
+ return rv;
|
|
|
516ab0 |
|
|
|
516ab0 |
class = ctxt->schema->entry_class;
|
|
|
516ab0 |
entry = ctxt->schema->entry_attr;
|
|
|
516ab0 |
@@ -2754,9 +2761,10 @@ static int read_one_map(struct autofs_po
|
|
|
516ab0 |
sp.age = age;
|
|
|
516ab0 |
|
|
|
516ab0 |
/* Initialize the LDAP context. */
|
|
|
516ab0 |
- sp.ldap = do_reconnect(ap->logopt, ctxt);
|
|
|
516ab0 |
- if (!sp.ldap)
|
|
|
516ab0 |
- return NSS_STATUS_UNAVAIL;
|
|
|
516ab0 |
+ sp.ldap = NULL;
|
|
|
516ab0 |
+ rv = do_reconnect(ap->logopt, &sp.ldap, ctxt);
|
|
|
516ab0 |
+ if (rv)
|
|
|
516ab0 |
+ return rv;
|
|
|
516ab0 |
|
|
|
516ab0 |
class = ctxt->schema->entry_class;
|
|
|
516ab0 |
entry = ctxt->schema->entry_attr;
|
|
|
516ab0 |
@@ -2908,7 +2916,7 @@ static int lookup_one(struct autofs_poin
|
|
|
516ab0 |
struct berval **bvValues;
|
|
|
516ab0 |
char *attrs[3];
|
|
|
516ab0 |
int scope = LDAP_SCOPE_SUBTREE;
|
|
|
516ab0 |
- LDAP *ldap;
|
|
|
516ab0 |
+ LDAP *ldap = NULL;
|
|
|
516ab0 |
struct mapent *we;
|
|
|
516ab0 |
unsigned int wild = 0;
|
|
|
516ab0 |
int ret = CHE_MISSING;
|
|
|
516ab0 |
@@ -2921,9 +2929,11 @@ static int lookup_one(struct autofs_poin
|
|
|
516ab0 |
}
|
|
|
516ab0 |
|
|
|
516ab0 |
/* Initialize the LDAP context. */
|
|
|
516ab0 |
- ldap = do_reconnect(ap->logopt, ctxt);
|
|
|
516ab0 |
- if (!ldap)
|
|
|
516ab0 |
+ rv = do_reconnect(ap->logopt, &ldap, ctxt);
|
|
|
516ab0 |
+ if (rv == NSS_STATUS_UNAVAIL)
|
|
|
516ab0 |
return CHE_UNAVAIL;
|
|
|
516ab0 |
+ if (rv == NSS_STATUS_NOTFOUND)
|
|
|
516ab0 |
+ return ret;
|
|
|
516ab0 |
|
|
|
516ab0 |
class = ctxt->schema->entry_class;
|
|
|
516ab0 |
entry = ctxt->schema->entry_attr;
|
|
|
516ab0 |
@@ -3252,7 +3262,7 @@ static int lookup_one_amd(struct autofs_
|
|
|
516ab0 |
struct lookup_context *ctxt)
|
|
|
516ab0 |
{
|
|
|
516ab0 |
struct mapent_cache *mc = source->mc;
|
|
|
516ab0 |
- LDAP *ldap;
|
|
|
516ab0 |
+ LDAP *ldap = NULL;
|
|
|
516ab0 |
LDAPMessage *result = NULL, *e;
|
|
|
516ab0 |
char *query;
|
|
|
516ab0 |
int scope = LDAP_SCOPE_SUBTREE;
|
|
|
516ab0 |
@@ -3271,9 +3281,11 @@ static int lookup_one_amd(struct autofs_
|
|
|
516ab0 |
}
|
|
|
516ab0 |
|
|
|
516ab0 |
/* Initialize the LDAP context. */
|
|
|
516ab0 |
- ldap = do_reconnect(ap->logopt, ctxt);
|
|
|
516ab0 |
- if (!ldap)
|
|
|
516ab0 |
+ rv = do_reconnect(ap->logopt, &ldap, ctxt);
|
|
|
516ab0 |
+ if (rv == NSS_STATUS_UNAVAIL)
|
|
|
516ab0 |
return CHE_UNAVAIL;
|
|
|
516ab0 |
+ if (rv == NSS_STATUS_NOTFOUND)
|
|
|
516ab0 |
+ return ret;
|
|
|
516ab0 |
|
|
|
516ab0 |
map = ctxt->schema->map_attr;
|
|
|
516ab0 |
class = ctxt->schema->entry_class;
|