changeset 4426:b8089cf41c96 HEAD

Check for sasl.h and sasl/sasl.h existence and use the one that's found. If neither is found, disable support for LDAP SASL.
author Timo Sirainen <tss@iki.fi>
date Mon, 19 Jun 2006 19:10:16 +0300
parents 227733bbe607
children ffafc8583e06
files configure.in src/auth/db-ldap.c src/auth/db-ldap.h
diffstat 3 files changed, 23 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/configure.in	Sun Jun 18 22:47:17 2006 +0300
+++ b/configure.in	Mon Jun 19 19:10:16 2006 +0300
@@ -17,7 +17,8 @@
 AC_CHECK_HEADERS(strings.h stdint.h unistd.h dirent.h \
   sys/uio.h sys/sysmacros.h sys/resource.h sys/select.h libgen.h \
   sys/quota.h sys/fs/ufs_quota.h ufs/ufs/quota.h jfs/quota.h \
-  mntent.h sys/mnttab.h sys/event.h sys/time.h sys/mkdev.h linux/dqblk_xfs.h)
+  mntent.h sys/mnttab.h sys/event.h sys/time.h sys/mkdev.h linux/dqblk_xfs.h \
+  sasl.h sasl/sasl.h)
 
 AC_ARG_ENABLE(ipv6,
 [  --enable-ipv6           Enable IPv6 support (default)],
--- a/src/auth/db-ldap.c	Sun Jun 18 22:47:17 2006 +0300
+++ b/src/auth/db-ldap.c	Mon Jun 19 19:10:16 2006 +0300
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 Timo Sirainen */
+/* Copyright (C) 2003-2006 Timo Sirainen */
 
 #include "common.h"
 
@@ -15,6 +15,15 @@
 #include <stddef.h>
 #include <stdlib.h>
 
+#define HAVE_LDAP_SASL
+#ifdef HAVE_SASL_H
+#  include <sasl.h>
+#elif defined (HAVE_SASL_SASL_H)
+#  include <sasl/sasl.h>
+#else
+#  undef HAVE_LDAP_SASL
+#endif
+
 /* Older versions may require calling ldap_result() twice */
 #if LDAP_VENDOR_VERSION <= 20112
 #  define OPENLDAP_ASYNC_WORKAROUND
@@ -226,11 +235,12 @@
 	}
 }
 
+#ifdef HAVE_LDAP_SASL
 static int
 sasl_interact(LDAP *ld __attr_unused__, unsigned flags __attr_unused__,
 	      void *defaults, void *interact)
 {
-	struct sasl_bind_context *context = defaults;
+	struct ldap_sasl_bind_context *context = defaults;
 	sasl_interact_t *in;
 	const char *str;
 
@@ -260,11 +270,11 @@
 	}
 	return LDAP_SUCCESS;
 }
+#endif
 
 bool db_ldap_connect(struct ldap_connection *conn)
 {
 	int ret, fd;
-	struct sasl_bind_context context;
 
 	if (conn->connected)
 		return TRUE;
@@ -316,6 +326,10 @@
 
 	/* FIXME: we shouldn't use blocking bind */
 	if (conn->set.sasl_bind) {
+#ifdef HAVE_LDAP_SASL
+		struct ldap_sasl_bind_context context;
+
+		memset(&context, 0, sizeof(context));
 		context.authcid = conn->set.dn;
 		context.passwd = conn->set.dnpass;
 		context.realm = conn->set.sasl_realm;
@@ -325,6 +339,9 @@
 						   conn->set.sasl_mech,
 						   NULL, NULL, LDAP_SASL_QUIET,
 						   sasl_interact, &context);
+#else
+		i_fatal("LDAP: sasl_bind=yes but no SASL support compiled in");
+#endif
 	} else {
 		ret = ldap_simple_bind_s(conn->ld, conn->set.dn,
 					 conn->set.dnpass);
--- a/src/auth/db-ldap.h	Sun Jun 18 22:47:17 2006 +0300
+++ b/src/auth/db-ldap.h	Mon Jun 19 19:10:16 2006 +0300
@@ -2,7 +2,6 @@
 #define __DB_LDAP_H
 
 #include <ldap.h>
-#include <sasl/sasl.h>
 
 struct auth_request;
 struct ldap_connection;
@@ -75,7 +74,7 @@
 	char **attributes; /* points to pass_attr_names / user_attr_names */
 };
 
-struct sasl_bind_context {
+struct ldap_sasl_bind_context {
 	const char *authcid;
 	const char *passwd;
 	const char *realm;