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

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