? log
? m
Index: db-ldap.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/db-ldap.c,v
retrieving revision 1.28
diff -u -r1.28 db-ldap.c
--- db-ldap.c	16 Mar 2005 19:03:58 -0000	1.28
+++ db-ldap.c	17 Apr 2005 16:50:38 -0000
@@ -269,6 +269,7 @@
 }
 
 void db_ldap_set_attrs(struct ldap_connection *conn, const char *attrlist,
+		       char ***attr_names_r, struct hash_table *attr_map,
 		       const char *const default_attr_map[])
 {
 	const char *const *attr;
@@ -283,7 +284,7 @@
 
 	/* @UNSAFE */
 	for (size = 0; attr[size] != NULL; size++) ;
-	conn->attr_names = p_new(conn->pool, char *, size + 1);
+	*attr_names_r = p_new(conn->pool, char *, size + 1);
 
 	for (i = 0; i < size; i++) {
 		p = strchr(attr[i], '=');
@@ -296,9 +297,9 @@
 			value = p_strdup(conn->pool, p + 1);
 		}
 
-		conn->attr_names[i] = name;
+		(*attr_names_r)[i] = name;
 		if (*name != '\0')
-			hash_insert(conn->attr_map, name, value);
+			hash_insert(attr_map, name, value);
 
 		if (*default_attr_map != NULL)
 			default_attr_map++;
@@ -372,8 +373,6 @@
 
 	conn->refcount = 1;
 	conn->requests = hash_create(default_pool, pool, 0, NULL, NULL);
-	conn->attr_map = hash_create(default_pool, pool, 0, str_hash,
-				     (hash_cmp_callback_t *)strcmp);
 
 	conn->config_path = p_strdup(pool, config_path);
 	conn->set = default_ldap_settings;
@@ -400,7 +399,10 @@
 	ldap_conn_close(conn);
 
 	hash_destroy(conn->requests);
-	hash_destroy(conn->attr_map);
+	if (conn->pass_attr_map != NULL)
+		hash_destroy(conn->pass_attr_map);
+	if (conn->user_attr_map != NULL)
+		hash_destroy(conn->user_attr_map);
 	pool_unref(conn->pool);
 }
 
Index: db-ldap.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/db-ldap.h,v
retrieving revision 1.13
diff -u -r1.13 db-ldap.h
--- db-ldap.h	12 Feb 2005 13:47:20 -0000	1.13
+++ db-ldap.h	17 Apr 2005 16:50:38 -0000
@@ -45,8 +45,8 @@
 	struct io *io;
 	struct hash_table *requests;
 
-	char **attr_names;
-	struct hash_table *attr_map;
+	char **pass_attr_names, **user_attr_names;
+	struct hash_table *pass_attr_map, *user_attr_map;
 
 	unsigned int connected:1;
 };
@@ -61,6 +61,7 @@
 		    struct ldap_request *request);
 
 void db_ldap_set_attrs(struct ldap_connection *conn, const char *attrlist,
+		       char ***attr_names_r, struct hash_table *attr_map,
 		       const char *const default_attr_map[]);
 
 struct ldap_connection *db_ldap_init(const char *config_path);
Index: passdb-ldap.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-ldap.c,v
retrieving revision 1.28
diff -u -r1.28 passdb-ldap.c
--- passdb-ldap.c	8 Apr 2005 10:25:50 -0000	1.28
+++ passdb-ldap.c	17 Apr 2005 16:50:38 -0000
@@ -49,7 +49,7 @@
 
 	attr = ldap_first_attribute(conn->ld, entry, &ber);
 	while (attr != NULL) {
-		name = hash_lookup(passdb_ldap_conn->attr_map, attr);
+		name = hash_lookup(passdb_ldap_conn->pass_attr_map, attr);
 		vals = ldap_get_values(conn->ld, entry, attr);
 
 		if (name != NULL && vals != NULL) {
@@ -157,7 +157,7 @@
 {
 	struct ldap_connection *conn = passdb_ldap_conn;
         const struct var_expand_table *vars;
-	const char **attr_names = (const char **)conn->attr_names;
+	const char **attr_names = (const char **)conn->pass_attr_names;
 	const char *filter, *base;
 	string_t *str;
 
@@ -181,7 +181,7 @@
 			       t_strarray_join(attr_names, ","));
 
 	db_ldap_search(conn, base, conn->set.ldap_scope,
-		       filter, passdb_ldap_conn->attr_names,
+		       filter, passdb_ldap_conn->pass_attr_names,
 		       ldap_request);
 }
 
@@ -215,8 +215,13 @@
 static void passdb_ldap_preinit(const char *args)
 {
 	passdb_ldap_conn = db_ldap_init(args);
+	passdb_ldap_conn->pass_attr_map =
+		hash_create(default_pool, passdb_ldap_conn->pool, 0, str_hash,
+			    (hash_cmp_callback_t *)strcmp);
 
 	db_ldap_set_attrs(passdb_ldap_conn, passdb_ldap_conn->set.pass_attrs,
+                          &passdb_ldap_conn->pass_attr_names,
+			  passdb_ldap_conn->pass_attr_map,
 			  default_attr_map);
 	passdb_ldap.cache_key = passdb_ldap_cache_key =
 		auth_cache_parse_key(passdb_ldap_conn->set.pass_filter);
Index: userdb-ldap.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/userdb-ldap.c,v
retrieving revision 1.30
diff -u -r1.30 userdb-ldap.c
--- userdb-ldap.c	16 Mar 2005 19:03:58 -0000	1.30
+++ userdb-ldap.c	17 Apr 2005 16:50:38 -0000
@@ -81,7 +81,7 @@
 
 	attr = ldap_first_attribute(conn->ld, entry, &ber);
 	while (attr != NULL) {
-		name = hash_lookup(userdb_ldap_conn->attr_map, attr);
+		name = hash_lookup(userdb_ldap_conn->user_attr_map, attr);
 		vals = ldap_get_values(conn->ld, entry, attr);
 
 		if (name != NULL && vals != NULL && vals[0] != NULL) {
@@ -166,7 +166,8 @@
 {
 	struct ldap_connection *conn = userdb_ldap_conn;
         const struct var_expand_table *vars;
-	const char **attr_names = (const char **)userdb_ldap_conn->attr_names;
+	const char **attr_names =
+		(const char **)userdb_ldap_conn->user_attr_names;
 	struct userdb_ldap_request *request;
 	const char *filter, *base;
 	string_t *str;
@@ -192,14 +193,20 @@
 			       t_strarray_join(attr_names, ","));
 
 	db_ldap_search(conn, base, conn->set.ldap_scope,
-		       filter, userdb_ldap_conn->attr_names,
+		       filter, userdb_ldap_conn->user_attr_names,
 		       &request->request);
 }
 
 static void userdb_ldap_preinit(const char *args)
 {
 	userdb_ldap_conn = db_ldap_init(args);
+	userdb_ldap_conn->user_attr_map =
+		hash_create(default_pool, userdb_ldap_conn->pool, 0, str_hash,
+			    (hash_cmp_callback_t *)strcmp);
+
 	db_ldap_set_attrs(userdb_ldap_conn, userdb_ldap_conn->set.user_attrs,
+                          &userdb_ldap_conn->user_attr_names,
+			  userdb_ldap_conn->user_attr_map,
 			  default_attr_map);
 }
 
