dovecot-1.3: Added lib-master and mail-storage-service code that...

dovecot at dovecot.org dovecot at dovecot.org
Fri Apr 10 03:24:57 EEST 2009


details:   http://hg.dovecot.org/dovecot-1.3/rev/94ecf8a8ed68
changeset: 9059:94ecf8a8ed68
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Apr 09 20:24:51 2009 -0400
description:
Added lib-master and mail-storage-service code that makes it easier to build new Dovecot binaries.
Currently only the standalone applications (e.g. deliver) uses this.

diffstat:

50 files changed, 1480 insertions(+), 1015 deletions(-)
configure.in                             |    1 
src/Makefile.am                          |    3 
src/deliver/Makefile.am                  |   11 
src/deliver/deliver-settings.c           |  122 ------
src/deliver/deliver-settings.h           |   23 -
src/deliver/deliver.c                    |  357 +++-----------------
src/deliver/deliver.h                    |    4 
src/deliver/smtp-client.c                |    3 
src/dict/main.c                          |    1 
src/imap/Makefile.am                     |    4 
src/imap/imap-settings.c                 |   48 --
src/imap/imap-settings.h                 |    6 
src/imap/main.c                          |   11 
src/lib-auth/auth-master.h               |    2 
src/lib-dovecot/Makefile.am              |    1 
src/lib-master/Makefile.am               |   19 +
src/lib-master/master-service-private.h  |   27 +
src/lib-master/master-service-settings.c |  144 ++++++++
src/lib-master/master-service-settings.h |   23 +
src/lib-master/master-service.c          |  219 ++++++++++++
src/lib-master/master-service.h          |   46 ++
src/lib-master/syslog-util.c             |   65 +++
src/lib-master/syslog-util.h             |   14 
src/lib-settings/settings-parser.c       |   17 
src/lib-settings/settings-parser.h       |    9 
src/lib-sql/Makefile.am                  |    1 
src/lib-storage/Makefile.am              |    7 
src/lib-storage/mail-namespace.c         |    4 
src/lib-storage/mail-storage-service.c   |  525 ++++++++++++++++++++++++++++++
src/lib-storage/mail-storage-service.h   |   31 +
src/lib-storage/mail-storage-settings.c  |   84 ++++
src/lib-storage/mail-storage-settings.h  |   21 +
src/lib-storage/mail-user.c              |   37 --
src/lib-storage/mail-user.h              |    2 
src/master/Makefile.am                   |    4 
src/master/child-process.c               |    8 
src/plugins/convert/Makefile.am          |    5 
src/plugins/convert/convert-settings.c   |   85 ----
src/plugins/convert/convert-settings.h   |   16 
src/plugins/convert/convert-tool.c       |   73 +---
src/plugins/expire/Makefile.am           |   11 
src/plugins/expire/auth-client.c         |    2 
src/plugins/expire/expire-settings.c     |  112 ------
src/plugins/expire/expire-settings.h     |   16 
src/plugins/expire/expire-tool.c         |  191 +++-------
src/pop3/Makefile.am                     |    4 
src/pop3/main.c                          |    8 
src/pop3/pop3-settings.c                 |   48 --
src/pop3/pop3-settings.h                 |    6 
src/util/Makefile.am                     |   14 

diffs (truncated from 3549 to 300 lines):

diff -r ace05d7b6da0 -r 94ecf8a8ed68 configure.in
--- a/configure.in	Thu Apr 09 20:18:18 2009 -0400
+++ b/configure.in	Thu Apr 09 20:24:51 2009 -0400
@@ -2380,6 +2380,7 @@ src/lib-imap/Makefile
 src/lib-imap/Makefile
 src/lib-index/Makefile
 src/lib-mail/Makefile
+src/lib-master/Makefile
 src/lib-ntlm/Makefile
 src/lib-otp/Makefile
 src/lib-dovecot/Makefile
diff -r ace05d7b6da0 -r 94ecf8a8ed68 src/Makefile.am
--- a/src/Makefile.am	Thu Apr 09 20:18:18 2009 -0400
+++ b/src/Makefile.am	Thu Apr 09 20:24:51 2009 -0400
@@ -12,6 +12,7 @@ LIBDOVECOT_SUBDIRS = \
 	lib-charset \
 	lib-mail \
 	lib-imap \
+	lib-master \
 	lib-dict \
 	lib-settings
 
@@ -24,7 +25,6 @@ SUBDIRS = \
 	lib-ntlm \
 	lib-otp \
 	auth \
-	config \
 	dict \
 	master \
 	login-common \
@@ -32,6 +32,7 @@ SUBDIRS = \
 	imap \
 	$(POP3D) \
 	$(DELIVER) \
+	config \
 	tests \
 	util \
 	plugins
diff -r ace05d7b6da0 -r 94ecf8a8ed68 src/deliver/Makefile.am
--- a/src/deliver/Makefile.am	Thu Apr 09 20:18:18 2009 -0400
+++ b/src/deliver/Makefile.am	Thu Apr 09 20:24:51 2009 -0400
@@ -4,20 +4,15 @@ pkglibexec_PROGRAMS = deliver
 
 AM_CPPFLAGS = \
 	-I$(top_srcdir)/src/lib \
-	-I$(top_srcdir)/src/lib-auth \
 	-I$(top_srcdir)/src/lib-settings \
-	-I$(top_srcdir)/src/lib-dict \
 	-I$(top_srcdir)/src/lib-mail \
 	-I$(top_srcdir)/src/lib-imap \
 	-I$(top_srcdir)/src/lib-index \
-	-I$(top_srcdir)/src/lib-settings \
+	-I$(top_srcdir)/src/lib-master \
 	-I$(top_srcdir)/src/lib-storage \
 	-I$(top_srcdir)/src/lib-storage/index \
 	-I$(top_srcdir)/src/lib-storage/index/raw \
-	-DBINDIR=\""$(bindir)"\" \
-	-DSYSCONFDIR=\""$(sysconfdir)"\" \
-	-DPKG_RUNDIR=\""$(rundir)"\" \
-	-DMODULEDIR=\""$(moduledir)"\"
+	-DPKG_RUNDIR=\""$(rundir)"\"
 
 deliver_LDFLAGS = -export-dynamic
 
@@ -30,7 +25,6 @@ deliver_DEPENDENCIES = $(libs)
 deliver_DEPENDENCIES = $(libs)
 
 deliver_SOURCES = \
-	auth-client.c \
 	deliver.c \
 	deliver-settings.c \
 	duplicate.c \
@@ -38,7 +32,6 @@ deliver_SOURCES = \
 	smtp-client.c
 
 headers = \
-	auth-client.h \
 	deliver.h \
 	deliver-settings.h \
 	duplicate.h \
diff -r ace05d7b6da0 -r 94ecf8a8ed68 src/deliver/deliver-settings.c
--- a/src/deliver/deliver-settings.c	Thu Apr 09 20:18:18 2009 -0400
+++ b/src/deliver/deliver-settings.c	Thu Apr 09 20:24:51 2009 -0400
@@ -11,6 +11,8 @@
 #include <stddef.h>
 #include <stdlib.h>
 
+static bool deliver_settings_check(void *_set, pool_t pool, const char **error_r);
+
 #undef DEF
 #undef DEFLIST
 #define DEF(type, name) \
@@ -19,27 +21,11 @@
 	{ SET_DEFLIST, name, offsetof(struct deliver_settings, field), defines }
 
 static struct setting_define deliver_setting_defines[] = {
-	DEF(SET_STR, base_dir),
-	DEF(SET_STR, log_path),
-	DEF(SET_STR, info_log_path),
-	DEF(SET_STR, log_timestamp),
-	DEF(SET_STR, syslog_facility),
-	DEF(SET_BOOL, version_ignore),
-
-	DEF(SET_STR, mail_plugins),
-	DEF(SET_STR, mail_plugin_dir),
-
-	DEF(SET_STR, mail_uid),
-	DEF(SET_STR, mail_gid),
-	DEF(SET_STR, mail_chroot),
-	DEF(SET_STR, mail_access_groups),
-
 	DEF(SET_STR, postmaster_address),
 	DEF(SET_STR, hostname),
 	DEF(SET_STR, sendmail_path),
 	DEF(SET_STR, rejection_subject),
 	DEF(SET_STR, rejection_reason),
-	DEF(SET_STR, auth_socket_path),
 	DEF(SET_STR, deliver_log_format),
 	DEF(SET_BOOL, quota_full_tempfail),
 
@@ -49,28 +35,12 @@ static struct setting_define deliver_set
 };
 
 static struct deliver_settings deliver_default_settings = {
-	MEMBER(base_dir) PKG_RUNDIR,
-	MEMBER(log_path) "",
-	MEMBER(info_log_path) "",
-	MEMBER(log_timestamp) DEFAULT_FAILURE_STAMP_FORMAT,
-	MEMBER(syslog_facility) "mail",
-	MEMBER(version_ignore) FALSE,
-
-	MEMBER(mail_plugins) "",
-	MEMBER(mail_plugin_dir) MODULEDIR,
-
-	MEMBER(mail_uid) "",
-	MEMBER(mail_gid) "",
-	MEMBER(mail_chroot) "",
-	MEMBER(mail_access_groups) "",
-
 	MEMBER(postmaster_address) "",
 	MEMBER(hostname) "",
 	MEMBER(sendmail_path) "/usr/lib/sendmail",
 	MEMBER(rejection_subject) "Rejected: %s",
 	MEMBER(rejection_reason)
 		"Your message to <%t> was automatically rejected:%n%r",
-	MEMBER(auth_socket_path) "auth-master",
 	MEMBER(deliver_log_format) "msgid=%m: %$",
 	MEMBER(quota_full_tempfail) FALSE
 };
@@ -84,82 +54,22 @@ struct setting_parser_info deliver_setti
 
 	MEMBER(parent_offset) (size_t)-1,
 	MEMBER(type_offset) (size_t)-1,
-	MEMBER(struct_size) sizeof(struct deliver_settings)
+	MEMBER(struct_size) sizeof(struct deliver_settings),
+#ifdef CONFIG_BINARY
+	MEMBER(check_func) NULL
+#else
+	MEMBER(check_func) deliver_settings_check
+#endif
 };
 
-static pool_t settings_pool = NULL;
+static bool deliver_settings_check(void *_set, pool_t pool ATTR_UNUSED,
+				   const char **error_r)
+{
+	struct deliver_settings *set = _set;
 
-static void fix_base_path(struct deliver_settings *set, const char **str)
-{
-	if (*str != NULL && **str != '\0' && **str != '/') {
-		*str = p_strconcat(settings_pool,
-				   set->base_dir, "/", *str, NULL);
+	if (*set->postmaster_address == '\0') {
+		*error_r = "postmaster_address setting not given";
+		return FALSE;
 	}
+	return TRUE;
 }
-
-struct setting_parser_context *
-deliver_settings_read(struct deliver_settings **set_r,
-		      struct mail_user_settings **user_set_r)
-{
-	static const struct setting_parser_info *roots[] = {
-                &deliver_setting_parser_info,
-                &mail_user_setting_parser_info
-	};
-	void **sets;
-	struct deliver_settings *deliver_set;
-	struct setting_parser_context *parser;
-
-	if (settings_pool == NULL)
-		settings_pool = pool_alloconly_create("deliver settings", 1024);
-	else
-		p_clear(settings_pool);
-
-	mail_storage_namespace_defines_init(settings_pool);
-
-	parser = settings_parser_init_list(settings_pool,
-				roots, N_ELEMENTS(roots),
-				SETTINGS_PARSER_FLAG_IGNORE_UNKNOWN_KEYS);
-
-	if (settings_parse_environ(parser) < 0) {
-		i_fatal_status(EX_CONFIG, "Error reading configuration: %s",
-			       settings_parser_get_error(parser));
-	}
-
-	sets = settings_parser_get_list(parser);
-
-	deliver_set = sets[0];
-	if (*deliver_set->hostname == '\0')
-		deliver_set->hostname = my_hostname;
-	fix_base_path(deliver_set, &deliver_set->auth_socket_path);
-
-	if (*deliver_set->postmaster_address == '\0') {
-		i_fatal_status(EX_CONFIG,
-			       "postmaster_address setting not given");
-	}
-
-	*set_r = deliver_set;
-	*user_set_r = sets[1];
-	return parser;
-}
-
-void deliver_settings_add(struct setting_parser_context *parser,
-			  const ARRAY_TYPE(const_string) *extra_fields)
-{
-	const char *const *str, *p, *line;
-	unsigned int i, count;
-
-	str = array_get(extra_fields, &count);
-	for (i = 0; i < count; i++) T_BEGIN {
-		p = strchr(str[i], '=');
-		if (p != NULL)
-			line = str[i];
-		else
-			line = t_strconcat(str[i], "=yes", NULL);
-		if (settings_parse_line(parser, str[i]) < 0) {
-			i_fatal_status(EX_CONFIG,
-				       "Invalid userdb input '%s': %s", str[i],
-				       settings_parser_get_error(parser));
-		}
-	} T_END;
-
-}
diff -r ace05d7b6da0 -r 94ecf8a8ed68 src/deliver/deliver-settings.h
--- a/src/deliver/deliver-settings.h	Thu Apr 09 20:18:18 2009 -0400
+++ b/src/deliver/deliver-settings.h	Thu Apr 09 20:24:51 2009 -0400
@@ -4,38 +4,17 @@ struct mail_user_settings;
 struct mail_user_settings;
 
 struct deliver_settings {
-	const char *base_dir;
-	const char *log_path;
-	const char *info_log_path;
-	const char *log_timestamp;
-	const char *syslog_facility;
-	bool version_ignore;
-
-	const char *mail_plugins;
-	const char *mail_plugin_dir;
-
-	const char *mail_uid;
-	const char *mail_gid;
-	const char *mail_chroot;
-	const char *mail_access_groups;
-
-	/* deliver: */
 	const char *postmaster_address;
 	const char *hostname;
 	const char *sendmail_path;
 	const char *rejection_subject;
 	const char *rejection_reason;
-	const char *auth_socket_path;
 	const char *deliver_log_format;
 	bool quota_full_tempfail;
 
 	ARRAY_DEFINE(plugin_envs, const char *);
 };
 
-struct setting_parser_context *
-deliver_settings_read(struct deliver_settings **set_r,
-		      struct mail_user_settings **user_set_r);
-void deliver_settings_add(struct setting_parser_context *parser,
-			  const ARRAY_TYPE(const_string) *extra_fields);
+extern struct setting_parser_info deliver_setting_parser_info;
 
 #endif
diff -r ace05d7b6da0 -r 94ecf8a8ed68 src/deliver/deliver.c
--- a/src/deliver/deliver.c	Thu Apr 09 20:18:18 2009 -0400
+++ b/src/deliver/deliver.c	Thu Apr 09 20:24:51 2009 -0400
@@ -1,49 +1,32 @@
 /* Copyright (c) 2005-2009 Dovecot authors, see the included COPYING file */
-
-/* This is getting pretty horrible. Especially the config file parsing.
-   Dovecot v2.0 should have a config file handling process which should help
-   with this.. */
 
 #include "lib.h"


More information about the dovecot-cvs mailing list