[dovecot-cvs] dovecot/src/master auth-process.c, 1.77, 1.78 master-settings.c, 1.82, 1.83 master-settings.h, 1.55, 1.56

cras at dovecot.org cras at dovecot.org
Mon Mar 7 20:55:18 EET 2005


Update of /var/lib/cvs/dovecot/src/master
In directory talvi:/tmp/cvs-serv539/src/master

Modified Files:
	auth-process.c master-settings.c master-settings.h 
Log Message:
Replaced userdb/passdb settings with blocks so it's possible to give
multiple ones. Plaintext password mechanisms now support handling multiple
passdbs, but others don't yet. Also fixed a few memory leaks.



Index: auth-process.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/master/auth-process.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- auth-process.c	28 Feb 2005 22:19:21 -0000	1.77
+++ auth-process.c	7 Mar 2005 18:55:15 -0000	1.78
@@ -397,6 +397,8 @@
 static void auth_set_environment(struct auth_settings *set)
 {
 	struct auth_socket_settings *as;
+	struct auth_passdb_settings *ap;
+	struct auth_userdb_settings *au;
 	const char *str;
 	int i;
 
@@ -410,8 +412,6 @@
 	env_put(t_strconcat("MECHANISMS=", set->mechanisms, NULL));
 	env_put(t_strconcat("REALMS=", set->realms, NULL));
 	env_put(t_strconcat("DEFAULT_REALM=", set->default_realm, NULL));
-	env_put(t_strconcat("USERDB=", set->userdb, NULL));
-	env_put(t_strconcat("PASSDB=", set->passdb, NULL));
 	env_put(t_strconcat("USERNAME_CHARS=", set->username_chars, NULL));
 	env_put(t_strconcat("USERNAME_TRANSLATION=",
 			    set->username_translation, NULL));
@@ -420,6 +420,15 @@
 	env_put(t_strdup_printf("CACHE_SIZE=%u", set->cache_size));
 	env_put(t_strdup_printf("CACHE_TTL=%u", set->cache_ttl));
 
+	for (ap = set->passdbs, i = 1; ap != NULL; ap = ap->next, i++) {
+		env_put(t_strdup_printf("PASSDB_%u_DRIVER=%s", i, ap->driver));
+		env_put(t_strdup_printf("PASSDB_%u_ARGS=%s", i, ap->args));
+	}
+	for (au = set->userdbs, i = 1; au != NULL; au = au->next, i++) {
+		env_put(t_strdup_printf("USERDB_%u_DRIVER=%s", i, au->driver));
+		env_put(t_strdup_printf("USERDB_%u_ARGS=%s", i, au->args));
+	}
+
 	for (as = set->sockets, i = 1; as != NULL; as = as->next, i++) {
 		if (strcmp(as->type, "listen") != 0)
 			continue;

Index: master-settings.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/master/master-settings.c,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -d -r1.82 -r1.83
--- master-settings.c	28 Feb 2005 22:19:21 -0000	1.82
+++ master-settings.c	7 Mar 2005 18:55:15 -0000	1.83
@@ -17,6 +17,8 @@
 	SETTINGS_TYPE_SERVER,
 	SETTINGS_TYPE_AUTH,
 	SETTINGS_TYPE_AUTH_SOCKET,
+	SETTINGS_TYPE_AUTH_PASSDB,
+	SETTINGS_TYPE_AUTH_USERDB,
         SETTINGS_TYPE_NAMESPACE,
 	SETTINGS_TYPE_SOCKET
 };
@@ -29,6 +31,8 @@
 	struct auth_settings *auth;
 	struct socket_settings *socket;
 	struct auth_socket_settings *auth_socket;
+	struct auth_passdb_settings *auth_passdb;
+	struct auth_userdb_settings *auth_userdb;
         struct namespace_settings *namespace;
 
 	int level;
@@ -139,8 +143,6 @@
 	DEF(SET_STR, mechanisms),
 	DEF(SET_STR, realms),
 	DEF(SET_STR, default_realm),
-	DEF(SET_STR, userdb),
-	DEF(SET_STR, passdb),
 	DEF(SET_INT, cache_size),
 	DEF(SET_INT, cache_ttl),
 	DEF(SET_STR, executable),
@@ -186,6 +188,28 @@
 
 #undef DEF
 #define DEF(type, name) \
+	{ type, #name, offsetof(struct auth_passdb_settings, name) }
+
+static struct setting_def auth_passdb_setting_defs[] = {
+	DEF(SET_STR, driver),
+	DEF(SET_STR, args),
+
+	{ 0, NULL, 0 }
+};
+
+#undef DEF
+#define DEF(type, name) \
+	{ type, #name, offsetof(struct auth_userdb_settings, name) }
+
+static struct setting_def auth_userdb_setting_defs[] = {
+	DEF(SET_STR, driver),
+	DEF(SET_STR, args),
+
+	{ 0, NULL, 0 }
+};
+
+#undef DEF
+#define DEF(type, name) \
 	{ type, #name, offsetof(struct namespace_settings, name) }
 
 static struct setting_def namespace_setting_defs[] = {
@@ -315,8 +339,6 @@
 	MEMBER(mechanisms) "plain",
 	MEMBER(realms) NULL,
 	MEMBER(default_realm) NULL,
-	MEMBER(userdb) "passwd",
-	MEMBER(passdb) "pam",
 	MEMBER(cache_size) 0,
 	MEMBER(cache_ttl) 3600,
 	MEMBER(executable) PKG_LIBEXECDIR"/dovecot-auth",
@@ -337,6 +359,8 @@
 	/* .. */
 	MEMBER(uid) 0,
 	MEMBER(gid) 0,
+	MEMBER(passdbs) NULL,
+	MEMBER(userdbs) NULL,
 	MEMBER(sockets) NULL
 };
 
@@ -646,6 +670,42 @@
 	return auth_settings_new(server, name);
 }
 
+static struct auth_passdb_settings *
+auth_passdb_settings_new(struct auth_settings *auth, const char *type)
+{
+	struct auth_passdb_settings *as, **as_p;
+
+	as = p_new(settings_pool, struct auth_passdb_settings, 1);
+
+	as->parent = auth;
+	as->driver = str_lcase(p_strdup(settings_pool, type));
+
+	as_p = &auth->passdbs;
+	while (*as_p != NULL)
+		as_p = &(*as_p)->next;
+	*as_p = as;
+
+	return as;
+}
+
+static struct auth_userdb_settings *
+auth_userdb_settings_new(struct auth_settings *auth, const char *type)
+{
+	struct auth_userdb_settings *as, **as_p;
+
+	as = p_new(settings_pool, struct auth_userdb_settings, 1);
+
+	as->parent = auth;
+	as->driver = str_lcase(p_strdup(settings_pool, type));
+
+	as_p = &auth->userdbs;
+	while (*as_p != NULL)
+		as_p = &(*as_p)->next;
+	*as_p = as;
+
+	return as;
+}
+
 static struct auth_socket_settings *
 auth_socket_settings_new(struct auth_settings *auth, const char *type)
 {
@@ -775,6 +835,14 @@
 		return parse_setting_from_defs(settings_pool,
 					       auth_socket_setting_defs,
 					       ctx->auth_socket, key, value);
+	case SETTINGS_TYPE_AUTH_PASSDB:
+		return parse_setting_from_defs(settings_pool,
+					       auth_passdb_setting_defs,
+					       ctx->auth_passdb, key, value);
+	case SETTINGS_TYPE_AUTH_USERDB:
+		return parse_setting_from_defs(settings_pool,
+					       auth_userdb_setting_defs,
+					       ctx->auth_userdb, key, value);
 	case SETTINGS_TYPE_NAMESPACE:
 		return parse_setting_from_defs(settings_pool,
 					       namespace_setting_defs,
@@ -906,6 +974,18 @@
 		return ctx->auth_socket != NULL;
 	}
 
+	if (ctx->type == SETTINGS_TYPE_AUTH && strcmp(type, "passdb") == 0) {
+		ctx->type = SETTINGS_TYPE_AUTH_PASSDB;
+		ctx->auth_passdb = auth_passdb_settings_new(ctx->auth, name);
+		return TRUE;
+	}
+
+	if (ctx->type == SETTINGS_TYPE_AUTH && strcmp(type, "userdb") == 0) {
+		ctx->type = SETTINGS_TYPE_AUTH_USERDB;
+		ctx->auth_userdb = auth_userdb_settings_new(ctx->auth, name);
+		return TRUE;
+	}
+
 	if (ctx->type == SETTINGS_TYPE_AUTH_SOCKET) {
 		ctx->type = SETTINGS_TYPE_SOCKET;
 

Index: master-settings.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/master/master-settings.h,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- master-settings.h	5 Mar 2005 20:02:07 -0000	1.55
+++ master-settings.h	7 Mar 2005 18:55:15 -0000	1.56
@@ -125,6 +125,22 @@
         struct socket_settings client;
 };
 
+struct auth_passdb_settings {
+	struct auth_settings *parent;
+	struct auth_passdb_settings *next;
+
+	const char *driver;
+	const char *args;
+};
+
+struct auth_userdb_settings {
+	struct auth_settings *parent;
+	struct auth_userdb_settings *next;
+
+	const char *driver;
+	const char *args;
+};
+
 struct auth_settings {
 	struct server_settings *parent;
 	struct auth_settings *next;
@@ -133,8 +149,6 @@
 	const char *mechanisms;
 	const char *realms;
 	const char *default_realm;
-	const char *userdb;
-	const char *passdb;
 	unsigned int cache_size;
 	unsigned int cache_ttl;
 	const char *executable;
@@ -154,6 +168,8 @@
 	/* .. */
 	uid_t uid;
 	gid_t gid;
+        struct auth_passdb_settings *passdbs;
+        struct auth_userdb_settings *userdbs;
 	struct auth_socket_settings *sockets;
 };
 



More information about the dovecot-cvs mailing list