AutoFS development
 help / color / mirror / Atom feed
From: Ian Kent <raven@themaw.net>
To: autofs mailing list <autofs@vger.kernel.org>
Cc: Gordon Lack <gordon.m.lack@gsk.com>,
	"Lan Yixun (dlan)" <dennis.yxun@gmail.com>,
	Leonardo Chiquitto <leonardo.lists@gmail.com>,
	Dustin Polke <DuPol@gmx.de>
Subject: [PATCH 16/25] autofs-5.0.7 - fix compilation of lookup_ldap.c without sasl
Date: Mon, 19 Aug 2013 09:13:42 +0800	[thread overview]
Message-ID: <20130819011341.6472.69065.stgit@perseus.fritz.box> (raw)
In-Reply-To: <20130819010909.6472.32512.stgit@perseus.fritz.box>

From: Dustin Polke <DuPol@gmx.de>

See https://bugs.gentoo.org/show_bug.cgi?id=361899 for more info.

Edited by: Ian Kent <raven@themaw.net>
- fix parse_ldap_config() is needed by ldap but previously excluded.
- exclude other references to ctxt->extern_cert and ctxt->extern_key.
- prevent memory leak if present in config but not used.
- remove now unused set_env().
---
 CHANGELOG             |    1 +
 include/lookup_ldap.h |    4 ++--
 lib/Makefile          |    4 ++++
 modules/Makefile      |    6 ++++--
 modules/lookup_ldap.c |   18 +++++++++++++-----
 5 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index dd6fc1a..5764cb0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -67,6 +67,7 @@
 - remove hard-coded STRIP variable.
 - use LIBS for link libraries.
 - unbundle NOTSTRIP from DEBUG so they dont depend on each other.
+- fix compilation of lookup_ldap.c without sasl.
 
 25/07/2012 autofs-5.0.7
 =======================
diff --git a/include/lookup_ldap.h b/include/lookup_ldap.h
index 9a4ce73..f34c029 100644
--- a/include/lookup_ldap.h
+++ b/include/lookup_ldap.h
@@ -11,6 +11,8 @@
 #include <krb5.h>
 #endif
 
+#include <libxml/tree.h>
+
 #include "list.h"
 #include "dclist.h"
 
@@ -92,7 +94,6 @@ struct lookup_context {
 };
 
 
-#ifdef WITH_SASL
 #define LDAP_AUTH_CONF_FILE "test"
 
 #define LDAP_TLS_DONT_USE	0
@@ -104,7 +105,6 @@ struct lookup_context {
 #define LDAP_AUTH_REQUIRED	0x0002
 #define LDAP_AUTH_AUTODETECT	0x0004
 #define LDAP_NEED_AUTH		(LDAP_AUTH_REQUIRED|LDAP_AUTH_AUTODETECT)
-#endif
 
 #define LDAP_AUTH_USESIMPLE	0x0008
 
diff --git a/lib/Makefile b/lib/Makefile
index 314779b..518b483 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -24,6 +24,10 @@ CFLAGS += -I../include -fPIC -D_GNU_SOURCE
 CFLAGS += -DAUTOFS_MAP_DIR=\"$(autofsmapdir)\"
 CFLAGS += -DAUTOFS_CONF_DIR=\"$(autofsconfdir)\"
 
+ifeq ($(LDAP), 1)
+  CFLAGS += $(XML_FLAGS) $(XML_LIBS)
+endif
+
 .PHONY: all install clean
 
 all: autofs.a
diff --git a/modules/Makefile b/modules/Makefile
index de01ebd..8610783 100644
--- a/modules/Makefile
+++ b/modules/Makefile
@@ -45,10 +45,12 @@ endif
 ifeq ($(LDAP), 1)
   SRCS += lookup_ldap.c
   MODS += lookup_ldap.so
+  LDAP_FLAGS += $(XML_FLAGS) -DLDAP_THREAD_SAFE
+  LIBLDAP += $(XML_LIBS)
   ifeq ($(SASL), 1)
     SASL_OBJ = cyrus-sasl.o cyrus-sasl-extern.o
-    LDAP_FLAGS += $(SASL_FLAGS) $(XML_FLAGS) $(KRB5_FLAGS) -DLDAP_THREAD_SAFE
-    LIBLDAP += $(LIBSASL) $(XML_LIBS) $(KRB5_LIBS)
+    LDAP_FLAGS += $(SASL_FLAGS) $(KRB5_FLAGS)
+    LIBLDAP += $(LIBSASL) $(KRB5_LIBS)
   endif
 endif
 
diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
index 655e9fa..d05098f 100644
--- a/modules/lookup_ldap.c
+++ b/modules/lookup_ldap.c
@@ -72,6 +72,7 @@ struct ldap_search_params {
 
 static int decode_percent_hack(const char *, char **);
 
+#ifdef WITH_SASL
 static int set_env(unsigned logopt, const char *name, const char *val)
 {
 	int ret = setenv(name, val, 1);
@@ -81,6 +82,7 @@ static int set_env(unsigned logopt, const char *name, const char *val)
 	}
 	return 1;
 }
+#endif
 
 #ifndef HAVE_LDAP_CREATE_PAGE_CONTROL
 int ldap_create_page_control(LDAP *ldap, ber_int_t pagesize,
@@ -205,9 +207,9 @@ int unbind_ldap_connection(unsigned logopt, LDAP *ldap, struct lookup_context *c
 {
 	int rv;
 
-#ifdef WITH_SASL
 	if (ctxt->use_tls == LDAP_TLS_RELEASE)
 		ctxt->use_tls = LDAP_TLS_INIT;
+#ifdef WITH_SASL
 	autofs_sasl_unbind(ctxt);
 #endif
 
@@ -265,7 +267,6 @@ LDAP *__init_ldap_connection(unsigned logopt, const char *uri, struct lookup_con
 		info(logopt, MODPREFIX "failed to set connection timeout to %d",
 		     net_timeout.tv_sec);
 
-#ifdef WITH_SASL
 	if (ctxt->use_tls) {
 		if (ctxt->version == 2) {
 			if (ctxt->tls_required) {
@@ -294,7 +295,6 @@ LDAP *__init_ldap_connection(unsigned logopt, const char *uri, struct lookup_con
 		}
 		ctxt->use_tls = LDAP_TLS_RELEASE;
 	}
-#endif
 
 	return ldap;
 }
@@ -618,10 +618,12 @@ static LDAP *do_connect(unsigned logopt, const char *uri, struct lookup_context
 {
 	LDAP *ldap;
 
+#ifdef WITH_SASL
 	if (ctxt->extern_cert && ctxt->extern_key) {
 		set_env(logopt, ENV_LDAPTLS_CERT, ctxt->extern_cert);
 		set_env(logopt, ENV_LDAPTLS_KEY, ctxt->extern_key);
 	}
+#endif
 
 	ldap = init_ldap_connection(logopt, uri, ctxt);
 	if (ldap) {
@@ -824,7 +826,6 @@ find_server:
 	return ldap;
 }
 
-#ifdef WITH_SASL
 int get_property(unsigned logopt, xmlNodePtr node, const char *prop, char **value)
 {
 	xmlChar *ret;
@@ -845,6 +846,7 @@ int get_property(unsigned logopt, xmlNodePtr node, const char *prop, char **valu
 	return 0;
 }
 
+#ifdef WITH_SASL
 /*
  *  For plain text, login and digest-md5 authentication types, we need
  *  user and password credentials.
@@ -857,6 +859,7 @@ int authtype_requires_creds(const char *authtype)
 		return 1;
 	return 0;
 }
+#endif
 
 /*
  *  Returns:
@@ -1089,6 +1092,7 @@ auth_fail:
 		}
 	} else if (auth_required == LDAP_AUTH_REQUIRED &&
 		  (authtype && !strncmp(authtype, "EXTERNAL", 8))) {
+#ifdef WITH_SASL
 		ret = get_property(logopt, root, "external_cert",  &extern_cert);
 		ret |= get_property(logopt, root, "external_key",  &extern_key);
 		/*
@@ -1107,6 +1111,7 @@ auth_fail:
 			if (extern_key)
 				free(extern_key);
 		}
+#endif
 	}
 
 	/*
@@ -1127,8 +1132,10 @@ auth_fail:
 	ctxt->secret = secret;
 	ctxt->client_princ = client_princ;
 	ctxt->client_cc = client_cc;
+#ifdef WITH_SASL
 	ctxt->extern_cert = extern_cert;
 	ctxt->extern_key = extern_key;
+#endif
 
 	debug(logopt, MODPREFIX
 	      "ldap authentication configured with the following options:");
@@ -1160,7 +1167,6 @@ out:
 
 	return ret;
 }
-#endif
 
 /*
  *  Take an input string as specified in the master map, and break it
@@ -1423,10 +1429,12 @@ static void free_context(struct lookup_context *ctxt)
 		defaults_free_searchdns(ctxt->sdns);
 	if (ctxt->dclist)
 		free_dclist(ctxt->dclist);
+#ifdef WITH_SASL
 	if (ctxt->extern_cert)
 		free(ctxt->extern_cert);
 	if (ctxt->extern_key)
 		free(ctxt->extern_key);
+#endif
 	free(ctxt);
 
 	return;


  parent reply	other threads:[~2013-08-19  1:13 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-19  1:11 [PATCH 00/25] Current autofs patch queue Ian Kent
2013-08-19  1:11 ` [PATCH 01/25] autofs-5.0.7 - don't override LDFLAGS in make rules Ian Kent
2013-08-19  1:12 ` [PATCH 02/25] autofs-5.0.7 - fix a couple of compiler warnings Ian Kent
2013-08-19  1:12 ` [PATCH 03/25] autofs-5.0.7 - add after sssd dependency to unit file Ian Kent
2013-08-19  1:12 ` [PATCH 04/25] autofs-5.0.7 - dont start readmap unless ready Ian Kent
2013-08-19  1:12 ` [PATCH 05/25] autofs-5.0.7 - fix crash due to thread unsafe use of libldap Ian Kent
2013-08-19  1:12 ` [PATCH 06/25] autofs-5.0.7 - fix compile error with heimdal support enabled Ian Kent
2013-08-20  3:36   ` Dennis Lan (dlan)
2013-08-20  7:34     ` Ian Kent
2013-08-19  1:12 ` [PATCH 07/25] autofs-5.0.7 - fix typo forced-shutdown should be force-shutdown Ian Kent
2013-08-19  1:12 ` [PATCH 08/25] autofs-5.0.7 - fix hesiod check error and use correct $(LIBS) setting Ian Kent
2013-08-19  1:12 ` [PATCH 09/25] autofs-5.0.7 - fix dead LDAP symbolic link when LDAP support is disabled Ian Kent
2013-08-19  1:13 ` [PATCH 10/25] autofs-5.0.7 - add missing libtirpc lib to mount_nfs.so when TIRPC enabled Ian Kent
2013-08-19  1:13 ` [PATCH 11/25] autofs-5.0.7 - use compiler determined by configure instead of hard-coded ones Ian Kent
2013-08-19  1:13 ` [PATCH 12/25] autofs-5.0.7 - remove hard-coded STRIP variable Ian Kent
2013-08-19  1:13 ` [PATCH 13/25] autofs-5.0.7 - use LIBS for link libraries Ian Kent
2013-08-19  1:13 ` [PATCH 14/25] autofs-5.0.7 - unbundle NOTSTRIP from DEBUG so they dont depend on each other Ian Kent
2013-08-19  1:13 ` [PATCH 15/25] autofs-5.0.7 - fix occasional build error when enable parallel compiling Ian Kent
2013-08-19  1:13 ` Ian Kent [this message]
2013-08-19  1:13 ` [PATCH 17/25] autofs-5.0.7 - fix dumpmaps multi output Ian Kent
2013-08-19  1:13 ` [PATCH 18/25] autofs-5.0.7 - try and cleanup after dumpmaps Ian Kent
2013-08-19  1:14 ` [PATCH 19/25] autofs-5.0.7 - teach dumpmaps to output simple key value pairs Ian Kent
2013-08-19  1:14 ` [PATCH 20/25] autofs-5.0.7 - fix syncronize handle_mounts() shutdown Ian Kent
2013-08-19  1:14 ` [PATCH 21/25] autofs-5.0.7 - fix fix wildcard multi map regression Ian Kent
2013-08-19  1:14 ` [PATCH 22/25] autofs-5.0.7 - improve timeout option description Ian Kent
2013-08-19  1:14 ` [PATCH 23/25] autofs-5.0.7 - only probe specific nfs version when requested Ian Kent
2013-08-19  1:14 ` [PATCH 24/25] autofs-5.0.7 - fix bad mkdir permission on create Ian Kent
2013-08-19  2:13   ` Ian Kent
2013-08-19  1:14 ` [PATCH 25/25] autofs-5.0.7 - setup program map env from macro table Ian Kent
2013-08-19  5:30 ` [PATCH 00/25] Current autofs patch queue Dennis Lan (dlan)
2013-08-20  2:55   ` Ian Kent
2013-08-20  4:52     ` Dennis Lan (dlan)
2013-09-02 10:34 ` Martin Wilck
2013-09-02 10:41   ` Gordon Lack
2013-09-02 11:04     ` Martin Wilck
2013-09-02 11:13       ` Gordon Lack
2013-09-02 12:17         ` Martin Wilck
2013-09-02 12:55           ` Gordon Lack
2013-09-02 13:15             ` Martin Wilck
2013-09-02 13:41               ` Gordon Lack
2013-09-02 14:11                 ` Martin Wilck
2013-09-02 14:20                   ` Gordon Lack
2013-09-02 14:49                     ` Martin Wilck
2013-09-02 15:08                       ` Gordon Lack
2013-09-02 15:23                         ` Martin Wilck
2013-09-02 15:36                           ` Gordon Lack
2013-09-06  8:11   ` Ian Kent

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130819011341.6472.69065.stgit@perseus.fritz.box \
    --to=raven@themaw.net \
    --cc=DuPol@gmx.de \
    --cc=autofs@vger.kernel.org \
    --cc=dennis.yxun@gmail.com \
    --cc=gordon.m.lack@gsk.com \
    --cc=leonardo.lists@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox