[dovecot-cvs] dovecot/src/auth db-ldap.c, 1.45, 1.46 db-ldap.h, 1.23, 1.24

cras at dovecot.org cras at dovecot.org
Mon Jun 19 19:10:18 EEST 2006


Update of /var/lib/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv31978/src/auth

Modified Files:
	db-ldap.c db-ldap.h 
Log Message:
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.



Index: db-ldap.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/db-ldap.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- db-ldap.c	17 Jun 2006 19:32:18 -0000	1.45
+++ db-ldap.c	19 Jun 2006 16:10:16 -0000	1.46
@@ -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);

Index: db-ldap.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/db-ldap.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- db-ldap.h	17 Jun 2006 19:32:18 -0000	1.23
+++ db-ldap.h	19 Jun 2006 16:10:16 -0000	1.24
@@ -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;



More information about the dovecot-cvs mailing list