Blame SOURCES/autofs-5.0.7-fix-compilation-of-lookup_ldap_c-without-sasl.patch

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