dovecot-1.3: mail_storage_service_init*() can now take multiple ...

dovecot at dovecot.org dovecot at dovecot.org
Wed Apr 15 19:40:23 EEST 2009


details:   http://hg.dovecot.org/dovecot-1.3/rev/fce3926fe910
changeset: 9106:fce3926fe910
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Apr 15 12:40:16 2009 -0400
description:
mail_storage_service_init*() can now take multiple set_roots.

diffstat:

5 files changed, 32 insertions(+), 17 deletions(-)
src/imap/main.c                        |    7 +++++--
src/lda/main.c                         |    8 ++++++--
src/lib-storage/mail-storage-service.c |   23 ++++++++++++++---------
src/lib-storage/mail-storage-service.h |    4 ++--
src/pop3/main.c                        |    7 +++++--

diffs (166 lines):

diff -r fdbc1902b4a9 -r fce3926fe910 src/imap/main.c
--- a/src/imap/main.c	Wed Apr 15 12:33:37 2009 -0400
+++ b/src/imap/main.c	Wed Apr 15 12:40:16 2009 -0400
@@ -134,6 +134,10 @@ static void main_deinit(void)
 
 int main(int argc, char *argv[], char *envp[])
 {
+	const struct setting_parser_info *set_roots[] = {
+		&imap_setting_parser_info,
+		NULL
+	};
 	enum master_service_flags service_flags = 0;
 	enum mail_storage_service_flags storage_service_flags = 0;
 	struct mail_user *mail_user;
@@ -178,8 +182,7 @@ int main(int argc, char *argv[], char *e
 			i_fatal("USER environment missing");
 	}
 
-	mail_user = mail_storage_service_init_user(service, user,
-						   &imap_setting_parser_info,
+	mail_user = mail_storage_service_init_user(service, user, set_roots,
 						   storage_service_flags);
 	set = mail_storage_service_get_settings(service);
 	restrict_access_allow_coredumps(TRUE);
diff -r fdbc1902b4a9 -r fce3926fe910 src/lda/main.c
--- a/src/lda/main.c	Wed Apr 15 12:33:37 2009 -0400
+++ b/src/lda/main.c	Wed Apr 15 12:40:16 2009 -0400
@@ -176,6 +176,10 @@ static void print_help(void)
 
 int main(int argc, char *argv[])
 {
+	const struct setting_parser_info *set_roots[] = {
+		&lda_setting_parser_info,
+		NULL
+	};
 	struct mail_deliver_context ctx;
 	enum mail_storage_service_flags service_flags = 0;
 	const char *user, *errstr, *path, *getopt_str;
@@ -314,8 +318,8 @@ int main(int argc, char *argv[])
 	}
 
 	service_flags |= MAIL_STORAGE_SERVICE_FLAG_DISALLOW_ROOT;
-	ctx.dest_user = mail_storage_service_init_user(service, user,
-				&lda_setting_parser_info, service_flags);
+	ctx.dest_user = mail_storage_service_init_user(service, user, set_roots,
+						       service_flags);
 	ctx.set = mail_storage_service_get_settings(service);
         duplicate_init(mail_user_set_get_storage_set(ctx.dest_user->set));
 
diff -r fdbc1902b4a9 -r fce3926fe910 src/lib-storage/mail-storage-service.c
--- a/src/lib-storage/mail-storage-service.c	Wed Apr 15 12:33:37 2009 -0400
+++ b/src/lib-storage/mail-storage-service.c	Wed Apr 15 12:40:16 2009 -0400
@@ -282,11 +282,13 @@ service_drop_privileges(const struct mai
 
 static void
 mail_storage_service_init_settings(struct master_service *service,
-				   const struct setting_parser_info *set_root,
+				   const struct setting_parser_info *set_roots[],
 				   bool preserve_home)
 {
-	const struct setting_parser_info *set_roots[3];
+	ARRAY_DEFINE(all_set_roots, const struct setting_parser_info *);
+	const struct setting_parser_info *info = &mail_user_setting_parser_info;
 	const char *error;
+	unsigned int i;
 
 	(void)umask(0077);
 
@@ -294,12 +296,15 @@ mail_storage_service_init_settings(struc
 	mail_storage_register_all();
 	mailbox_list_register_all();
 
-	set_roots[0] = &mail_user_setting_parser_info;
-	set_roots[1] = set_root;
-	set_roots[2] = NULL;
+	t_array_init(&all_set_roots, 5);
+	array_append(&all_set_roots, &info, 1);
+	for (i = 0; set_roots[i] != NULL; i++)
+		array_append(&all_set_roots, &set_roots[i], 1);
+	(void)array_append_space(&all_set_roots);
 
 	/* read settings after registering storages so they can have their
 	   own setting definitions too */
+	set_roots = array_idx_modifiable(&all_set_roots, 0);
 	if (master_service_settings_read(service, set_roots,
 					 mail_storage_get_dynamic_parsers(),
 					 preserve_home, &error) < 0)
@@ -395,7 +400,7 @@ user_expand_varstr(struct master_service
 
 struct mail_user *
 mail_storage_service_init_user(struct master_service *service, const char *user,
-			       const struct setting_parser_info *set_root,
+			       const struct setting_parser_info *set_roots[],
 			       enum mail_storage_service_flags flags)
 {
 	const struct master_service_settings *set;
@@ -408,7 +413,7 @@ mail_storage_service_init_user(struct ma
 	bool userdb_lookup;
 
 	userdb_lookup = (flags & MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP) != 0;
-	mail_storage_service_init_settings(service, set_root, !userdb_lookup);
+	mail_storage_service_init_settings(service, set_roots, !userdb_lookup);
 
 	if ((flags & MAIL_STORAGE_SERVICE_FLAG_DEBUG) != 0)
 		set_keyval(service, "mail_debug", "yes");
@@ -484,7 +489,7 @@ void mail_storage_service_deinit_user(vo
 
 struct mail_storage_service_multi_ctx *
 mail_storage_service_multi_init(struct master_service *service,
-				const struct setting_parser_info *set_root,
+				const struct setting_parser_info *set_roots[],
 				enum mail_storage_service_flags flags)
 {
 	struct mail_storage_service_multi_ctx *ctx;
@@ -497,7 +502,7 @@ mail_storage_service_multi_init(struct m
 	ctx->service = service;
 	ctx->flags = flags;
 
-	mail_storage_service_init_settings(service, set_root, FALSE);
+	mail_storage_service_init_settings(service, set_roots, FALSE);
 
 	/* do all the global initialization. delay initializing plugins until
 	   we drop privileges the first time. */
diff -r fdbc1902b4a9 -r fce3926fe910 src/lib-storage/mail-storage-service.h
--- a/src/lib-storage/mail-storage-service.h	Wed Apr 15 12:33:37 2009 -0400
+++ b/src/lib-storage/mail-storage-service.h	Wed Apr 15 12:40:16 2009 -0400
@@ -16,13 +16,13 @@ struct setting_parser_info;
 
 struct mail_user *
 mail_storage_service_init_user(struct master_service *service, const char *user,
-			       const struct setting_parser_info *set_root,
+			       const struct setting_parser_info *set_roots[],
 			       enum mail_storage_service_flags flags);
 void mail_storage_service_deinit_user(void);
 
 struct mail_storage_service_multi_ctx *
 mail_storage_service_multi_init(struct master_service *service,
-				const struct setting_parser_info *set_root,
+				const struct setting_parser_info *set_roots[],
 				enum mail_storage_service_flags flags);
 /* Returns 1 if ok, 0 if user wasn't found, -1 if error. */
 int mail_storage_service_multi_next(struct mail_storage_service_multi_ctx *ctx,
diff -r fdbc1902b4a9 -r fce3926fe910 src/pop3/main.c
--- a/src/pop3/main.c	Wed Apr 15 12:33:37 2009 -0400
+++ b/src/pop3/main.c	Wed Apr 15 12:40:16 2009 -0400
@@ -139,6 +139,10 @@ static void main_deinit(void)
 
 int main(int argc, char *argv[], char *envp[])
 {
+	const struct setting_parser_info *set_roots[] = {
+		&pop3_setting_parser_info,
+		NULL
+	};
 	enum master_service_flags service_flags = 0;
 	enum mail_storage_service_flags storage_service_flags =
 		MAIL_STORAGE_SERVICE_FLAG_DISALLOW_ROOT;
@@ -176,8 +180,7 @@ int main(int argc, char *argv[], char *e
 			i_fatal("USER environment missing");
 	}
 
-	mail_user = mail_storage_service_init_user(service, user,
-						   &pop3_setting_parser_info,
+	mail_user = mail_storage_service_init_user(service, user, set_roots,
 						   storage_service_flags);
 	set = mail_storage_service_get_settings(service);
 	restrict_access_allow_coredumps(TRUE);


More information about the dovecot-cvs mailing list