[dovecot-cvs] dovecot/src/auth passdb-bsdauth.c, 1.4, 1.5 passdb-checkpassword.c, 1.3, 1.4 passdb-ldap.c, 1.13, 1.14 passdb-pam.c, 1.18, 1.19 passdb-passwd-file.c, 1.11, 1.12 passdb-passwd.c, 1.7, 1.8 passdb-shadow.c, 1.8, 1.9 passdb-sql.c, 1.7, 1.8 passdb-vpopmail.c, 1.11, 1.12 passdb.c, 1.25, 1.26 passdb.h, 1.16, 1.17 userdb-ldap.c, 1.16, 1.17 userdb-passwd-file.c, 1.9, 1.10 userdb-passwd.c, 1.10, 1.11 userdb-sql.c, 1.2, 1.3 userdb-static.c, 1.8, 1.9 userdb-vpopmail.c, 1.10, 1.11 userdb.c, 1.12, 1.13 userdb.h, 1.12, 1.13

cras at dovecot.org cras at dovecot.org
Mon Dec 6 18:39:05 EET 2004


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

Modified Files:
	passdb-bsdauth.c passdb-checkpassword.c passdb-ldap.c 
	passdb-pam.c passdb-passwd-file.c passdb-passwd.c 
	passdb-shadow.c passdb-sql.c passdb-vpopmail.c passdb.c 
	passdb.h userdb-ldap.c userdb-passwd-file.c userdb-passwd.c 
	userdb-sql.c userdb-static.c userdb-vpopmail.c userdb.c 
	userdb.h 
Log Message:
Added name variable for userdb_module and passdb_module and changed their
initialization a bit.



Index: passdb-bsdauth.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-bsdauth.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- passdb-bsdauth.c	20 Sep 2004 21:47:30 -0000	1.4
+++ passdb-bsdauth.c	6 Dec 2004 16:39:02 -0000	1.5
@@ -65,6 +65,8 @@
 }
 
 struct passdb_module passdb_bsdauth = {
+	"bsdauth",
+
 	NULL, NULL,
 	bsdauth_deinit,
 

Index: passdb-checkpassword.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-checkpassword.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- passdb-checkpassword.c	8 Oct 2004 17:51:47 -0000	1.3
+++ passdb-checkpassword.c	6 Dec 2004 16:39:02 -0000	1.4
@@ -317,6 +317,8 @@
 }
 
 struct passdb_module passdb_checkpassword = {
+	"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.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- passdb-ldap.c	1 Nov 2004 13:31:00 -0000	1.13
+++ passdb-ldap.c	6 Dec 2004 16:39:02 -0000	1.14
@@ -253,6 +253,8 @@
 }
 
 struct passdb_module passdb_ldap = {
+	"ldap",
+
 	passdb_ldap_preinit,
 	passdb_ldap_init,
 	passdb_ldap_deinit,

Index: passdb-pam.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-pam.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- passdb-pam.c	19 Oct 2004 02:51:37 -0000	1.18
+++ passdb-pam.c	6 Dec 2004 16:39:02 -0000	1.19
@@ -404,6 +404,8 @@
 }
 
 struct passdb_module passdb_pam = {
+	"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.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- passdb-passwd-file.c	21 Oct 2004 02:23:12 -0000	1.11
+++ passdb-passwd-file.c	6 Dec 2004 16:39:02 -0000	1.12
@@ -83,6 +83,8 @@
 }
 
 struct passdb_module passdb_passwd_file = {
+	"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.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- passdb-passwd.c	20 Sep 2004 21:47:30 -0000	1.7
+++ passdb-passwd.c	6 Dec 2004 16:39:02 -0000	1.8
@@ -62,6 +62,8 @@
 }
 
 struct passdb_module passdb_passwd = {
+	"passwd",
+
 	NULL, NULL,
 	passwd_deinit,
 

Index: passdb-shadow.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-shadow.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- passdb-shadow.c	20 Sep 2004 21:47:30 -0000	1.8
+++ passdb-shadow.c	6 Dec 2004 16:39:02 -0000	1.9
@@ -62,6 +62,8 @@
 }
 
 struct passdb_module passdb_shadow = {
+	"shadow",
+
 	NULL, NULL,
 	shadow_deinit,
 

Index: passdb-sql.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-sql.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- passdb-sql.c	1 Nov 2004 13:31:00 -0000	1.7
+++ passdb-sql.c	6 Dec 2004 16:39:02 -0000	1.8
@@ -213,6 +213,8 @@
 }
 
 struct passdb_module passdb_sql = {
+	"sql",
+
 	passdb_sql_preinit,
 	passdb_sql_init,
 	passdb_sql_deinit,

Index: passdb-vpopmail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-vpopmail.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- passdb-vpopmail.c	19 Oct 2004 02:51:37 -0000	1.11
+++ passdb-vpopmail.c	6 Dec 2004 16:39:02 -0000	1.12
@@ -97,6 +97,8 @@
 }
 
 struct passdb_module passdb_vpopmail = {
+	"vpopmail",
+
 	NULL, NULL,
 	vpopmail_deinit,
 

Index: passdb.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- passdb.c	21 Oct 2004 02:23:12 -0000	1.25
+++ passdb.c	6 Dec 2004 16:39:02 -0000	1.26
@@ -13,6 +13,37 @@
 static struct auth_module *passdb_module = NULL;
 #endif
 
+struct passdb_module *passdbs[] = {
+#ifdef PASSDB_PASSWD
+	&passdb_passwd,
+#endif
+#ifdef PASSDB_BSDAUTH
+	&passdb_bsdauth,
+#endif
+#ifdef PASSDB_PASSWD_FILE
+	&passdb_passwd_file,
+#endif
+#ifdef PASSDB_PAM
+	&passdb_pam,
+#endif
+#ifdef PASSDB_CHECKPASSWORD
+	&passdb_checkpassword,
+#endif
+#ifdef PASSDB_SHADOW
+	&passdb_shadow,
+#endif
+#ifdef PASSDB_VPOPMAIL
+	&passdb_vpopmail,
+#endif
+#ifdef PASSDB_LDAP
+	&passdb_ldap,
+#endif
+#ifdef PASSDB_SQL
+	&passdb_sql,
+#endif
+	NULL
+};
+
 struct passdb_module *passdb;
 static char *passdb_args;
 
@@ -81,8 +112,7 @@
 	callback(password, auth_request);
 }
 
-static void
-mech_list_verify_passdb(struct passdb_module *passdb, const char *name)
+static void mech_list_verify_passdb(struct passdb_module *passdb)
 {
 	struct mech_module_list *list;
 
@@ -97,16 +127,15 @@
 
 	if (list != NULL) {
 		i_fatal("Passdb %s doesn't support %s method",
-			name, list->module.mech_name);
+			passdb->name, list->module.mech_name);
 	}
 }
 
 void passdb_preinit(void)
 {
+	struct passdb_module **p;
 	const char *name, *args;
 
-	passdb = NULL;
-
 	name = getenv("PASSDB");
 	if (name == NULL)
 		i_fatal("PASSDB environment is unset");
@@ -120,42 +149,14 @@
 
 	passdb_args = i_strdup(args);
 
-#ifdef PASSDB_PASSWD
-	if (strcasecmp(name, "passwd") == 0)
-		passdb = &passdb_passwd;
-#endif
-#ifdef PASSDB_BSDAUTH
-	if (strcasecmp(name, "bsdauth") == 0)
-		passdb = &passdb_bsdauth;
-#endif
-#ifdef PASSDB_PASSWD_FILE
-	if (strcasecmp(name, "passwd-file") == 0)
-		passdb = &passdb_passwd_file;
-#endif
-#ifdef PASSDB_PAM
-	if (strcasecmp(name, "pam") == 0)
-		passdb = &passdb_pam;
-#endif
-#ifdef PASSDB_CHECKPASSWORD
-	if (strcasecmp(name, "checkpassword") == 0)
-		passdb = &passdb_checkpassword;
-#endif
-#ifdef PASSDB_SHADOW
-	if (strcasecmp(name, "shadow") == 0)
-		passdb = &passdb_shadow;
-#endif
-#ifdef PASSDB_VPOPMAIL
-	if (strcasecmp(name, "vpopmail") == 0)
-		passdb = &passdb_vpopmail;
-#endif
-#ifdef PASSDB_LDAP
-	if (strcasecmp(name, "ldap") == 0)
-		passdb = &passdb_ldap;
-#endif
-#ifdef PASSDB_SQL
-	if (strcasecmp(name, "sql") == 0)
-		passdb = &passdb_sql;
-#endif
+	passdb = NULL;
+	for (p = passdbs; *p != NULL; p++) {
+		if (strcmp((*p)->name, name) == 0) {
+			passdb = *p;
+			break;
+		}
+	}
+	
 #ifdef HAVE_MODULES
 	passdb_module = passdb != NULL ? NULL : auth_module_open(name);
 	if (passdb_module != NULL) {
@@ -170,7 +171,7 @@
 	if (passdb->preinit != NULL)
 		passdb->preinit(passdb_args);
 
-	mech_list_verify_passdb(passdb, name);
+	mech_list_verify_passdb(passdb);
 }
 
 void passdb_init(void)

Index: passdb.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- passdb.h	21 Oct 2004 02:23:12 -0000	1.16
+++ passdb.h	6 Dec 2004 16:39:02 -0000	1.17
@@ -33,6 +33,8 @@
 					   struct auth_request *request);
 
 struct passdb_module {
+	const char *name;
+
 	void (*preinit)(const char *args);
 	void (*init)(const char *args);
 	void (*deinit)(void);

Index: userdb-ldap.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/userdb-ldap.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- userdb-ldap.c	1 Nov 2004 13:34:36 -0000	1.16
+++ userdb-ldap.c	6 Dec 2004 16:39:02 -0000	1.17
@@ -208,6 +208,8 @@
 }
 
 struct userdb_module userdb_ldap = {
+	"ldap",
+
 	userdb_ldap_preinit,
 	userdb_ldap_init,
 	userdb_ldap_deinit,

Index: userdb-passwd-file.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/userdb-passwd-file.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- userdb-passwd-file.c	20 Sep 2004 21:47:31 -0000	1.9
+++ userdb-passwd-file.c	6 Dec 2004 16:39:02 -0000	1.10
@@ -54,6 +54,8 @@
 }
 
 struct userdb_module userdb_passwd_file = {
+	"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.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- userdb-passwd.c	20 Sep 2004 21:47:31 -0000	1.10
+++ userdb-passwd.c	6 Dec 2004 16:39:02 -0000	1.11
@@ -37,6 +37,8 @@
 }
 
 struct userdb_module userdb_passwd = {
+	"passwd",
+
 	NULL, NULL, NULL,
 	passwd_lookup
 };

Index: userdb-sql.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/userdb-sql.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- userdb-sql.c	1 Nov 2004 13:34:36 -0000	1.2
+++ userdb-sql.c	6 Dec 2004 16:39:02 -0000	1.3
@@ -107,6 +107,8 @@
 }
 
 struct userdb_module userdb_sql = {
+	"sql",
+
 	userdb_sql_preinit,
 	userdb_sql_init,
 	userdb_sql_deinit,

Index: userdb-static.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/userdb-static.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- userdb-static.c	20 Sep 2004 21:47:31 -0000	1.8
+++ userdb-static.c	6 Dec 2004 16:39:02 -0000	1.9
@@ -84,6 +84,8 @@
 }
 
 struct userdb_module userdb_static = {
+	"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.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- userdb-vpopmail.c	20 Sep 2004 21:47:31 -0000	1.10
+++ userdb-vpopmail.c	6 Dec 2004 16:39:02 -0000	1.11
@@ -106,6 +106,8 @@
 }
 
 struct userdb_module userdb_vpopmail = {
+	"vpopmail",
+
 	NULL, NULL, NULL,
 	vpopmail_lookup
 };

Index: userdb.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/userdb.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- userdb.c	15 Oct 2004 23:12:52 -0000	1.12
+++ userdb.c	6 Dec 2004 16:39:02 -0000	1.13
@@ -10,15 +10,36 @@
 static struct auth_module *userdb_module = NULL;
 #endif
 
+struct userdb_module *userdbs[] = {
+#ifdef USERDB_PASSWD
+	&userdb_passwd,
+#endif
+#ifdef USERDB_PASSWD_FILE
+	&userdb_passwd_file,
+#endif
+#ifdef USERDB_STATIC
+	&userdb_static,
+#endif
+#ifdef USERDB_VPOPMAIL
+	&userdb_vpopmail,
+#endif
+#ifdef USERDB_LDAP
+	&userdb_ldap,
+#endif
+#ifdef USERDB_SQL
+	&userdb_sql,
+#endif
+	NULL
+};
+
 struct userdb_module *userdb;
 static char *userdb_args;
 
 void userdb_preinit(void)
 {
+	struct userdb_module **p;
 	const char *name, *args;
 
-	userdb = NULL;
-
 	name = getenv("USERDB");
 	if (name == NULL)
 		i_fatal("USERDB environment is unset");
@@ -32,30 +53,13 @@
 
 	userdb_args = i_strdup(args);
 
-#ifdef USERDB_PASSWD
-	if (strcasecmp(name, "passwd") == 0)
-		userdb = &userdb_passwd;
-#endif
-#ifdef USERDB_PASSWD_FILE
-	if (strcasecmp(name, "passwd-file") == 0)
-		userdb = &userdb_passwd_file;
-#endif
-#ifdef USERDB_STATIC
-	if (strcasecmp(name, "static") == 0)
-		userdb = &userdb_static;
-#endif
-#ifdef USERDB_VPOPMAIL
-	if (strcasecmp(name, "vpopmail") == 0)
-		userdb = &userdb_vpopmail;
-#endif
-#ifdef USERDB_LDAP
-	if (strcasecmp(name, "ldap") == 0)
-		userdb = &userdb_ldap;
-#endif
-#ifdef USERDB_SQL
-	if (strcasecmp(name, "sql") == 0)
-		userdb = &userdb_sql;
-#endif
+	userdb = NULL;
+	for (p = userdbs; *p != NULL; p++) {
+		if (strcmp((*p)->name, name) == 0) {
+			userdb = *p;
+			break;
+		}
+	}
 #ifdef HAVE_MODULES
 	userdb_module = userdb != NULL ? NULL : auth_module_open(name);
 	if (userdb_module != NULL) {

Index: userdb.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/userdb.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- userdb.h	15 Oct 2004 23:12:52 -0000	1.12
+++ userdb.h	6 Dec 2004 16:39:02 -0000	1.13
@@ -16,6 +16,8 @@
 typedef void userdb_callback_t(const struct user_data *user, void *context);
 
 struct userdb_module {
+	const char *name;
+
 	void (*preinit)(const char *args);
 	void (*init)(const char *args);
 	void (*deinit)(void);



More information about the dovecot-cvs mailing list