dovecot-2.0: protocols setting works again.

dovecot at dovecot.org dovecot at dovecot.org
Mon Aug 31 20:14:05 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/2fa181d56c20
changeset: 9837:2fa181d56c20
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Aug 31 13:13:57 2009 -0400
description:
protocols setting works again.
Services can now specify which protocol they implement and they can quickly
enabled/disabled by modifying protocols setting. imaps and pop3s are no
longer separate protocols.

diffstat:

5 files changed, 33 insertions(+), 4 deletions(-)
dovecot-example.conf         |    5 ++---
dovecot-master-example.conf  |    6 ++++++
src/master/master-settings.c |    7 ++++++-
src/master/master-settings.h |    3 +++
src/master/service.c         |   16 ++++++++++++++++

diffs (168 lines):

diff -r 3e9f77da6a6f -r 2fa181d56c20 dovecot-example.conf
--- a/dovecot-example.conf	Mon Aug 31 13:00:47 2009 -0400
+++ b/dovecot-example.conf	Mon Aug 31 13:13:57 2009 -0400
@@ -20,9 +20,8 @@
 # Base directory where to store runtime data.
 #base_dir = /var/run/dovecot/
 
-# Protocols we want to be serving: imap imaps pop3 pop3s
-# If you only want to use dovecot-auth, you can set this to "none".
-#protocols = imap imaps
+# Protocols we want to be serving.
+#protocols = imap pop3 lmtp
 
 # Disable LOGIN command and all other plaintext authentications unless
 # SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
diff -r 3e9f77da6a6f -r 2fa181d56c20 dovecot-master-example.conf
--- a/dovecot-master-example.conf	Mon Aug 31 13:00:47 2009 -0400
+++ b/dovecot-master-example.conf	Mon Aug 31 13:13:57 2009 -0400
@@ -64,6 +64,7 @@ service auth-worker {
 }
 
 service imap-login {
+  protocol = imap
   type = auth-source
   executable = imap-login
   auth_dest_service = imap
@@ -88,6 +89,8 @@ service imap-login {
 }
 
 service imap {
+  protocol = imap
+
   # This would write rawlogs into user's ~/dovecot.rawlog/, if it exists:
   #   executable = rawlog /usr/libexec/dovecot/imap
   # <doc/wiki/Debugging/Rawlog>
@@ -103,6 +106,7 @@ service imap {
 }
 
 service pop3-login {
+  protocol = pop3
   type = auth-source
   executable = pop3-login
   auth_dest_service = pop3
@@ -124,10 +128,12 @@ service pop3-login {
 }
 
 service pop3 {
+  protocol = pop3
   executable = pop3
 }
 
 service lmtp {
+  protocol = lmtp
   executable = lmtp
 
   unix_listener {
diff -r 3e9f77da6a6f -r 2fa181d56c20 src/master/master-settings.c
--- a/src/master/master-settings.c	Mon Aug 31 13:00:47 2009 -0400
+++ b/src/master/master-settings.c	Mon Aug 31 13:13:57 2009 -0400
@@ -88,6 +88,7 @@ static struct setting_parser_info inet_l
 
 static struct setting_define service_setting_defines[] = {
 	DEF(SET_STR, name),
+	DEF(SET_STR, protocol),
 	DEF(SET_STR, type),
 	DEF(SET_STR, executable),
 	DEF(SET_STR, user),
@@ -117,6 +118,7 @@ static struct service_settings service_d
 	MEMBER(master_set) NULL,
 
 	MEMBER(name) "",
+	MEMBER(protocol) "",
 	MEMBER(type) "",
 	MEMBER(executable) "",
 	MEMBER(user) "",
@@ -185,6 +187,7 @@ static struct setting_define master_sett
 static struct setting_define master_setting_defines[] = {
 	DEF(SET_STR, base_dir),
 	DEF(SET_STR, libexec_dir),
+	DEF(SET_STR, protocols),
 	DEF(SET_UINT, default_process_limit),
 	DEF(SET_UINT, default_client_limit),
 
@@ -205,6 +208,7 @@ static struct master_settings master_def
 static struct master_settings master_default_settings = {
 	MEMBER(base_dir) PKG_RUNDIR,
 	MEMBER(libexec_dir) PKG_LIBEXECDIR,
+	MEMBER(protocols) "imap pop3 lmtp",
 	MEMBER(default_process_limit) 100,
 	MEMBER(default_client_limit) 1000,
 
@@ -253,7 +257,7 @@ static bool
 static bool
 master_settings_verify(void *_set, pool_t pool, const char **error_r)
 {
-	const struct master_settings *set = _set;
+	struct master_settings *set = _set;
 	struct service_settings *const *services;
 	unsigned int i, j, count;
 
@@ -324,6 +328,7 @@ master_settings_verify(void *_set, pool_
 		fix_file_listener_paths(&services[i]->fifo_listeners,
 					pool, set->base_dir);
 	}
+	set->protocols_split = p_strsplit(pool, set->protocols, " ");
 	return TRUE;
 }
 /* </settings checks> */
diff -r 3e9f77da6a6f -r 2fa181d56c20 src/master/master-settings.h
--- a/src/master/master-settings.h	Mon Aug 31 13:00:47 2009 -0400
+++ b/src/master/master-settings.h	Mon Aug 31 13:13:57 2009 -0400
@@ -19,6 +19,7 @@ struct service_settings {
 	struct master_settings *master_set;
 
 	const char *name;
+	const char *protocol;
 	const char *type;
 	const char *executable;
 	const char *user;
@@ -46,6 +47,7 @@ struct master_settings {
 struct master_settings {
 	const char *base_dir;
 	const char *libexec_dir;
+	const char *protocols;
 	unsigned int default_process_limit;
 	unsigned int default_client_limit;
 
@@ -57,6 +59,7 @@ struct master_settings {
 
 	ARRAY_DEFINE(services, struct service_settings *);
 	ARRAY_DEFINE(auths, struct master_auth_settings *);
+	char **protocols_split;
 };
 
 extern struct setting_parser_info master_setting_parser_info;
diff -r 3e9f77da6a6f -r 2fa181d56c20 src/master/service.c
--- a/src/master/service.c	Mon Aug 31 13:00:47 2009 -0400
+++ b/src/master/service.c	Mon Aug 31 13:13:57 2009 -0400
@@ -317,6 +317,20 @@ service_lookup(struct service_list *serv
 	return NULL;
 }
 
+static bool service_want(struct service_settings *set)
+{
+	char *const *proto;
+
+	if (*set->protocol == '\0')
+		return TRUE;
+
+	for (proto = set->master_set->protocols_split; *proto != NULL; proto++) {
+		if (strcmp(*proto, set->protocol) == 0)
+			return TRUE;
+	}
+	return FALSE;
+}
+
 int services_create(const struct master_settings *set,
 		    const char *const *child_process_env,
 		    struct service_list **services_r, const char **error_r)
@@ -343,6 +357,8 @@ int services_create(const struct master_
 	p_array_init(&service_list->services, pool, count);
 
 	for (i = 0; i < count; i++) {
+		if (!service_want(service_settings[i]))
+			continue;
 		service = service_create(pool, service_settings[i],
 					 service_list, &error);
 		if (service == NULL) {


More information about the dovecot-cvs mailing list