|
|
6bbd11 |
autofs-5.0.7 - fix compilation of lookup_ldap.c without sasl
|
|
|
6bbd11 |
|
|
|
6bbd11 |
From: Dustin Polke <DuPol@gmx.de>
|
|
|
6bbd11 |
|
|
|
6bbd11 |
See https://bugs.gentoo.org/show_bug.cgi?id=361899 for more info.
|
|
|
6bbd11 |
|
|
|
6bbd11 |
Edited by: Ian Kent <raven@themaw.net>
|
|
|
6bbd11 |
- fix parse_ldap_config() is needed by ldap but previously excluded.
|
|
|
6bbd11 |
- exclude other references to ctxt->extern_cert and ctxt->extern_key.
|
|
|
6bbd11 |
- prevent memory leak if present in config but not used.
|
|
|
6bbd11 |
- remove now unused set_env().
|
|
|
6bbd11 |
---
|
|
|
6bbd11 |
CHANGELOG | 1 +
|
|
|
6bbd11 |
include/lookup_ldap.h | 4 ++--
|
|
|
6bbd11 |
lib/Makefile | 4 ++++
|
|
|
6bbd11 |
modules/Makefile | 6 ++++--
|
|
|
6bbd11 |
modules/lookup_ldap.c | 18 +++++++++++++-----
|
|
|
6bbd11 |
5 files changed, 24 insertions(+), 9 deletions(-)
|
|
|
6bbd11 |
|
|
|
6bbd11 |
--- autofs-5.0.7.orig/CHANGELOG
|
|
|
6bbd11 |
+++ autofs-5.0.7/CHANGELOG
|
|
|
6bbd11 |
@@ -82,6 +82,7 @@
|
|
|
6bbd11 |
- add std vars to program map invocation.
|
|
|
6bbd11 |
- check for existing offset mount before mounting.
|
|
|
6bbd11 |
- fix cache readlock not taken on lookup.
|
|
|
6bbd11 |
+- fix compilation of lookup_ldap.c without sasl.
|
|
|
6bbd11 |
|
|
|
6bbd11 |
25/07/2012 autofs-5.0.7
|
|
|
6bbd11 |
=======================
|
|
|
6bbd11 |
--- autofs-5.0.7.orig/include/lookup_ldap.h
|
|
|
6bbd11 |
+++ autofs-5.0.7/include/lookup_ldap.h
|
|
|
6bbd11 |
@@ -11,6 +11,8 @@
|
|
|
6bbd11 |
#include <krb5.h>
|
|
|
6bbd11 |
#endif
|
|
|
6bbd11 |
|
|
|
6bbd11 |
+#include <libxml/tree.h>
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
#include "list.h"
|
|
|
6bbd11 |
#include "dclist.h"
|
|
|
6bbd11 |
|
|
|
6bbd11 |
@@ -92,7 +94,6 @@ struct lookup_context {
|
|
|
6bbd11 |
};
|
|
|
6bbd11 |
|
|
|
6bbd11 |
|
|
|
6bbd11 |
-#ifdef WITH_SASL
|
|
|
6bbd11 |
#define LDAP_AUTH_CONF_FILE "test"
|
|
|
6bbd11 |
|
|
|
6bbd11 |
#define LDAP_TLS_DONT_USE 0
|
|
|
6bbd11 |
@@ -104,7 +105,6 @@ struct lookup_context {
|
|
|
6bbd11 |
#define LDAP_AUTH_REQUIRED 0x0002
|
|
|
6bbd11 |
#define LDAP_AUTH_AUTODETECT 0x0004
|
|
|
6bbd11 |
#define LDAP_NEED_AUTH (LDAP_AUTH_REQUIRED|LDAP_AUTH_AUTODETECT)
|
|
|
6bbd11 |
-#endif
|
|
|
6bbd11 |
|
|
|
6bbd11 |
#define LDAP_AUTH_USESIMPLE 0x0008
|
|
|
6bbd11 |
|
|
|
6bbd11 |
--- autofs-5.0.7.orig/lib/Makefile
|
|
|
6bbd11 |
+++ autofs-5.0.7/lib/Makefile
|
|
|
6bbd11 |
@@ -24,6 +24,10 @@ CFLAGS += -I../include -fPIC -D_GNU_SOUR
|
|
|
6bbd11 |
CFLAGS += -DAUTOFS_MAP_DIR=\"$(autofsmapdir)\"
|
|
|
6bbd11 |
CFLAGS += -DAUTOFS_CONF_DIR=\"$(autofsconfdir)\"
|
|
|
6bbd11 |
|
|
|
6bbd11 |
+ifeq ($(LDAP), 1)
|
|
|
6bbd11 |
+ CFLAGS += $(XML_FLAGS) $(XML_LIBS)
|
|
|
6bbd11 |
+endif
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
.PHONY: all install clean
|
|
|
6bbd11 |
|
|
|
6bbd11 |
all: autofs.a
|
|
|
6bbd11 |
--- autofs-5.0.7.orig/modules/Makefile
|
|
|
6bbd11 |
+++ autofs-5.0.7/modules/Makefile
|
|
|
6bbd11 |
@@ -45,10 +45,12 @@ endif
|
|
|
6bbd11 |
ifeq ($(LDAP), 1)
|
|
|
6bbd11 |
SRCS += lookup_ldap.c
|
|
|
6bbd11 |
MODS += lookup_ldap.so
|
|
|
6bbd11 |
+ LDAP_FLAGS += $(XML_FLAGS) -DLDAP_THREAD_SAFE
|
|
|
6bbd11 |
+ LIBLDAP += $(XML_LIBS)
|
|
|
6bbd11 |
ifeq ($(SASL), 1)
|
|
|
6bbd11 |
SASL_OBJ = cyrus-sasl.o cyrus-sasl-extern.o
|
|
|
6bbd11 |
- LDAP_FLAGS += $(SASL_FLAGS) $(XML_FLAGS) $(KRB5_FLAGS) -DLDAP_THREAD_SAFE
|
|
|
6bbd11 |
- LIBLDAP += $(LIBSASL) $(XML_LIBS) $(KRB5_LIBS)
|
|
|
6bbd11 |
+ LDAP_FLAGS += $(SASL_FLAGS) $(KRB5_FLAGS)
|
|
|
6bbd11 |
+ LIBLDAP += $(LIBSASL) $(KRB5_LIBS)
|
|
|
6bbd11 |
endif
|
|
|
6bbd11 |
endif
|
|
|
6bbd11 |
|
|
|
6bbd11 |
--- autofs-5.0.7.orig/modules/lookup_ldap.c
|
|
|
6bbd11 |
+++ autofs-5.0.7/modules/lookup_ldap.c
|
|
|
6bbd11 |
@@ -66,6 +66,7 @@ struct ldap_search_params {
|
|
|
6bbd11 |
|
|
|
6bbd11 |
static int decode_percent_hack(const char *, char **);
|
|
|
6bbd11 |
|
|
|
6bbd11 |
+#ifdef WITH_SASL
|
|
|
6bbd11 |
static int set_env(unsigned logopt, const char *name, const char *val)
|
|
|
6bbd11 |
{
|
|
|
6bbd11 |
int ret = setenv(name, val, 1);
|
|
|
6bbd11 |
@@ -75,6 +76,7 @@ static int set_env(unsigned logopt, cons
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
return 1;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
+#endif
|
|
|
6bbd11 |
|
|
|
6bbd11 |
#ifndef HAVE_LDAP_CREATE_PAGE_CONTROL
|
|
|
6bbd11 |
int ldap_create_page_control(LDAP *ldap, ber_int_t pagesize,
|
|
|
6bbd11 |
@@ -183,9 +185,9 @@ int unbind_ldap_connection(unsigned logo
|
|
|
6bbd11 |
{
|
|
|
6bbd11 |
int rv;
|
|
|
6bbd11 |
|
|
|
6bbd11 |
-#ifdef WITH_SASL
|
|
|
6bbd11 |
if (ctxt->use_tls == LDAP_TLS_RELEASE)
|
|
|
6bbd11 |
ctxt->use_tls = LDAP_TLS_INIT;
|
|
|
6bbd11 |
+#ifdef WITH_SASL
|
|
|
6bbd11 |
autofs_sasl_unbind(ctxt);
|
|
|
6bbd11 |
#endif
|
|
|
6bbd11 |
|
|
|
6bbd11 |
@@ -243,7 +245,6 @@ LDAP *init_ldap_connection(unsigned logo
|
|
|
6bbd11 |
info(logopt, MODPREFIX "failed to set connection timeout to %d",
|
|
|
6bbd11 |
net_timeout.tv_sec);
|
|
|
6bbd11 |
|
|
|
6bbd11 |
-#ifdef WITH_SASL
|
|
|
6bbd11 |
if (ctxt->use_tls) {
|
|
|
6bbd11 |
if (ctxt->version == 2) {
|
|
|
6bbd11 |
if (ctxt->tls_required) {
|
|
|
6bbd11 |
@@ -272,7 +273,6 @@ LDAP *init_ldap_connection(unsigned logo
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
ctxt->use_tls = LDAP_TLS_RELEASE;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
-#endif
|
|
|
6bbd11 |
|
|
|
6bbd11 |
return ldap;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
@@ -585,10 +585,12 @@ static LDAP *do_connect(unsigned logopt,
|
|
|
6bbd11 |
{
|
|
|
6bbd11 |
LDAP *ldap;
|
|
|
6bbd11 |
|
|
|
6bbd11 |
+#ifdef WITH_SASL
|
|
|
6bbd11 |
if (ctxt->extern_cert && ctxt->extern_key) {
|
|
|
6bbd11 |
set_env(logopt, ENV_LDAPTLS_CERT, ctxt->extern_cert);
|
|
|
6bbd11 |
set_env(logopt, ENV_LDAPTLS_KEY, ctxt->extern_key);
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
+#endif
|
|
|
6bbd11 |
|
|
|
6bbd11 |
ldap = init_ldap_connection(logopt, uri, ctxt);
|
|
|
6bbd11 |
if (ldap) {
|
|
|
6bbd11 |
@@ -791,7 +793,6 @@ find_server:
|
|
|
6bbd11 |
return ldap;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
-#ifdef WITH_SASL
|
|
|
6bbd11 |
int get_property(unsigned logopt, xmlNodePtr node, const char *prop, char **value)
|
|
|
6bbd11 |
{
|
|
|
6bbd11 |
xmlChar *ret;
|
|
|
6bbd11 |
@@ -812,6 +813,7 @@ int get_property(unsigned logopt, xmlNod
|
|
|
6bbd11 |
return 0;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
+#ifdef WITH_SASL
|
|
|
6bbd11 |
/*
|
|
|
6bbd11 |
* For plain text, login and digest-md5 authentication types, we need
|
|
|
6bbd11 |
* user and password credentials.
|
|
|
6bbd11 |
@@ -824,6 +826,7 @@ int authtype_requires_creds(const char *
|
|
|
6bbd11 |
return 1;
|
|
|
6bbd11 |
return 0;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
+#endif
|
|
|
6bbd11 |
|
|
|
6bbd11 |
/*
|
|
|
6bbd11 |
* Returns:
|
|
|
6bbd11 |
@@ -1056,6 +1059,7 @@ auth_fail:
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
} else if (auth_required == LDAP_AUTH_REQUIRED &&
|
|
|
6bbd11 |
(authtype && !strncmp(authtype, "EXTERNAL", 8))) {
|
|
|
6bbd11 |
+#ifdef WITH_SASL
|
|
|
6bbd11 |
ret = get_property(logopt, root, "external_cert", &extern_cert);
|
|
|
6bbd11 |
ret |= get_property(logopt, root, "external_key", &extern_key);
|
|
|
6bbd11 |
/*
|
|
|
6bbd11 |
@@ -1074,6 +1078,7 @@ auth_fail:
|
|
|
6bbd11 |
if (extern_key)
|
|
|
6bbd11 |
free(extern_key);
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
+#endif
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
/*
|
|
|
6bbd11 |
@@ -1094,8 +1099,10 @@ auth_fail:
|
|
|
6bbd11 |
ctxt->secret = secret;
|
|
|
6bbd11 |
ctxt->client_princ = client_princ;
|
|
|
6bbd11 |
ctxt->client_cc = client_cc;
|
|
|
6bbd11 |
+#ifdef WITH_SASL
|
|
|
6bbd11 |
ctxt->extern_cert = extern_cert;
|
|
|
6bbd11 |
ctxt->extern_key = extern_key;
|
|
|
6bbd11 |
+#endif
|
|
|
6bbd11 |
|
|
|
6bbd11 |
debug(logopt, MODPREFIX
|
|
|
6bbd11 |
"ldap authentication configured with the following options:");
|
|
|
6bbd11 |
@@ -1127,7 +1134,6 @@ out:
|
|
|
6bbd11 |
|
|
|
6bbd11 |
return ret;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
-#endif
|
|
|
6bbd11 |
|
|
|
6bbd11 |
/*
|
|
|
6bbd11 |
* Take an input string as specified in the master map, and break it
|
|
|
6bbd11 |
@@ -1390,10 +1396,12 @@ static void free_context(struct lookup_c
|
|
|
6bbd11 |
defaults_free_searchdns(ctxt->sdns);
|
|
|
6bbd11 |
if (ctxt->dclist)
|
|
|
6bbd11 |
free_dclist(ctxt->dclist);
|
|
|
6bbd11 |
+#ifdef WITH_SASL
|
|
|
6bbd11 |
if (ctxt->extern_cert)
|
|
|
6bbd11 |
free(ctxt->extern_cert);
|
|
|
6bbd11 |
if (ctxt->extern_key)
|
|
|
6bbd11 |
free(ctxt->extern_key);
|
|
|
6bbd11 |
+#endif
|
|
|
6bbd11 |
free(ctxt);
|
|
|
6bbd11 |
|
|
|
6bbd11 |
return;
|