[dovecot-cvs] dovecot/src/auth db-ldap.c, 1.22, 1.23 db-ldap.h, 1.11, 1.12 db-mysql.c, 1.10, 1.11 db-mysql.h, 1.4, 1.5 db-pgsql.c, 1.8, 1.9 db-pgsql.h, 1.3, 1.4 passdb-bsdauth.c, 1.3, 1.4 passdb-checkpassword.c, 1.1, 1.2 passdb-ldap.c, 1.10, 1.11 passdb-mysql.c, 1.3, 1.4 passdb-pam.c, 1.16, 1.17 passdb-passwd-file.c, 1.9, 1.10 passdb-passwd.c, 1.6, 1.7 passdb-pgsql.c, 1.5, 1.6 passdb-shadow.c, 1.7, 1.8 passdb-vpopmail.c, 1.8, 1.9 passdb.c, 1.22, 1.23 passdb.h, 1.13, 1.14 userdb-ldap.c, 1.14, 1.15 userdb-mysql.c, 1.2, 1.3 userdb-passwd-file.c, 1.8, 1.9 userdb-passwd.c, 1.9, 1.10 userdb-pgsql.c, 1.6, 1.7 userdb-static.c, 1.7, 1.8 userdb-vpopmail.c, 1.9, 1.10 userdb.c, 1.10, 1.11 userdb.h, 1.9, 1.10

cras at dovecot.org cras at dovecot.org
Tue Sep 21 00:47:33 EEST 2004


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

Modified Files:
	db-ldap.c db-ldap.h db-mysql.c db-mysql.h db-pgsql.c 
	db-pgsql.h passdb-bsdauth.c passdb-checkpassword.c 
	passdb-ldap.c passdb-mysql.c passdb-pam.c passdb-passwd-file.c 
	passdb-passwd.c passdb-pgsql.c passdb-shadow.c 
	passdb-vpopmail.c passdb.c passdb.h userdb-ldap.c 
	userdb-mysql.c userdb-passwd-file.c userdb-passwd.c 
	userdb-pgsql.c userdb-static.c userdb-vpopmail.c userdb.c 
	userdb.h 
Log Message:
Added preinit() call to userdb/passdbs, which is called before dropping
privileges. init() is called after. SQL/LDAP now parses the config file in
preinit, but does the actual connecting only in init(). This fixes LDAP
crashing at startup.



Index: db-ldap.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/db-ldap.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- db-ldap.c	16 Jul 2004 16:20:55 -0000	1.22
+++ db-ldap.c	20 Sep 2004 21:47:30 -0000	1.23
@@ -67,7 +67,6 @@
 
 static struct ldap_connection *ldap_connections = NULL;
 
-static int ldap_conn_open(struct ldap_connection *conn);
 static void ldap_conn_close(struct ldap_connection *conn);
 
 static int deref2str(const char *str)
@@ -117,7 +116,7 @@
 	int msgid;
 
 	if (!conn->connected) {
-		if (!ldap_conn_open(conn)) {
+		if (!db_ldap_connect(conn)) {
 			request->callback(conn, request, NULL);
 			return;
 		}
@@ -177,7 +176,7 @@
 	}
 }
 
-static int ldap_conn_open(struct ldap_connection *conn)
+int db_ldap_connect(struct ldap_connection *conn)
 {
 	int ret, fd;
 
@@ -373,8 +372,6 @@
         conn->set.ldap_deref = deref2str(conn->set.deref);
         conn->set.ldap_scope = scope2str(conn->set.scope);
 
-	(void)ldap_conn_open(conn);
-
 	conn->next = ldap_connections;
         ldap_connections = conn;
 	return conn;

Index: db-ldap.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/db-ldap.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- db-ldap.h	25 Apr 2004 22:40:29 -0000	1.11
+++ db-ldap.h	20 Sep 2004 21:47:30 -0000	1.12
@@ -63,6 +63,8 @@
 struct ldap_connection *db_ldap_init(const char *config_path);
 void db_ldap_unref(struct ldap_connection *conn);
 
+int db_ldap_connect(struct ldap_connection *conn);
+
 const char *ldap_escape(const char *str);
 const char *ldap_get_error(struct ldap_connection *conn);
 

Index: db-mysql.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/db-mysql.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- db-mysql.c	26 Jul 2004 17:11:15 -0000	1.10
+++ db-mysql.c	20 Sep 2004 21:47:30 -0000	1.11
@@ -54,7 +54,6 @@
 
 static struct mysql_connection *mysql_connections = NULL;
 
-static int mysql_conn_open(struct mysql_connection *conn);
 static void mysql_conn_close(struct mysql_connection *conn);
 
 void db_mysql_query(struct mysql_connection *conn, const char *query,
@@ -67,7 +66,7 @@
 		i_info("MySQL: Performing query: %s", query);
 
 	if (!conn->connected) {
-		if (!mysql_conn_open(conn)) {
+		if (!db_mysql_connect(conn)) {
 			request->callback(conn, request, NULL);
 			return;
 		}
@@ -110,7 +109,7 @@
 	i_free(request);
 }
 
-static int mysql_conn_open(struct mysql_connection *conn)
+int db_mysql_connect(struct mysql_connection *conn)
 {
 	int use_ssl = FALSE;
 
@@ -214,8 +213,6 @@
 	if (conn->set.db_user == NULL)
 		i_fatal("MySQL: db_user variable isn't set in config file");
 
-	(void)mysql_conn_open(conn);
-
 	conn->next = mysql_connections;
 	mysql_connections = conn;
 	return conn;

Index: db-mysql.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/db-mysql.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- db-mysql.h	30 Jul 2004 02:07:47 -0000	1.4
+++ db-mysql.h	20 Sep 2004 21:47:30 -0000	1.5
@@ -54,4 +54,6 @@
 struct mysql_connection *db_mysql_init(const char *config_path);
 void db_mysql_unref(struct mysql_connection *conn);
 
+int db_mysql_connect(struct mysql_connection *conn);
+
 #endif

Index: db-pgsql.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/db-pgsql.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- db-pgsql.c	30 Jul 2004 06:53:35 -0000	1.8
+++ db-pgsql.c	20 Sep 2004 21:47:30 -0000	1.9
@@ -32,7 +32,6 @@
 
 static struct pgsql_connection *pgsql_connections = NULL;
 
-static int pgsql_conn_open(struct pgsql_connection *conn);
 static void pgsql_conn_close(struct pgsql_connection *conn);
 
 const char *db_pgsql_escape(const char *str)
@@ -53,7 +52,7 @@
 	int failed;
 
 	if (!conn->connected) {
-		if (!pgsql_conn_open(conn)) {
+		if (!db_pgsql_connect(conn)) {
 			request->callback(conn, request, NULL);
 			return;
 		}
@@ -92,7 +91,7 @@
 	i_free(request);
 }
 
-static int pgsql_conn_open(struct pgsql_connection *conn)
+int db_pgsql_connect(struct pgsql_connection *conn)
 {
 	if (conn->connected)
 		return TRUE;
@@ -165,8 +164,6 @@
 	if (!settings_read(config_path, NULL, parse_setting, NULL, conn))
 		exit(FATAL_DEFAULT);
 
-	(void)pgsql_conn_open(conn);
-
 	conn->next = pgsql_connections;
 	pgsql_connections = conn;
 	return conn;

Index: db-pgsql.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/db-pgsql.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- db-pgsql.h	26 Apr 2004 21:20:15 -0000	1.3
+++ db-pgsql.h	20 Sep 2004 21:47:30 -0000	1.4
@@ -45,4 +45,6 @@
 struct pgsql_connection *db_pgsql_init(const char *config_path);
 void db_pgsql_unref(struct pgsql_connection *conn);
 
+int db_pgsql_connect(struct pgsql_connection *conn);
+
 #endif

Index: passdb-bsdauth.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-bsdauth.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- passdb-bsdauth.c	20 Sep 2004 20:49:22 -0000	1.3
+++ passdb-bsdauth.c	20 Sep 2004 21:47:30 -0000	1.4
@@ -65,7 +65,7 @@
 }
 
 struct passdb_module passdb_bsdauth = {
-	NULL,
+	NULL, NULL,
 	bsdauth_deinit,
 
 	bsdauth_verify_plain,

Index: passdb-checkpassword.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-checkpassword.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- passdb-checkpassword.c	18 Jun 2004 03:40:12 -0000	1.1
+++ passdb-checkpassword.c	20 Sep 2004 21:47:30 -0000	1.2
@@ -311,6 +311,7 @@
 }
 
 struct passdb_module passdb_checkpassword = {
+	NULL,
 	checkpassword_init,
 	checkpassword_deinit,
 

Index: passdb-ldap.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-ldap.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- passdb-ldap.c	31 May 2004 18:57:25 -0000	1.10
+++ passdb-ldap.c	20 Sep 2004 21:47:30 -0000	1.11
@@ -201,7 +201,7 @@
         ldap_lookup_pass(request, &ldap_request->request);
 }
 
-static void passdb_ldap_init(const char *args)
+static void passdb_ldap_preinit(const char *args)
 {
 	struct ldap_connection *conn;
 
@@ -214,6 +214,11 @@
 			  &passdb_ldap_conn->attr_names);
 }
 
+static void passdb_ldap_init(const char *args __attr_unused__)
+{
+	(void)db_ldap_connect(passdb_ldap_conn->conn);
+}
+
 static void passdb_ldap_deinit(void)
 {
 	db_ldap_unref(passdb_ldap_conn->conn);
@@ -221,6 +226,7 @@
 }
 
 struct passdb_module passdb_ldap = {
+	passdb_ldap_preinit,
 	passdb_ldap_init,
 	passdb_ldap_deinit,
 

Index: passdb-mysql.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-mysql.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- passdb-mysql.c	31 May 2004 18:57:25 -0000	1.3
+++ passdb-mysql.c	20 Sep 2004 21:47:30 -0000	1.4
@@ -153,7 +153,7 @@
         mysql_lookup_pass(request, &mysql_request->request);
 }
 
-static void passdb_mysql_init(const char *args)
+static void passdb_mysql_preinit(const char *args)
 {
 	struct mysql_connection *conn;
 
@@ -161,6 +161,11 @@
 	passdb_mysql_conn->conn = conn = db_mysql_init(args);
 }
 
+static void passdb_mysql_init(const char *args __attr_unused__)
+{
+	(void)db_mysql_connect(passdb_mysql_conn->conn);
+}
+
 static void passdb_mysql_deinit(void)
 {
 	db_mysql_unref(passdb_mysql_conn->conn);
@@ -168,6 +173,7 @@
 }
 
 struct passdb_module passdb_mysql = {
+	passdb_mysql_preinit,
 	passdb_mysql_init,
 	passdb_mysql_deinit,
 

Index: passdb-pam.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-pam.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- passdb-pam.c	15 Jun 2004 03:14:06 -0000	1.16
+++ passdb-pam.c	20 Sep 2004 21:47:30 -0000	1.17
@@ -404,6 +404,7 @@
 }
 
 struct passdb_module passdb_pam = {
+	NULL,
 	pam_init,
 	pam_deinit,
 

Index: passdb-passwd-file.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-passwd-file.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- passdb-passwd-file.c	31 May 2004 18:57:25 -0000	1.9
+++ passdb-passwd-file.c	20 Sep 2004 21:47:30 -0000	1.10
@@ -83,6 +83,7 @@
 }
 
 struct passdb_module passdb_passwd_file = {
+	NULL,
 	passwd_file_init,
 	passwd_file_deinit,
 

Index: passdb-passwd.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-passwd.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- passdb-passwd.c	31 May 2004 18:57:25 -0000	1.6
+++ passdb-passwd.c	20 Sep 2004 21:47:30 -0000	1.7
@@ -62,7 +62,7 @@
 }
 
 struct passdb_module passdb_passwd = {
-	NULL,
+	NULL, NULL,
 	passwd_deinit,
 
 	passwd_verify_plain,

Index: passdb-pgsql.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-pgsql.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- passdb-pgsql.c	31 May 2004 18:57:25 -0000	1.5
+++ passdb-pgsql.c	20 Sep 2004 21:47:30 -0000	1.6
@@ -150,7 +150,7 @@
         pgsql_lookup_pass(request, &pgsql_request->request);
 }
 
-static void passdb_pgsql_init(const char *args)
+static void passdb_pgsql_preinit(const char *args)
 {
 	struct pgsql_connection *conn;
 
@@ -158,6 +158,11 @@
 	passdb_pgsql_conn->conn = conn = db_pgsql_init(args);
 }
 
+static void passdb_pgsql_init(const char *args __attr_unused__)
+{
+	(void)db_pgsql_connect(passdb_pgsql_conn->conn);
+}
+
 static void passdb_pgsql_deinit(void)
 {
 	db_pgsql_unref(passdb_pgsql_conn->conn);
@@ -165,6 +170,7 @@
 }
 
 struct passdb_module passdb_pgsql = {
+	passdb_pgsql_preinit,
 	passdb_pgsql_init,
 	passdb_pgsql_deinit,
 

Index: passdb-shadow.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-shadow.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- passdb-shadow.c	31 May 2004 18:57:25 -0000	1.7
+++ passdb-shadow.c	20 Sep 2004 21:47:30 -0000	1.8
@@ -62,7 +62,7 @@
 }
 
 struct passdb_module passdb_shadow = {
-	NULL,
+	NULL, NULL,
 	shadow_deinit,
 
 	shadow_verify_plain,

Index: passdb-vpopmail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-vpopmail.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- passdb-vpopmail.c	26 Jul 2004 15:42:52 -0000	1.8
+++ passdb-vpopmail.c	20 Sep 2004 21:47:30 -0000	1.9
@@ -98,7 +98,7 @@
 }
 
 struct passdb_module passdb_vpopmail = {
-	NULL,
+	NULL, NULL,
 	vpopmail_deinit,
 
 	vpopmail_verify_plain,

Index: passdb.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- passdb.c	19 Aug 2004 03:56:02 -0000	1.22
+++ passdb.c	20 Sep 2004 21:47:30 -0000	1.23
@@ -13,6 +13,7 @@
 #endif
 
 struct passdb_module *passdb;
+static char *passdb_args;
 
 static const char *
 passdb_credentials_to_str(enum passdb_credentials credentials)
@@ -98,7 +99,7 @@
 	}
 }
 
-void passdb_init(void)
+void passdb_preinit(void)
 {
 	const char *name, *args;
 
@@ -115,6 +116,8 @@
 	while (*args == ' ' || *args == '\t')
 		args++;
 
+	passdb_args = i_strdup(args);
+
 #ifdef PASSDB_PASSWD
 	if (strcasecmp(name, "passwd") == 0)
 		passdb = &passdb_passwd;
@@ -166,13 +169,18 @@
 	if (passdb == NULL)
 		i_fatal("Unknown passdb type '%s'", name);
 
-	/* initialize */
-	if (passdb->init != NULL)
-		passdb->init(args);
+	if (passdb->preinit != NULL)
+		passdb->preinit(passdb_args);
 
 	mech_list_verify_passdb(passdb, name);
 }
 
+void passdb_init(void)
+{
+	if (passdb->init != NULL)
+		passdb->init(passdb_args);
+}
+
 void passdb_deinit(void)
 {
 	if (passdb != NULL && passdb->deinit != NULL)
@@ -181,4 +189,5 @@
 	if (passdb_module != NULL)
                 auth_module_close(passdb_module);
 #endif
+	i_free(passdb_args);
 }

Index: passdb.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- passdb.h	19 Aug 2004 03:56:02 -0000	1.13
+++ passdb.h	20 Sep 2004 21:47:30 -0000	1.14
@@ -33,6 +33,7 @@
 					   struct auth_request *request);
 
 struct passdb_module {
+	void (*preinit)(const char *args);
 	void (*init)(const char *args);
 	void (*deinit)(void);
 
@@ -66,6 +67,7 @@
 extern struct passdb_module passdb_pgsql;
 extern struct passdb_module passdb_mysql;
 
+void passdb_preinit(void);
 void passdb_init(void);
 void passdb_deinit(void);
 

Index: userdb-ldap.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/userdb-ldap.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- userdb-ldap.c	24 May 2004 22:33:50 -0000	1.14
+++ userdb-ldap.c	20 Sep 2004 21:47:30 -0000	1.15
@@ -179,7 +179,7 @@
 		       &request->request);
 }
 
-static void userdb_ldap_init(const char *args)
+static void userdb_ldap_preinit(const char *args)
 {
 	struct ldap_connection *conn;
 
@@ -192,6 +192,11 @@
 			  &userdb_ldap_conn->attr_names);
 }
 
+static void userdb_ldap_init(const char *args __attr_unused__)
+{
+	(void)db_ldap_connect(userdb_ldap_conn->conn);
+}
+
 static void userdb_ldap_deinit(void)
 {
 	db_ldap_unref(userdb_ldap_conn->conn);
@@ -199,6 +204,7 @@
 }
 
 struct userdb_module userdb_ldap = {
+	userdb_ldap_preinit,
 	userdb_ldap_init,
 	userdb_ldap_deinit,
 

Index: userdb-mysql.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/userdb-mysql.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- userdb-mysql.c	24 May 2004 22:33:50 -0000	1.2
+++ userdb-mysql.c	20 Sep 2004 21:47:30 -0000	1.3
@@ -138,7 +138,7 @@
 	db_mysql_query(conn, query, &request->request);
 }
 
-static void userdb_mysql_init(const char *args)
+static void userdb_mysql_preinit(const char *args)
 {
 	struct mysql_connection *conn;
 
@@ -146,6 +146,11 @@
 	userdb_mysql_conn->conn = conn = db_mysql_init(args);
 }
 
+static void userdb_mysql_init(const char *args)
+{
+	(void)db_mysql_connect(userdb_mysql_conn->conn);
+}
+
 static void userdb_mysql_deinit(void)
 {
 	db_mysql_unref(userdb_mysql_conn->conn);
@@ -153,6 +158,7 @@
 }
 
 struct userdb_module userdb_mysql = {
+	userdb_mysql_preinit,
 	userdb_mysql_init,
 	userdb_mysql_deinit,
 

Index: userdb-passwd-file.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/userdb-passwd-file.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- userdb-passwd-file.c	31 May 2004 18:57:25 -0000	1.8
+++ userdb-passwd-file.c	20 Sep 2004 21:47:31 -0000	1.9
@@ -54,6 +54,7 @@
 }
 
 struct userdb_module userdb_passwd_file = {
+	NULL,
 	passwd_file_init,
 	passwd_file_deinit,
 

Index: userdb-passwd.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/userdb-passwd.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- userdb-passwd.c	31 May 2004 18:57:25 -0000	1.9
+++ userdb-passwd.c	20 Sep 2004 21:47:31 -0000	1.10
@@ -37,7 +37,7 @@
 }
 
 struct userdb_module userdb_passwd = {
-	NULL, NULL,
+	NULL, NULL, NULL,
 	passwd_lookup
 };
 

Index: userdb-pgsql.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/userdb-pgsql.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- userdb-pgsql.c	24 May 2004 22:33:50 -0000	1.6
+++ userdb-pgsql.c	20 Sep 2004 21:47:31 -0000	1.7
@@ -108,7 +108,7 @@
 	db_pgsql_query(conn, query, &request->request);
 }
 
-static void userdb_pgsql_init(const char *args)
+static void userdb_pgsql_preinit(const char *args)
 {
 	struct pgsql_connection *conn;
 
@@ -116,6 +116,11 @@
 	userdb_pgsql_conn->conn = conn = db_pgsql_init(args);
 }
 
+static void userdb_pgsql_init(const char *args __attr_unused__)
+{
+	(void)db_pgsql_connect(userdb_pgsql_conn->conn);
+}
+
 static void userdb_pgsql_deinit(void)
 {
 	db_pgsql_unref(userdb_pgsql_conn->conn);
@@ -123,6 +128,7 @@
 }
 
 struct userdb_module userdb_pgsql = {
+	userdb_pgsql_preinit,
 	userdb_pgsql_init,
 	userdb_pgsql_deinit,
 

Index: userdb-static.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/userdb-static.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- userdb-static.c	28 Aug 2004 20:07:39 -0000	1.7
+++ userdb-static.c	20 Sep 2004 21:47:31 -0000	1.8
@@ -84,6 +84,7 @@
 }
 
 struct userdb_module userdb_static = {
+	NULL,
 	static_init,
 	static_deinit,
 

Index: userdb-vpopmail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/userdb-vpopmail.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- userdb-vpopmail.c	24 May 2004 22:33:50 -0000	1.9
+++ userdb-vpopmail.c	20 Sep 2004 21:47:31 -0000	1.10
@@ -106,7 +106,7 @@
 }
 
 struct userdb_module userdb_vpopmail = {
-	NULL, NULL,
+	NULL, NULL, NULL,
 	vpopmail_lookup
 };
 

Index: userdb.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/userdb.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- userdb.c	23 Jun 2004 17:47:06 -0000	1.10
+++ userdb.c	20 Sep 2004 21:47:31 -0000	1.11
@@ -11,8 +11,9 @@
 #endif
 
 struct userdb_module *userdb;
+static char *userdb_args;
 
-void userdb_init(void)
+void userdb_preinit(void)
 {
 	const char *name, *args;
 
@@ -29,6 +30,8 @@
 	while (*args == ' ' || *args == '\t')
 		args++;
 
+	userdb_args = i_strdup(args);
+
 #ifdef USERDB_PASSWD
 	if (strcasecmp(name, "passwd") == 0)
 		userdb = &userdb_passwd;
@@ -68,9 +71,14 @@
 	if (userdb == NULL)
 		i_fatal("Unknown userdb type '%s'", name);
 
-	/* initialize */
+	if (userdb->preinit != NULL)
+		userdb->preinit(args);
+}
+
+void userdb_init(void)
+{
 	if (userdb->init != NULL)
-		userdb->init(args);
+		userdb->init(userdb_args);
 }
 
 void userdb_deinit(void)
@@ -81,4 +89,5 @@
 	if (userdb_module != NULL)
                 auth_module_close(userdb_module);
 #endif
+	i_free(userdb_args);
 }

Index: userdb.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/userdb.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- userdb.h	24 May 2004 22:33:50 -0000	1.9
+++ userdb.h	20 Sep 2004 21:47:31 -0000	1.10
@@ -16,6 +16,7 @@
 typedef void userdb_callback_t(struct user_data *user, void *context);
 
 struct userdb_module {
+	void (*preinit)(const char *args);
 	void (*init)(const char *args);
 	void (*deinit)(void);
 
@@ -33,6 +34,7 @@
 extern struct userdb_module userdb_pgsql;
 extern struct userdb_module userdb_mysql;
 
+void userdb_preinit(void);
 void userdb_init(void);
 void userdb_deinit(void);
 



More information about the dovecot-cvs mailing list