[dovecot-cvs] dovecot/src/auth db-ldap.c, 1.24, 1.25 passdb-ldap.c, 1.20, 1.21 userdb-ldap.c, 1.24, 1.25

cras at dovecot.org cras at dovecot.org
Thu Jan 13 20:37:02 EET 2005


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

Modified Files:
	db-ldap.c passdb-ldap.c userdb-ldap.c 
Log Message:
Move default filters/attrs to setting defaults rather than check it from
code. Also fixes a crash.



Index: db-ldap.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/db-ldap.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- db-ldap.c	19 Dec 2004 05:30:20 -0000	1.24
+++ db-ldap.c	13 Jan 2005 18:37:00 -0000	1.25
@@ -56,10 +56,10 @@
 	MEMBER(scope) "subtree",
 	MEMBER(base) NULL,
 	MEMBER(ldap_version) 2,
-	MEMBER(user_attrs) NULL,
-	MEMBER(user_filter) NULL,
-	MEMBER(pass_attrs) NULL,
-	MEMBER(pass_filter) NULL,
+	MEMBER(user_attrs) "uid,homeDirectory,,,uidNumber,gidNumber",
+	MEMBER(user_filter) "(&(objectClass=posixAccount)(uid=%u))",
+	MEMBER(pass_attrs) "uid,userPassword",
+	MEMBER(pass_filter) "(&(objectClass=posixAccount)(uid=%u))",
 	MEMBER(default_pass_scheme) "crypt",
 	MEMBER(user_global_uid) (uid_t)-1,
 	MEMBER(user_global_gid) (gid_t)-1

Index: passdb-ldap.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-ldap.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- passdb-ldap.c	11 Jan 2005 00:13:50 -0000	1.20
+++ passdb-ldap.c	13 Jan 2005 18:37:00 -0000	1.21
@@ -16,9 +16,6 @@
 #include <ldap.h>
 #include <stdlib.h>
 
-/* using posixAccount */
-#define DEFAULT_ATTRIBUTES "uid,userPassword"
-
 enum ldap_user_attr {
 	ATTR_VIRTUAL_USER = 0,
 	ATTR_PASSWORD,
@@ -163,14 +160,8 @@
 	var_expand(str, conn->set.base, vars);
 	base = t_strdup(str_c(str));
 
-	if (conn->set.pass_filter == NULL) {
-		filter = t_strdup_printf("(&(objectClass=posixAccount)(%s=%s))",
-					 attr_names[ATTR_VIRTUAL_USER],
-					 ldap_escape(auth_request->user));
-	} else {
-		var_expand(str, conn->set.pass_filter, vars);
-		filter = str_c(str);
-	}
+	var_expand(str, conn->set.pass_filter, vars);
+	filter = str_c(str);
 
 	auth_request_ref(auth_request);
 	ldap_request->callback = handle_request;
@@ -243,9 +234,7 @@
 	passdb_ldap_conn = i_new(struct passdb_ldap_connection, 1);
 	passdb_ldap_conn->conn = conn = db_ldap_init(args);
 
-	db_ldap_set_attrs(conn, conn->set.pass_attrs ?
-			  conn->set.pass_attrs : DEFAULT_ATTRIBUTES,
-			  &passdb_ldap_conn->attrs,
+	db_ldap_set_attrs(conn, conn->set.pass_attrs, &passdb_ldap_conn->attrs,
 			  &passdb_ldap_conn->attr_names);
 	passdb_ldap_cache_key = auth_cache_parse_key(conn->set.pass_filter);
 }

Index: userdb-ldap.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/userdb-ldap.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- userdb-ldap.c	11 Jan 2005 00:13:50 -0000	1.24
+++ userdb-ldap.c	13 Jan 2005 18:37:00 -0000	1.25
@@ -14,9 +14,6 @@
 #include <ldap.h>
 #include <stdlib.h>
 
-/* using posixAccount */
-#define DEFAULT_ATTRIBUTES "uid,homeDirectory,,,uidNumber,gidNumber"
-
 enum ldap_user_attr {
 	ATTR_VIRTUAL_USER = 0,
 	ATTR_HOME,
@@ -176,14 +173,8 @@
 	var_expand(str, conn->set.base, vars);
 	base = t_strdup(str_c(str));
 
-	if (conn->set.user_filter == NULL) {
-		filter = t_strdup_printf("(&(objectClass=posixAccount)(%s=%s))",
-					 attr_names[ATTR_VIRTUAL_USER],
-					 ldap_escape(auth_request->user));
-	} else {
-		var_expand(str, conn->set.user_filter, vars);
-		filter = str_c(str);
-	}
+	var_expand(str, conn->set.user_filter, vars);
+	filter = str_c(str);
 
 	request = i_new(struct userdb_ldap_request, 1);
 	request->request.callback = handle_request;
@@ -208,9 +199,7 @@
 	userdb_ldap_conn = i_new(struct userdb_ldap_connection, 1);
 	userdb_ldap_conn->conn = conn = db_ldap_init(args);
 
-	db_ldap_set_attrs(conn, conn->set.user_attrs ?
-			  conn->set.user_attrs : DEFAULT_ATTRIBUTES,
-			  &userdb_ldap_conn->attrs,
+	db_ldap_set_attrs(conn, conn->set.user_attrs, &userdb_ldap_conn->attrs,
 			  &userdb_ldap_conn->attr_names);
 }
 



More information about the dovecot-cvs mailing list