dovecot-1.3: Added master_service_set().

dovecot at dovecot.org dovecot at dovecot.org
Mon Apr 13 19:36:40 EEST 2009


details:   http://hg.dovecot.org/dovecot-1.3/rev/ea2117eaa8d1
changeset: 9082:ea2117eaa8d1
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Apr 13 12:35:50 2009 -0400
description:
Added master_service_set().

diffstat:

3 files changed, 18 insertions(+), 12 deletions(-)
src/lib-master/master-service-settings.c |    5 +++++
src/lib-master/master-service-settings.h |    2 ++
src/lib-storage/mail-storage-service.c   |   23 +++++++++++------------

diffs (105 lines):

diff -r 0e10344711b8 -r ea2117eaa8d1 src/lib-master/master-service-settings.c
--- a/src/lib-master/master-service-settings.c	Sat Apr 11 23:50:34 2009 -0400
+++ b/src/lib-master/master-service-settings.c	Mon Apr 13 12:35:50 2009 -0400
@@ -142,3 +142,8 @@ void **master_service_settings_get_other
 {
 	return settings_parser_get_list(service->set_parser) + 1;
 }
+
+int master_service_set(struct master_service *service, const char *line)
+{
+	return settings_parse_line(service->set_parser, line);
+}
diff -r 0e10344711b8 -r ea2117eaa8d1 src/lib-master/master-service-settings.h
--- a/src/lib-master/master-service-settings.h	Sat Apr 11 23:50:34 2009 -0400
+++ b/src/lib-master/master-service-settings.h	Mon Apr 13 12:35:50 2009 -0400
@@ -20,4 +20,6 @@ master_service_settings_get(struct maste
 master_service_settings_get(struct master_service *service);
 void **master_service_settings_get_others(struct master_service *service);
 
+int master_service_set(struct master_service *service, const char *line);
+
 #endif
diff -r 0e10344711b8 -r ea2117eaa8d1 src/lib-storage/mail-storage-service.c
--- a/src/lib-storage/mail-storage-service.c	Sat Apr 11 23:50:34 2009 -0400
+++ b/src/lib-storage/mail-storage-service.c	Mon Apr 13 12:35:50 2009 -0400
@@ -31,14 +31,13 @@ struct mail_storage_service_multi_ctx {
 
 static struct module *modules = NULL;
 
-static void
-master_service_set(struct master_service *service,
-		   const char *key, const char *value)
+static void set_keyval(struct master_service *service,
+		       const char *key, const char *value)
 {
 	const char *str;
 
 	str = t_strconcat(key, "=", value, NULL);
-	if (settings_parse_line(service->set_parser, str) < 0) {
+	if (master_service_set(service, str) < 0) {
 		i_fatal("Invalid userdb input '%s': %s", str,
 			settings_parser_get_error(service->set_parser));
 	}
@@ -82,13 +81,13 @@ user_reply_handle(struct master_service 
 			*error_r = "userdb returned 0 as uid";
 			return -1;
 		}
-		master_service_set(service, "mail_uid", dec2str(reply->uid));
+		set_keyval(service, "mail_uid", dec2str(reply->uid));
 	}
 	if (reply->gid != (uid_t)-1)
-		master_service_set(service, "mail_gid", dec2str(reply->gid));
+		set_keyval(service, "mail_gid", dec2str(reply->gid));
 
 	if (reply->home != NULL)
-		master_service_set(service, "mail_home", reply->home);
+		set_keyval(service, "mail_home", reply->home);
 
 	if (reply->chroot != NULL) {
 		if (!validate_chroot(user_set, reply->chroot)) {
@@ -98,7 +97,7 @@ user_reply_handle(struct master_service 
 				reply->chroot);
 			return -1;
 		}
-		master_service_set(service, "mail_chroot", reply->chroot);
+		set_keyval(service, "mail_chroot", reply->chroot);
 	}
 
 	str = array_get(&reply->extra_fields, &count);
@@ -413,7 +412,7 @@ mail_storage_service_init_user(struct ma
 	mail_storage_service_init_settings(service, set_root, !userdb_lookup);
 
 	if ((flags & MAIL_STORAGE_SERVICE_FLAG_DEBUG) != 0)
-		master_service_set(service, "mail_debug", "yes");
+		set_keyval(service, "mail_debug", "yes");
 
 	/* now that we've read settings, we can set up logging */
 	master_service_init_log(service,
@@ -443,7 +442,7 @@ mail_storage_service_init_user(struct ma
 		system_groups_user = NULL;
 		if (*home == '\0' && getenv("HOME") != NULL) {
 			home = getenv("HOME");
-			master_service_set(service, "mail_home", home);
+			set_keyval(service, "mail_home", home);
 		}
 	}
 
@@ -452,7 +451,7 @@ mail_storage_service_init_user(struct ma
 	    strncmp(home, user_set->mail_chroot, len - 2) == 0) {
 		/* If chroot ends with "/.", strip chroot dir from home dir */
 		home += len - 2;
-		master_service_set(service, "mail_home", home);
+		set_keyval(service, "mail_home", home);
 	}
 
 	modules = *user_set->mail_plugins == '\0' ? NULL :
@@ -573,7 +572,7 @@ int mail_storage_service_multi_next(stru
 	    strncmp(home, user_set->mail_chroot, len - 2) == 0) {
 		/* home dir already contains the chroot dir */
 	} else if (len > 0) {
-		master_service_set(ctx->service, "mail_home",
+		set_keyval(ctx->service, "mail_home",
 			t_strconcat(user_set->mail_chroot, "/", home, NULL));
 	}
 	if (mail_storage_service_init_post(ctx->service, user, home, user_set,


More information about the dovecot-cvs mailing list