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

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