From f11de734327a7a4db80a16a493df0020d9bd4f16 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Mon, 31 Aug 2009 13:13:57 -0400 Subject: [PATCH] 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. --HG-- branch : HEAD --- 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 ++++++++++++++++ 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/dovecot-example.conf b/dovecot-example.conf index a331caddaf..f8547efcd5 100644 --- a/dovecot-example.conf +++ b/dovecot-example.conf @@ -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 --git a/dovecot-master-example.conf b/dovecot-master-example.conf index becf84dbb9..d15b8c1f90 100644 --- a/dovecot-master-example.conf +++ b/dovecot-master-example.conf @@ -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 # @@ -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 --git a/src/master/master-settings.c b/src/master/master-settings.c index 16de48c4c9..52b1b94b39 100644 --- a/src/master/master-settings.c +++ b/src/master/master-settings.c @@ -88,6 +88,7 @@ static struct setting_parser_info inet_listener_setting_parser_info = { 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_default_settings = { MEMBER(master_set) NULL, MEMBER(name) "", + MEMBER(protocol) "", MEMBER(type) "", MEMBER(executable) "", MEMBER(user) "", @@ -185,6 +187,7 @@ struct setting_parser_info master_auth_setting_parser_info = { 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 setting_define master_setting_defines[] = { 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 void fix_file_listener_paths(ARRAY_TYPE(file_listener_settings) *l, 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_t pool, const char **error_r) fix_file_listener_paths(&services[i]->fifo_listeners, pool, set->base_dir); } + set->protocols_split = p_strsplit(pool, set->protocols, " "); return TRUE; } /* */ diff --git a/src/master/master-settings.h b/src/master/master-settings.h index cd8e5c7ba7..0ed31ad822 100644 --- a/src/master/master-settings.h +++ b/src/master/master-settings.h @@ -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_auth_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 --git a/src/master/service.c b/src/master/service.c index 1dbe1a4b43..50599f492d 100644 --- a/src/master/service.c +++ b/src/master/service.c @@ -317,6 +317,20 @@ service_lookup(struct service_list *service_list, const char *name) 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_settings *set, 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) { -- 2.47.3