]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
protocols setting works again.
authorTimo Sirainen <tss@iki.fi>
Mon, 31 Aug 2009 17:13:57 +0000 (13:13 -0400)
committerTimo Sirainen <tss@iki.fi>
Mon, 31 Aug 2009 17:13:57 +0000 (13:13 -0400)
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
dovecot-master-example.conf
src/master/master-settings.c
src/master/master-settings.h
src/master/service.c

index a331caddaf7586fe9ed8cdea6248a720d7b6ffc1..f8547efcd53c5c5920f5dfee44bd6bb013ab6f01 100644 (file)
@@ -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
index becf84dbb94fe138239f9f0c465e719b370912fc..d15b8c1f9018a7d90563ea443b7ec46969d49b36 100644 (file)
@@ -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 {
index 16de48c4c99b79045f42c374116b4b8c71e99b10..52b1b94b39bb14a94b973b4beca925a008ed0b62 100644 (file)
@@ -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;
 }
 /* </settings checks> */
index cd8e5c7ba7c2e4d674bb53979b8dd43d2bd16afa..0ed31ad82292af20a71974e53fdaf651aeaeaeda 100644 (file)
@@ -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;
index 1dbe1a4b433378f2ea288e7269b240a5801d76fb..50599f492d9ccabdec39e79cca9203639cc3ba0e 100644 (file)
@@ -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) {