~ubuntu-dev/ubuntu/lucid/dovecot/lucid-201002101901

« back to all changes in this revision

Viewing changes to debian/patches/dovecot-managesieve.patch

  • Committer: Chuck Short
  • Date: 2010-01-21 20:21:25 UTC
  • mfrom: (4.1.11 squeeze)
  • Revision ID: zulcss@ubuntu.com-20100121202125-pme73o491kfwj5nc
* Merge from debian testing, remaining changes:
  + Add new binary pkg dovecot-postfix that integrates postfix and dovecot
    automatically: (LP: #164837)
  + debian/control:
    - add new binary with short description
    - set Architecture all for dovecot-postfix (LP: #329878)
  + debian/dovecot-postfix.postinst:
    - create initial certificate symlinks to snakeoil.
    - set up postfix with postconf to:
      - use Maildir/ as the default mailbox.
      - use dovecot as the sasl authentication server.
      - use dovecot LDA (deliver).
      - use tls for smtp{d} services.
    - fix certificates paths in postfix' main.cf
    - add reject_unauth_destination to postfix' recipient restrictions
    - add reject_unknown_sender_domain to postfix' sender restriction
    - rename configuration name on remove, delete on purge
    - restart dovecot after linking certificates
    - handle use case when postfix is unconfigurated
  + debian/dovecot-postfix.dirs: create backup directory for postfix's config
    configuration
  + restart postfix and dovecot.
  + debian/dovecot-postfix.postrm:
    - remove all dovecot related configuration from postfix.
    - restart postfix and dovecot.
  + debian/dovecot-common.init:
    - check if /etc/dovecot/dovecot-postfix.conf exists and use it
      as the configuration file if so.
  + debian/patches/warning-ubuntu-postfix.dpatch
    - add warning about dovecot-postfix.conf in dovecot default
      configuration file
  + debian/patches/dovecot-postfix.conf.diff:
    - Ubuntu server custom changes to the default dovecot configuration for
      better interfation with postfix.
    - enable sieve plugin.
    - Ubuntu server custom changes to the default dovecot configuration for
      better integration with postfix:
      - enable imap, pop3, imaps, pop3s and managesieve by default.
      - enable dovecot LDA (deliver).
      - enable SASL auth socket in postfix private directory
   + debian/rules:
     - copy, patch and install dovecot-postfix.conf in /etc/dovecot/.
     - build architecure independent packages too
   + Use Snakeoil SSL certificates by default.
     - debian/control: Depend on ssl-cert.
     - debian/patches/ssl-cert-snakeoil.dpatch: Change default SSL cert
       paths to snakeoil.
     - debian/dovecot-common.postinst: Relax grep for SSL_* a bit.
   + Add autopkgtest to debian/tests/*.
   + Fast TearDown: Update the lsb init header to not stop in level 6.
   + Add ufw integration:
     - Created debian/dovecot-common.ufw.profile.
     - debian/rules: install profile.
     - debian/control: suggest ufw.
   + debian/{control,rules}: enable PIE hardening.
   + dovecot-imapd, dovecot-pop3: Replaces dovecot-common (<< 1:1.1). (LP: #254721)
   + debian/control: Update Vcs-* headers.
   + Add SMTP-AUTH support for Outlook (login auth mechanism)
* New upstream release.
* debian/patches/gold-fix.patch: Removed. Fixed upstream.
* Moved libexec to lib corrections in dovecot-managesieve.patch and
  dovecot-managesieve-dist.patch to dovecot-example.patch
* debian/patches/dovecot-mboxlocking.patch: Regenerated to avoid FTBFS
  when quilt isn't installed.
* debian/patches/quota-mountpoint.patch: Removed. Not needed anymore.
* debian/patches/dovecot-quota.patch: Removed. Quotas aren't properly
  enabled unless mail_plugins = quota imap_quota.
* debian/patches/gold-fix.patch: Fixed configure script to build even
  with binutils-gold or --no-add-needed linker flag (Closes: #554306)
* debian/dovecot-common.init: fixed LSB headers. Thanks to Pascal Volk.
  (Closes: #558040)
* debian/changelog: added CVE references to previous changelog entry.
* debian/rules: checked up the build system. It's not fragile anymore.
  (Closes: 493803)
* debian/dovecot-common.postinst: Now invoking dpkg-reconfigure
  on dovecot-common is enough to generate new certificates
  if the previous ones were removed. (Closes: #545582)
* debian/rules: No longer install convert-tool in /usr/bin.
  It isn't an user utility and it should stay in /usr/lib/dovecot
  like all other similar tool.
* New upstream release. (Closes: #557601)
* [SECURITY] Fixes local information disclosure and denial of service.
  (see: http://www.dovecot.org/list/dovecot-news/2009-November/000143.html
  and CVE-2009-3897)
* Added myself to uploaders.
* Switched to the new source format "3.0 (quilt)":
  - removed dpatch from build-depends
  - removed debian/README.source because now we use only standard
    dpkg features
  - regenerated all patches
* Prepared to switch to multi-origin source:
  - recreated dovecot-libsieve.patch and dovecot-managesieve-dist.patch
    starting from the upstream tarball
  - removed all autotools related build-depends and build-conflict
  - renamed dovecot-libsieve and dovecot-managesieve directories
    to libsieve and managesieve.
* debian/rules: Moved the configuration of libsieve and managesieve from
  the build phase to the configuration phase
* Added dovecot-dbg package  with debugging symbols.  Thanks Stephan Bosch.
  (Closes: #554710)
* Fixed some stray libexec'isms in the default configuration.
* New upstream release.
* debian/dovecot-common.init:
  - use $CONF when starting the daemon. (Closes: #549944)
  - always output start/stop messages. (Closes: #523810)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Author: Stephan Bosch <stephan@rename-it.nl>
 
2
Description: Adds support for ManageSieve
 
3
Origin: http://www.rename-it.nl/dovecot/1.2/dovecot-1.2.8-managesieve-0.11.9.diff.gz
 
4
Last-Update: 2009-11-23
 
5
 
 
6
diff -r ee1782019a60 README.managesieve
 
7
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
 
8
+++ b/README.managesieve        Mon Nov 23 12:21:06 2009 +0100
 
9
@@ -0,0 +1,29 @@
 
10
+
 
11
+MANAGESIEVE service support patch for Dovecot 1.2
 
12
+
 
13
+NOTICE: As per dovecot-1.1, this patch only contains the changes to the 
 
14
+Dovecot tree that are necessary to use the now external 
 
15
+dovecot-1.x-managesieve package. So, applying this patch is no longer 
 
16
+the only thing you need to do to give Dovecot managesieve support. 
 
17
+Eventually the need for this patch will disappear completely. 
 
18
+
 
19
+Compile
 
20
+-------
 
21
+
 
22
+After applying this patch you can just use the usual build process
 
23
+(http://wiki.dovecot.org/CompilingSource):
 
24
+
 
25
+./configure
 
26
+make
 
27
+sudo make install 
 
28
+
 
29
+Don't forget to execute ./autogen.sh if you downloaded dovecot from the
 
30
+Mercurial repository.
 
31
+
 
32
+Installation and Configuration
 
33
+------------------------------
 
34
+
 
35
+Read the README of the dovecot-managesieve package for the next steps. 
 
36
+Note that this patch adds configuration examples to the dovecot-example.conf 
 
37
+configuration file example.
 
38
+
 
39
diff -r ee1782019a60 dovecot-example.conf
 
40
--- a/dovecot-example.conf      Thu Nov 19 19:32:13 2009 -0500
 
41
+++ b/dovecot-example.conf      Mon Nov 23 12:21:06 2009 +0100
 
42
@@ -19,7 +19,7 @@
 
43
 # Base directory where to store runtime data.
 
44
 #base_dir = /var/run/dovecot/
 
45
 
 
46
-# Protocols we want to be serving: imap imaps pop3 pop3s
 
47
+# Protocols we want to be serving: imap imaps pop3 pop3s managesieve
 
48
 # If you only want to use dovecot-auth, you can set this to "none".
 
49
 #protocols = imap imaps
 
50
 
 
51
@@ -28,8 +28,8 @@
 
52
 # interfaces. Use "*, [::]" for listening both IPv4 and IPv6.
 
53
 #
 
54
 # If you want to specify ports for each service, you will need to configure
 
55
-# these settings inside the protocol imap/pop3 { ... } section, so you can
 
56
-# specify different ports for IMAP/POP3. For example:
 
57
+# these settings inside the protocol imap/pop3/managesieve { ... } section, 
 
58
+# so you can specify different ports for IMAP/POP3/MANAGESIEVE. For example:
 
59
 #   protocol imap {
 
60
 #     listen = *:10143
 
61
 #     ssl_listen = *:10943
 
62
@@ -39,6 +39,10 @@
 
63
 #     listen = *:10100
 
64
 #     ..
 
65
 #   }
 
66
+#   protocol managesieve {
 
67
+#     listen = *:12000
 
68
+#     ..
 
69
+#   }
 
70
 #listen = *
 
71
 
 
72
 # Disable LOGIN command and all other plaintext authentications unless
 
73
@@ -696,6 +700,38 @@
 
74
 }
 
75
 
 
76
 ##
 
77
+## ManageSieve specific settings
 
78
+##
 
79
+
 
80
+protocol managesieve {
 
81
+  # Login executable location.
 
82
+  #login_executable = /usr/libexec/dovecot/managesieve-login
 
83
+
 
84
+  # ManageSieve executable location. See IMAP's mail_executable above for 
 
85
+  # examples how this could be changed.
 
86
+  #mail_executable = /usr/libexec/dovecot/managesieve
 
87
+
 
88
+  # Maximum ManageSieve command line length in bytes. This setting is 
 
89
+  # directly borrowed from IMAP. But, since long command lines are very
 
90
+  # unlikely with ManageSieve, changing this will not be very useful.  
 
91
+  #managesieve_max_line_length = 65536
 
92
+
 
93
+  # ManageSieve logout format string:
 
94
+  #  %i - total number of bytes read from client
 
95
+  #  %o - total number of bytes sent to client
 
96
+  #managesieve_logout_format = bytes=%i/%o
 
97
+
 
98
+  # To fool ManageSieve clients that are focused on timesieved you can
 
99
+  # specify the IMPLEMENTATION capability that the dovecot reports to clients 
 
100
+  # (default: "dovecot").
 
101
+  #managesieve_implementation_string = Cyrus timsieved v2.2.13
 
102
+
 
103
+  # The ManageSieve service also uses the sieve and sieve_dir settings
 
104
+  # of the Sieve plugin. These are configured in the plugin {} section of
 
105
+  # this config file. 
 
106
+}
 
107
+
 
108
+##
 
109
 ## LDA specific settings
 
110
 ##
 
111
 
 
112
@@ -1211,6 +1247,16 @@
 
113
   # Available fields: uid, box, msgid, from, subject, size, vsize, flags
 
114
   # size and vsize are available only for expunge and copy events.
 
115
   #mail_log_fields = uid box msgid size
 
116
+
 
117
+  # Sieve plugin (http://wiki.dovecot.org/LDA/Sieve) and ManageSieve service
 
118
+  # 
 
119
+  # Location of the active script. When ManageSieve is used this is actually 
 
120
+  # a symlink pointing to the active script in the sieve storage directory. 
 
121
+  #sieve=~/.dovecot.sieve
 
122
+  #
 
123
+  # The path to the directory where the personal Sieve scripts are stored. For 
 
124
+  # ManageSieve this is where the uploaded scripts are stored.
 
125
+  #sieve_dir=~/sieve
 
126
 }
 
127
 
 
128
 # Config files can also be included. deliver doesn't support them currently.
 
129
diff -r ee1782019a60 src/master/child-process.c
 
130
--- a/src/master/child-process.c        Thu Nov 19 19:32:13 2009 -0500
 
131
+++ b/src/master/child-process.c        Mon Nov 23 12:21:06 2009 +0100
 
132
@@ -20,7 +20,8 @@
 
133
        "imap",
 
134
        "pop3",
 
135
        "ssl-build-param",
 
136
-       "dict"
 
137
+       "dict",
 
138
+       "managesieve"
 
139
 };
 
140
 
 
141
 struct hash_table *processes;
 
142
@@ -111,6 +112,7 @@
 
143
                        return "Out of memory - see login_process_size setting";
 
144
                case PROCESS_TYPE_IMAP:
 
145
                case PROCESS_TYPE_POP3:
 
146
+               case PROCESS_TYPE_MANAGESIEVE:
 
147
                        return "Out of memory - see mail_process_size setting";
 
148
                case PROCESS_TYPE_UNKNOWN:
 
149
                case PROCESS_TYPE_SSL_PARAM:
 
150
@@ -159,6 +161,7 @@
 
151
 #endif
 
152
        case PROCESS_TYPE_IMAP:
 
153
        case PROCESS_TYPE_POP3:
 
154
+       case PROCESS_TYPE_MANAGESIEVE:
 
155
 #ifndef HAVE_PR_SET_DUMPABLE
 
156
                if (!settings_root->defaults->mail_drop_priv_before_exec) {
 
157
                        str_append(str, " (core not dumped - set mail_drop_priv_before_exec=yes)");
 
158
diff -r ee1782019a60 src/master/child-process.h
 
159
--- a/src/master/child-process.h        Thu Nov 19 19:32:13 2009 -0500
 
160
+++ b/src/master/child-process.h        Mon Nov 23 12:21:06 2009 +0100
 
161
@@ -10,6 +10,7 @@
 
162
        PROCESS_TYPE_POP3,
 
163
        PROCESS_TYPE_SSL_PARAM,
 
164
        PROCESS_TYPE_DICT,
 
165
+       PROCESS_TYPE_MANAGESIEVE,
 
166
 
 
167
        PROCESS_TYPE_MAX
 
168
 };
 
169
diff -r ee1782019a60 src/master/listener.c
 
170
--- a/src/master/listener.c     Thu Nov 19 19:32:13 2009 -0500
 
171
+++ b/src/master/listener.c     Mon Nov 23 12:21:06 2009 +0100
 
172
@@ -130,6 +130,10 @@
 
173
                        check_conflicts_set(server->pop3, ip, port,
 
174
                                            "pop3", proto);
 
175
                }
 
176
+                if (server->managesieve != NULL) {
 
177
+            check_conflicts_set(server->managesieve, ip, port,
 
178
+                        "managesieve", proto);
 
179
+        }
 
180
        }
 
181
 }
 
182
 
 
183
@@ -230,13 +234,29 @@
 
184
                        if (set->protocol == MAIL_PROTOCOL_POP3 &&
 
185
                            strcmp(set->ssl, "no") != 0)
 
186
                                ssl_listen = TRUE;
 
187
+               } else if (strcasecmp(*proto, "managesieve") == 0) {
 
188
+                       if (set->protocol == MAIL_PROTOCOL_MANAGESIEVE)
 
189
+                               nonssl_listen = TRUE;
 
190
                }
 
191
        }
 
192
 
 
193
        if (!nonssl_listen)
 
194
                listener_close_fds(&set->listens);
 
195
        else {
 
196
-               default_port = set->protocol == MAIL_PROTOCOL_IMAP ? 143 : 110;
 
197
+               switch (set->protocol) {
 
198
+               case MAIL_PROTOCOL_IMAP:
 
199
+                       default_port = 143;
 
200
+                       break;
 
201
+               case MAIL_PROTOCOL_POP3:
 
202
+                       default_port = 110;
 
203
+                       break;
 
204
+               case MAIL_PROTOCOL_MANAGESIEVE:
 
205
+                       default_port = 2000;
 
206
+                       break;
 
207
+               default:
 
208
+                       i_unreached();
 
209
+               }
 
210
+
 
211
                listener_init("listen", set->listen, default_port,
 
212
                              &set->listens);
 
213
        }
 
214
@@ -336,9 +356,11 @@
 
215
                if (old_set != NULL) {
 
216
                        listen_copy_old(old_set->imap, server->imap);
 
217
                        listen_copy_old(old_set->pop3, server->pop3);
 
218
+                       listen_copy_old(old_set->managesieve, server->managesieve);
 
219
                }
 
220
                listen_parse_and_close_unneeded(server->imap);
 
221
                listen_parse_and_close_unneeded(server->pop3);
 
222
+               listen_parse_and_close_unneeded(server->managesieve);
 
223
 
 
224
                if (old_set != NULL)
 
225
                        old_set = old_set->next;
 
226
@@ -349,6 +371,8 @@
 
227
                        listener_listen_missing(server->imap, "imap", retry);
 
228
                if (server->pop3 != NULL)
 
229
                        listener_listen_missing(server->pop3, "pop3", retry);
 
230
+               if (server->managesieve != NULL)
 
231
+                       listener_listen_missing(server->managesieve, "managesieve", retry);
 
232
        }
 
233
 }
 
234
 
 
235
@@ -365,5 +389,8 @@
 
236
                        listener_close_fds(&server->pop3->listens);
 
237
                        listener_close_fds(&server->pop3->ssl_listens);
 
238
                }
 
239
+               if (server->managesieve != NULL) {
 
240
+                       listener_close_fds(&server->managesieve->listens);
 
241
+               }
 
242
        }
 
243
 }
 
244
diff -r ee1782019a60 src/master/login-process.c
 
245
--- a/src/master/login-process.c        Thu Nov 19 19:32:13 2009 -0500
 
246
+++ b/src/master/login-process.c        Mon Nov 23 12:21:06 2009 +0100
 
247
@@ -72,8 +72,20 @@
 
248
        group = i_new(struct login_group, 1);
 
249
        group->refcount = 1;
 
250
        group->set = set;
 
251
-       group->mail_process_type = set->protocol == MAIL_PROTOCOL_IMAP ?
 
252
-               PROCESS_TYPE_IMAP : PROCESS_TYPE_POP3;
 
253
+
 
254
+       switch ( set->protocol ) {
 
255
+       case MAIL_PROTOCOL_IMAP:
 
256
+               group->mail_process_type = PROCESS_TYPE_IMAP;
 
257
+               break;
 
258
+       case MAIL_PROTOCOL_POP3:
 
259
+               group->mail_process_type = PROCESS_TYPE_POP3;
 
260
+               break;
 
261
+       case MAIL_PROTOCOL_MANAGESIEVE:
 
262
+               group->mail_process_type = PROCESS_TYPE_MANAGESIEVE;
 
263
+               break;
 
264
+       default:
 
265
+               i_unreached();
 
266
+       }
 
267
 
 
268
        group->next = login_groups;
 
269
        login_groups = group;
 
270
@@ -224,6 +236,8 @@
 
271
                        login_group_create(server->imap);
 
272
                if (server->pop3 != NULL)
 
273
                        login_group_create(server->pop3);
 
274
+               if (server->managesieve != NULL)
 
275
+                       login_group_create(server->managesieve);
 
276
        }
 
277
 }
 
278
 
 
279
@@ -285,6 +299,8 @@
 
280
                        protocol = MAIL_PROTOCOL_IMAP;
 
281
                else if (strcmp(proto, "pop3") == 0)
 
282
                        protocol = MAIL_PROTOCOL_POP3;
 
283
+               else if (strcmp(proto, "managesieve") == 0)
 
284
+                       protocol = MAIL_PROTOCOL_MANAGESIEVE;
 
285
                else {
 
286
                        i_error("login: Unknown protocol '%s'", proto);
 
287
                        return FALSE;
 
288
@@ -621,7 +637,13 @@
 
289
                                    set->imap_generated_capability, NULL));
 
290
                if (*set->imap_capability != '\0')
 
291
                        env_put("CAPABILITY_STRING_OVERRIDDEN=1");
 
292
+       } else if (group->mail_process_type == PROCESS_TYPE_MANAGESIEVE) {
 
293
+               env_put(t_strconcat("CAPABILITY_STRING=",
 
294
+                       set->managesieve_generated_capability, NULL));
 
295
+               env_put(t_strconcat("MANAGESIEVE_IMPLEMENTATION_STRING=",
 
296
+                       set->managesieve_implementation_string, NULL));
 
297
        }
 
298
+
 
299
        if (*set->login_trusted_networks != '\0') {
 
300
                env_put(t_strconcat("TRUSTED_NETWORKS=",
 
301
                                    set->login_trusted_networks, NULL));
 
302
diff -r ee1782019a60 src/master/mail-process.c
 
303
--- a/src/master/mail-process.c Thu Nov 19 19:32:13 2009 -0500
 
304
+++ b/src/master/mail-process.c Mon Nov 23 12:21:06 2009 +0100
 
305
@@ -372,6 +372,15 @@
 
306
        /* We care about POP3 UIDL format in all process types */
 
307
        env_put(t_strconcat("POP3_UIDL_FORMAT=", set->pop3_uidl_format, NULL));
 
308
 
 
309
+       if (set->protocol == MAIL_PROTOCOL_MANAGESIEVE) {
 
310
+               env_put(t_strdup_printf("MANAGESIEVE_MAX_LINE_LENGTH=%u",
 
311
+                                   set->managesieve_max_line_length));
 
312
+               env_put(t_strconcat("MANAGESIEVE_LOGOUT_FORMAT=",
 
313
+                                   set->managesieve_logout_format, NULL));
 
314
+               env_put(t_strconcat("MANAGESIEVE_IMPLEMENTATION_STRING=",
 
315
+                           set->managesieve_implementation_string, NULL));
 
316
+       }
 
317
+
 
318
        if (set->mail_save_crlf)
 
319
                env_put("MAIL_SAVE_CRLF=1");
 
320
        if (set->mmap_disable)
 
321
@@ -499,6 +508,8 @@
 
322
                        set = server->imap;
 
323
                else if (strcmp(protocol, "pop3") == 0)
 
324
                        set = server->pop3;
 
325
+               else if (strcmp(protocol, "managesieve") == 0)
 
326
+                       set = server->managesieve;
 
327
                else
 
328
                        i_fatal("Unknown protocol: '%s'", protocol);
 
329
                executable = set->mail_executable;
 
330
@@ -596,7 +607,8 @@
 
331
        bool home_given, nfs_check;
 
332
 
 
333
        i_assert(process_type == PROCESS_TYPE_IMAP ||
 
334
-                process_type == PROCESS_TYPE_POP3);
 
335
+               process_type == PROCESS_TYPE_POP3 || 
 
336
+               process_type == PROCESS_TYPE_MANAGESIEVE );
 
337
 
 
338
        if (mail_process_count == set->max_mail_processes) {
 
339
                i_error("Maximum number of mail processes exceeded "
 
340
@@ -985,6 +997,8 @@
 
341
                                           mail_process_destroyed);
 
342
        child_process_set_destroy_callback(PROCESS_TYPE_POP3,
 
343
                                           mail_process_destroyed);
 
344
+       child_process_set_destroy_callback(PROCESS_TYPE_MANAGESIEVE,
 
345
+                                          mail_process_destroyed);
 
346
 }
 
347
 
 
348
 void mail_processes_deinit(void)
 
349
diff -r ee1782019a60 src/master/main.c
 
350
--- a/src/master/main.c Thu Nov 19 19:32:13 2009 -0500
 
351
+++ b/src/master/main.c Mon Nov 23 12:21:06 2009 +0100
 
352
@@ -247,6 +247,8 @@
 
353
                        return TRUE;
 
354
                if (server->pop3 != NULL && have_stderr_set(server->pop3))
 
355
                        return TRUE;
 
356
+               if (server->managesieve != NULL && have_stderr_set(server->managesieve))
 
357
+                       return TRUE;
 
358
 
 
359
                server = server->next;
 
360
        }
 
361
diff -r ee1782019a60 src/master/master-settings-defs.c
 
362
--- a/src/master/master-settings-defs.c Thu Nov 19 19:32:13 2009 -0500
 
363
+++ b/src/master/master-settings-defs.c Mon Nov 23 12:21:06 2009 +0100
 
364
@@ -131,5 +131,10 @@
 
365
        DEF_STR(dict_db_config),
 
366
        DEF_INT(dict_process_count),
 
367
 
 
368
+       /* managesieve */
 
369
+       DEF_INT(managesieve_max_line_length),
 
370
+       DEF_STR(managesieve_logout_format),
 
371
+       DEF_STR(managesieve_implementation_string),
 
372
+
 
373
        { 0, NULL, 0 }
 
374
 };
 
375
diff -r ee1782019a60 src/master/master-settings.c
 
376
--- a/src/master/master-settings.c      Thu Nov 19 19:32:13 2009 -0500
 
377
+++ b/src/master/master-settings.c      Mon Nov 23 12:21:06 2009 +0100
 
378
@@ -297,6 +297,11 @@
 
379
        MEMBER(dict_db_config) NULL,
 
380
        MEMBER(dict_process_count) 1,
 
381
 
 
382
+       /* managesieve */
 
383
+       MEMBER(managesieve_max_line_length) 65536,
 
384
+       MEMBER(managesieve_logout_format) "bytes=%i/%o",
 
385
+       MEMBER(managesieve_implementation_string) PACKAGE,
 
386
+
 
387
        /* .. */
 
388
 };
 
389
 
 
390
@@ -477,6 +482,8 @@
 
391
                        auth->parent->pop3->ssl_verify_client_cert = TRUE;
 
392
                if (auth->parent->imap != NULL)
 
393
                        auth->parent->imap->ssl_verify_client_cert = TRUE;
 
394
+               if (auth->parent->managesieve != NULL)
 
395
+                       auth->parent->managesieve->ssl_verify_client_cert = TRUE;
 
396
        }
 
397
 
 
398
        for (s = auth->sockets; s != NULL; s = s->next) {
 
399
@@ -556,12 +563,21 @@
 
400
                return TRUE;
 
401
        }
 
402
 
 
403
-       if (set->protocol == MAIL_PROTOCOL_IMAP) {
 
404
+       switch ( set->protocol ) {
 
405
+       case MAIL_PROTOCOL_IMAP:
 
406
                if (strstr(set->protocols, "imap") == NULL)
 
407
                        return FALSE;
 
408
-       } else {
 
409
+               break;
 
410
+       case MAIL_PROTOCOL_POP3:
 
411
                if (strstr(set->protocols, "pop3") == NULL)
 
412
                        return FALSE;
 
413
+               break;
 
414
+       case MAIL_PROTOCOL_MANAGESIEVE:
 
415
+               if (strstr(set->protocols, "managesieve") == NULL)
 
416
+                       return FALSE;
 
417
+               break;
 
418
+       default:
 
419
+               i_unreached();
 
420
        }
 
421
 
 
422
        return TRUE;
 
423
@@ -656,7 +672,6 @@
 
424
        (void)closedir(dirp);
 
425
 }
 
426
 
 
427
-#ifdef HAVE_MODULES
 
428
 static const char *
 
429
 get_process_capability(enum process_type ptype, struct settings *set)
 
430
 {
 
431
@@ -757,6 +772,7 @@
 
432
        return i_strdup(buf);
 
433
 }
 
434
 
 
435
+#ifdef HAVE_MODULES
 
436
 static bool get_imap_capability(struct settings *set)
 
437
 {
 
438
        static const char *generated_capability = NULL;
 
439
@@ -781,6 +797,26 @@
 
440
 }
 
441
 #endif
 
442
 
 
443
+static bool get_managesieve_capability(struct settings *set)
 
444
+{
 
445
+       static const char *generated_capability = NULL;
 
446
+
 
447
+       if (generated_capability != NULL) {
 
448
+               /* See get_imap_capability above.. */
 
449
+               set->managesieve_generated_capability =
 
450
+                       p_strdup(settings_pool, generated_capability);
 
451
+               return TRUE;
 
452
+       }
 
453
+
 
454
+       generated_capability = get_process_capability(PROCESS_TYPE_MANAGESIEVE, set);
 
455
+       if (generated_capability == NULL)
 
456
+               return FALSE;
 
457
+
 
458
+       set->managesieve_generated_capability =
 
459
+               p_strdup(settings_pool, generated_capability);
 
460
+       return TRUE;
 
461
+}
 
462
+
 
463
 static bool settings_verify(struct settings *set)
 
464
 {
 
465
        const char *dir;
 
466
@@ -966,6 +1002,11 @@
 
467
                strstr(set->server->imap->login_executable, " -D");
 
468
        if (p != NULL && p[3] == '\0')
 
469
                return TRUE;
 
470
+       p = set->server->managesieve == NULL ? NULL :
 
471
+               strstr(set->server->managesieve->login_executable, " -D");
 
472
+       if (p != NULL && p[3] == '\0')
 
473
+               return TRUE;
 
474
+
 
475
        return FALSE;
 
476
 }
 
477
 
 
478
@@ -1025,6 +1066,10 @@
 
479
                        return FALSE;
 
480
        }
 
481
 #endif
 
482
+       if ( set->protocol == MAIL_PROTOCOL_MANAGESIEVE ) {
 
483
+               if (!get_managesieve_capability(set))
 
484
+                       return FALSE;
 
485
+       }
 
486
        return TRUE;
 
487
 }
 
488
 
 
489
@@ -1260,6 +1305,15 @@
 
490
                        array_append(&ctx->server->lda_settings, &value, 1);
 
491
                }
 
492
 
 
493
+               if (error == NULL &&
 
494
+                   (ctx->protocol == MAIL_PROTOCOL_ANY ||
 
495
+                    ctx->protocol == MAIL_PROTOCOL_MANAGESIEVE)) {
 
496
+                       error = parse_setting_from_defs(settings_pool,
 
497
+                                                       setting_defs,
 
498
+                                                       ctx->server->managesieve,
 
499
+                                                       key, value);
 
500
+               }
 
501
+
 
502
                if (error == NULL)
 
503
                        return NULL;
 
504
 
 
505
@@ -1318,6 +1372,13 @@
 
506
                        array_append(&ctx->server->pop3->plugin_envs,
 
507
                                     &value, 1);
 
508
                }
 
509
+               if (ctx->protocol == MAIL_PROTOCOL_ANY ||
 
510
+                   ctx->protocol == MAIL_PROTOCOL_MANAGESIEVE) {
 
511
+                       array_append(&ctx->server->managesieve->plugin_envs, &key, 1);
 
512
+                       array_append(&ctx->server->managesieve->plugin_envs,
 
513
+                                    &value, 1);
 
514
+               }
 
515
+
 
516
                return NULL;
 
517
        }
 
518
 
 
519
@@ -1327,7 +1388,8 @@
 
520
 static struct server_settings *
 
521
 create_new_server(const char *name,
 
522
                  struct settings *imap_defaults,
 
523
-                 struct settings *pop3_defaults)
 
524
+                 struct settings *pop3_defaults,
 
525
+                 struct settings *managesieve_defaults)
 
526
 {
 
527
        struct server_settings *server;
 
528
 
 
529
@@ -1335,15 +1397,18 @@
 
530
        server->name = p_strdup(settings_pool, name);
 
531
        server->imap = p_new(settings_pool, struct settings, 1);
 
532
        server->pop3 = p_new(settings_pool, struct settings, 1);
 
533
+       server->managesieve = p_new(settings_pool, struct settings, 1);
 
534
        server->auth_defaults = default_auth_settings;
 
535
 
 
536
        *server->imap = *imap_defaults;
 
537
        *server->pop3 = *pop3_defaults;
 
538
+       *server->managesieve = *managesieve_defaults;
 
539
 
 
540
        p_array_init(&server->dicts, settings_pool, 4);
 
541
        p_array_init(&server->lda_settings, settings_pool, 12);
 
542
        p_array_init(&server->imap->plugin_envs, settings_pool, 8);
 
543
        p_array_init(&server->pop3->plugin_envs, settings_pool, 8);
 
544
+       p_array_init(&server->managesieve->plugin_envs, settings_pool, 8);
 
545
 
 
546
        server->imap->server = server;
 
547
        server->imap->protocol = MAIL_PROTOCOL_IMAP;
 
548
@@ -1357,6 +1422,12 @@
 
549
        server->pop3->mail_executable = PKG_LIBEXECDIR"/pop3";
 
550
        server->pop3->mail_plugin_dir = MODULEDIR"/pop3";
 
551
 
 
552
+       server->managesieve->server = server;
 
553
+       server->managesieve->protocol = MAIL_PROTOCOL_MANAGESIEVE;
 
554
+       server->managesieve->login_executable = PKG_LIBEXECDIR"/managesieve-login";
 
555
+       server->managesieve->mail_executable = PKG_LIBEXECDIR"/managesieve";
 
556
+       server->managesieve->mail_plugin_dir = MODULEDIR"/managesieve";
 
557
+  
 
558
        return server;
 
559
 }
 
560
 
 
561
@@ -1399,8 +1470,8 @@
 
562
 
 
563
                ctx->type = SETTINGS_TYPE_SERVER;
 
564
                ctx->server = create_new_server(name, ctx->server->imap,
 
565
-                                               ctx->server->pop3);
 
566
-                server = ctx->root;
 
567
+                                               ctx->server->pop3, ctx->server->managesieve);
 
568
+               server = ctx->root;
 
569
                while (server->next != NULL)
 
570
                        server = server->next;
 
571
                server->next = ctx->server;
 
572
@@ -1421,6 +1492,8 @@
 
573
                        ctx->protocol = MAIL_PROTOCOL_POP3;
 
574
                else if (strcmp(name, "lda") == 0)
 
575
                        ctx->protocol = MAIL_PROTOCOL_LDA;
 
576
+               else if (strcmp(name, "managesieve") == 0)
 
577
+                       ctx->protocol = MAIL_PROTOCOL_MANAGESIEVE;
 
578
                else {
 
579
                        *errormsg = "Unknown protocol name";
 
580
                        return FALSE;
 
581
@@ -1532,6 +1605,8 @@
 
582
                        fd_count += server->imap->login_max_processes_count;
 
583
                if (server->pop3 != NULL)
 
584
                        fd_count += server->pop3->login_max_processes_count;
 
585
+               if (server->managesieve != NULL)
 
586
+                       fd_count += server->managesieve->login_max_processes_count;
 
587
                fd_count += server->defaults->max_mail_processes;
 
588
        }
 
589
 
 
590
@@ -1562,7 +1637,7 @@
 
591
        ctx.protocol = MAIL_PROTOCOL_ANY;
 
592
        ctx.server = ctx.root =
 
593
                create_new_server("default",
 
594
-                                 &default_settings, &default_settings);
 
595
+                                 &default_settings, &default_settings, &default_settings);
 
596
        ctx.auth = &ctx.server->auth_defaults;
 
597
 
 
598
        if (!settings_read(path, NULL, parse_setting, parse_section, &ctx))
 
599
@@ -1579,7 +1654,8 @@
 
600
 
 
601
        if (!nochecks && !nofixes) {
 
602
                def = settings_is_active(ctx.root->imap) ?
 
603
-                       ctx.root->imap : ctx.root->pop3;
 
604
+                       ctx.root->imap : ( settings_is_active(ctx.root->pop3) ?
 
605
+                               ctx.root->pop3 : ctx.root->managesieve );
 
606
 
 
607
                path = t_strconcat(def->base_dir, "/master.pid", NULL);
 
608
                pid_file_check_running(path);
 
609
@@ -1588,7 +1664,8 @@
 
610
        prev = NULL;
 
611
        for (server = ctx.root; server != NULL; server = server->next) {
 
612
                if ((*server->imap->protocols == '\0' ||
 
613
-                    *server->pop3->protocols == '\0') && !nochecks) {
 
614
+                    *server->pop3->protocols == '\0' ||
 
615
+                    *server->managesieve->protocols == '\0') && !nochecks) {
 
616
                        i_error("protocols: No protocols given "
 
617
                                "in configuration file");
 
618
                        return FALSE;
 
619
@@ -1619,6 +1696,15 @@
 
620
                                server->defaults = server->pop3;
 
621
                }
 
622
 
 
623
+               if (!settings_is_active(server->managesieve) && !nochecks)
 
624
+                       server->managesieve = NULL;
 
625
+               else {
 
626
+                       if (!settings_fix(server->managesieve, nochecks, nofixes))
 
627
+                               return FALSE;
 
628
+                       if (server->defaults == NULL)
 
629
+                               server->defaults = server->managesieve;
 
630
+               }
 
631
+
 
632
                if (server->defaults == NULL) {
 
633
                        if (prev == NULL)
 
634
                                ctx.root = server->next;
 
635
@@ -1852,8 +1938,8 @@
 
636
 
 
637
 void master_settings_dump(struct server_settings *set, bool nondefaults)
 
638
 {
 
639
-       const void *sets[4];
 
640
-       const char *set_names[4];
 
641
+       const void *sets[5];
 
642
+       const char *set_names[5];
 
643
        unsigned int count;
 
644
 
 
645
        sets[0] = &default_settings;
 
646
@@ -1872,6 +1958,11 @@
 
647
                sets[count] = set->pop3;
 
648
                set_names[count] = "pop3";
 
649
                count++;
 
650
+       }       
 
651
+       if (set->managesieve != NULL) {
 
652
+               sets[count] = set->managesieve;
 
653
+               set_names[count] = "managesieve";
 
654
+               count++;
 
655
        }
 
656
        settings_dump(setting_defs, sets, set_names, count, nondefaults, 0);
 
657
        namespace_settings_dump(set->namespaces, nondefaults);
 
658
diff -r ee1782019a60 src/master/master-settings.h
 
659
--- a/src/master/master-settings.h      Thu Nov 19 19:32:13 2009 -0500
 
660
+++ b/src/master/master-settings.h      Mon Nov 23 12:21:06 2009 +0100
 
661
@@ -4,10 +4,11 @@
 
662
 #include "network.h"
 
663
 
 
664
 enum mail_protocol {
 
665
-        MAIL_PROTOCOL_ANY,
 
666
-        MAIL_PROTOCOL_IMAP,
 
667
+       MAIL_PROTOCOL_ANY,
 
668
+       MAIL_PROTOCOL_IMAP,
 
669
        MAIL_PROTOCOL_POP3,
 
670
-       MAIL_PROTOCOL_LDA
 
671
+       MAIL_PROTOCOL_LDA,
 
672
+       MAIL_PROTOCOL_MANAGESIEVE
 
673
 };
 
674
 
 
675
 struct listener {
 
676
@@ -143,6 +144,11 @@
 
677
        const char *dict_db_config;
 
678
        unsigned int dict_process_count;
 
679
 
 
680
+       /* managesieve */
 
681
+       unsigned int managesieve_max_line_length;
 
682
+       const char *managesieve_logout_format;
 
683
+       const char *managesieve_implementation_string;
 
684
+
 
685
        /* .. */
 
686
        ARRAY_TYPE(listener) listens;
 
687
        ARRAY_TYPE(listener) ssl_listens;
 
688
@@ -151,6 +157,7 @@
 
689
        gid_t mail_gid_t, mail_priv_gid_t;
 
690
 
 
691
        const char *imap_generated_capability;
 
692
+       const char *managesieve_generated_capability;
 
693
 
 
694
        ARRAY_DEFINE(plugin_envs, const char *);
 
695
 };
 
696
@@ -256,9 +263,10 @@
 
697
        struct settings *defaults;
 
698
        struct settings *imap;
 
699
        struct settings *pop3;
 
700
+       struct settings *managesieve;
 
701
        struct auth_settings *auths;
 
702
        struct auth_settings auth_defaults;
 
703
-        struct namespace_settings *namespaces;
 
704
+       struct namespace_settings *namespaces;
 
705
 
 
706
        ARRAY_DEFINE(lda_settings, const char *);
 
707
        ARRAY_DEFINE(dicts, const char *);