2
## DP: Adds support for MANAGESIEVE
2
## DP: Adds support for ManageSieve
3
3
## DP: Author: Stephan Bosch <stephan@rename-it.nl>
5
# ManageSieve patch v0.10.5 for dovecot-1.1.11
6
6
# Copyright (c) 2006-2009 by Stephan Bosch <stephan@rename-it.nl>
7
# This patch is licenced under LGPLv2.1 (see COPYING.LGPL in the dovecot sources)
7
# This patch is licenced under LGPLv2.1
9
# Patch obtained from http://hg.rename-it.nl/dovecot-1.1-managesieve-patch/raw-file/f8e808e5a6f0/managesieve.patch
9
# Patch obtained from http://www.rename-it.nl/dovecot/1.2/dovecot-1.2.4-managesieve-0.11.9.diff.gz
11
11
. $(dirname $0)/DPATCH
15
diff -r 8cacf7ad431d README.managesieve
16
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
17
+++ b/README.managesieve Thu Feb 05 09:50:24 2009 +0100
20
+MANAGESIEVE service support patch for Dovecot 1.1
22
+NOTICE: As per dovecot-1.1, this patch only contains the changes to the
23
+Dovecot tree that are necessary to use the now external
24
+dovecot-1.1-managesieve package. So, applying this patch is no longer
25
+the only thing you need to do to give Dovecot managesieve support.
26
+Eventually the need for this patch will disappear completely.
31
+You can just use the usual build process
32
+(http://wiki.dovecot.org/CompilingSource):
38
+Don't forget to execute ./autogen.sh if you downloaded dovecot from the
39
+Mercurial repository.
41
+Installation and Configuration
42
+------------------------------
44
+Read the README of the dovecot-managesieve package for the next steps.
45
+Note that this patch adds configuration examples to the dovecot-example.conf
46
+configuration file example.
48
diff -r 8cacf7ad431d dovecot-example.conf
49
--- a/dovecot-example.conf Tue Feb 03 18:44:27 2009 -0500
50
+++ b/dovecot-example.conf Thu Feb 05 09:50:24 2009 +0100
15
Binary files dovecot-1.2.4.orig/dovecot-1.2.4-managesieve-0.11.9.diff.gz and dovecot-1.2.4/dovecot-1.2.4-managesieve-0.11.9.diff.gz differ
16
diff -urN dovecot-1.2.4.orig/dovecot-example.conf dovecot-1.2.4/dovecot-example.conf
17
--- dovecot-1.2.4.orig/dovecot-example.conf 2009-08-08 01:46:04.000000000 +0200
18
+++ dovecot-1.2.4/dovecot-example.conf 2009-08-29 17:20:49.000000000 +0200
52
20
# Base directory where to store runtime data.
53
21
#base_dir = /var/run/dovecot/
70
38
# ssl_listen = *:10943
43
+# protocol managesieve {
77
+# protocol managesieve {
49
# Disable LOGIN command and all other plaintext authentications unless
86
+## MANAGESIEVE specific settings
54
+## ManageSieve specific settings
89
57
+protocol managesieve {
90
58
+ # Login executable location.
91
59
+ #login_executable = /usr/libexec/dovecot/managesieve-login
93
+ # MANAGESIEVE executable location. See IMAP's mail_executable above for
61
+ # ManageSieve executable location. See IMAP's mail_executable above for
94
62
+ # examples how this could be changed.
95
63
+ #mail_executable = /usr/libexec/dovecot/managesieve
97
+ # Maximum MANAGESIEVE command line length in bytes. This setting is
65
+ # Maximum ManageSieve command line length in bytes. This setting is
98
66
+ # directly borrowed from IMAP. But, since long command lines are very
99
+ # unlikely with MANAGESIEVE, changing this will not be very useful.
67
+ # unlikely with ManageSieve, changing this will not be very useful.
100
68
+ #managesieve_max_line_length = 65536
102
+ # Specifies the location of the symlink pointing to the active script in
103
+ # the sieve storage directory. This must match the SIEVE setting used by
104
+ # deliver (refer to http://wiki.dovecot.org/LDA/Sieve#location for more
105
+ # info). Variable substitution with % is recognized.
106
+ sieve=~/.dovecot.sieve
108
+ # This specifies the path to the directory where the uploaded scripts must
109
+ # be stored. In terms of '%' variable substitution it is identical to
110
+ # dovecot's mail_location setting used by the mail protocol daemons.
111
+ sieve_storage=~/sieve
70
+ # ManageSieve logout format string:
71
+ # %i - total number of bytes read from client
72
+ # %o - total number of bytes sent to client
73
+ #managesieve_logout_format = bytes=%i/%o
113
75
+ # If, for some inobvious reason, the sieve_storage remains unset, the
114
+ # managesieve daemon uses the specification of the mail_location to find out
76
+ # ManageSieve daemon uses the specification of the mail_location to find out
115
77
+ # where to store the sieve files (see explaination in README.managesieve).
116
78
+ # The example below, when uncommented, overrides any global mail_location
117
79
+ # specification and stores all the scripts in '~/mail/sieve' if sieve_storage
118
80
+ # is unset. However, you should always use the sieve_storage setting.
119
81
+ # mail_location = mbox:~/mail
121
+ # To fool managesieve clients that are focused on timesieved you can
83
+ # To fool ManageSieve clients that are focused on timesieved you can
122
84
+ # specify the IMPLEMENTATION capability that the dovecot reports to clients
123
+ # (default: dovecot).
85
+ # (default: "dovecot").
124
86
+ #managesieve_implementation_string = Cyrus timsieved v2.2.13
128
90
## LDA specific settings
131
diff -r 8cacf7ad431d src/master/child-process.c
132
--- a/src/master/child-process.c Tue Feb 03 18:44:27 2009 -0500
133
+++ b/src/master/child-process.c Thu Feb 05 09:50:24 2009 +0100
93
@@ -1207,6 +1247,16 @@
94
# Available fields: uid, box, msgid, from, subject, size, vsize, flags
95
# size and vsize are available only for expunge and copy events.
96
#mail_log_fields = uid box msgid size
98
+ # Sieve plugin (http://wiki.dovecot.org/LDA/Sieve) and ManageSieve service
100
+ # Location of the active script. When ManageSieve is used this is actually
101
+ # a symlink pointing to the active script in the sieve storage directory.
102
+ #sieve=~/.dovecot.sieve
104
+ # The path to the directory where the personal Sieve scripts are stored. For
105
+ # ManageSieve this is where the uploaded scripts are stored.
109
# Config files can also be included:
110
diff -urN dovecot-1.2.4.orig/README.managesieve dovecot-1.2.4/README.managesieve
111
--- dovecot-1.2.4.orig/README.managesieve 1970-01-01 01:00:00.000000000 +0100
112
+++ dovecot-1.2.4/README.managesieve 2009-08-29 17:20:49.000000000 +0200
115
+MANAGESIEVE service support patch for Dovecot 1.2
117
+NOTICE: As per dovecot-1.1, this patch only contains the changes to the
118
+Dovecot tree that are necessary to use the now external
119
+dovecot-1.x-managesieve package. So, applying this patch is no longer
120
+the only thing you need to do to give Dovecot managesieve support.
121
+Eventually the need for this patch will disappear completely.
126
+After applying this patch you can just use the usual build process
127
+(http://wiki.dovecot.org/CompilingSource):
133
+Don't forget to execute ./autogen.sh if you downloaded dovecot from the
134
+Mercurial repository.
136
+Installation and Configuration
137
+------------------------------
139
+Read the README of the dovecot-managesieve package for the next steps.
140
+Note that this patch adds configuration examples to the dovecot-example.conf
141
+configuration file example.
143
diff -urN dovecot-1.2.4.orig/src/master/child-process.c dovecot-1.2.4/src/master/child-process.c
144
--- dovecot-1.2.4.orig/src/master/child-process.c 2009-04-28 22:01:59.000000000 +0200
145
+++ dovecot-1.2.4/src/master/child-process.c 2009-08-29 17:20:49.000000000 +0200
134
146
@@ -20,7 +20,8 @@
149
161
return "Out of memory - see mail_process_size setting";
150
162
case PROCESS_TYPE_UNKNOWN:
151
163
case PROCESS_TYPE_SSL_PARAM:
152
diff -r 8cacf7ad431d src/master/child-process.h
153
--- a/src/master/child-process.h Tue Feb 03 18:44:27 2009 -0500
154
+++ b/src/master/child-process.h Thu Feb 05 09:50:24 2009 +0100
166
case PROCESS_TYPE_IMAP:
167
case PROCESS_TYPE_POP3:
168
+ case PROCESS_TYPE_MANAGESIEVE:
169
#ifndef HAVE_PR_SET_DUMPABLE
170
if (!settings_root->defaults->mail_drop_priv_before_exec) {
171
str_append(str, " (core not dumped - set mail_drop_priv_before_exec=yes)");
172
diff -urN dovecot-1.2.4.orig/src/master/child-process.h dovecot-1.2.4/src/master/child-process.h
173
--- dovecot-1.2.4.orig/src/master/child-process.h 2009-02-23 19:26:01.000000000 +0100
174
+++ dovecot-1.2.4/src/master/child-process.h 2009-08-29 17:20:49.000000000 +0200
155
175
@@ -10,6 +10,7 @@
156
176
PROCESS_TYPE_POP3,
157
177
PROCESS_TYPE_SSL_PARAM,
163
diff -r 8cacf7ad431d src/master/listener.c
164
--- a/src/master/listener.c Tue Feb 03 18:44:27 2009 -0500
165
+++ b/src/master/listener.c Thu Feb 05 09:50:24 2009 +0100
183
diff -urN dovecot-1.2.4.orig/src/master/listener.c dovecot-1.2.4/src/master/listener.c
184
--- dovecot-1.2.4.orig/src/master/listener.c 2009-06-05 00:28:14.000000000 +0200
185
+++ dovecot-1.2.4/src/master/listener.c 2009-08-29 17:20:49.000000000 +0200
167
187
check_conflicts_set(server->pop3, ip, port,
238
diff -r 8cacf7ad431d src/master/login-process.c
239
--- a/src/master/login-process.c Tue Feb 03 18:44:27 2009 -0500
240
+++ b/src/master/login-process.c Thu Feb 05 09:50:24 2009 +0100
258
diff -urN dovecot-1.2.4.orig/src/master/login-process.c dovecot-1.2.4/src/master/login-process.c
259
--- dovecot-1.2.4.orig/src/master/login-process.c 2009-04-28 22:01:59.000000000 +0200
260
+++ dovecot-1.2.4/src/master/login-process.c 2009-08-29 17:20:49.000000000 +0200
242
262
group = i_new(struct login_group, 1);
243
263
group->refcount = 1;
244
264
group->set = set;
280
300
i_error("login: Unknown protocol '%s'", proto);
283
303
*set->imap_capability != '\0' ?
284
304
set->imap_capability :
285
305
set->imap_generated_capability, NULL));
286
306
+ } else if (group->mail_process_type == PROCESS_TYPE_MANAGESIEVE) {
307
+ env_put(t_strconcat("CAPABILITY_STRING=",
308
+ set->managesieve_generated_capability, NULL));
287
309
+ env_put(t_strconcat("MANAGESIEVE_IMPLEMENTATION_STRING=",
288
+ set->managesieve_implementation_string, NULL));
310
+ set->managesieve_implementation_string, NULL));
290
env_put(t_strconcat("LOGIN_DIR=", set->login_dir, NULL));
292
diff -r 8cacf7ad431d src/master/mail-process.c
293
--- a/src/master/mail-process.c Tue Feb 03 18:44:27 2009 -0500
294
+++ b/src/master/mail-process.c Thu Feb 05 09:50:24 2009 +0100
313
if (*set->login_trusted_networks != '\0') {
314
env_put(t_strconcat("TRUSTED_NETWORKS=",
315
set->login_trusted_networks, NULL));
316
diff -urN dovecot-1.2.4.orig/src/master/mail-process.c dovecot-1.2.4/src/master/mail-process.c
317
--- dovecot-1.2.4.orig/src/master/mail-process.c 2009-08-08 01:46:04.000000000 +0200
318
+++ dovecot-1.2.4/src/master/mail-process.c 2009-08-29 17:20:49.000000000 +0200
296
320
/* We care about POP3 UIDL format in all process types */
297
321
env_put(t_strconcat("POP3_UIDL_FORMAT=", set->pop3_uidl_format, NULL));
299
323
+ if (set->protocol == MAIL_PROTOCOL_MANAGESIEVE) {
300
324
+ env_put(t_strdup_printf("MANAGESIEVE_MAX_LINE_LENGTH=%u",
301
325
+ set->managesieve_max_line_length));
326
+ env_put(t_strconcat("MANAGESIEVE_LOGOUT_FORMAT=",
327
+ set->managesieve_logout_format, NULL));
302
328
+ env_put(t_strconcat("MANAGESIEVE_IMPLEMENTATION_STRING=",
303
329
+ set->managesieve_implementation_string, NULL));
306
+ /* Set sieve environment
307
+ * FIXME: Currently just uses the expand_mail_env function to
308
+ * substitute variables and home dir. Technically, that function
309
+ * is not meant for the sieve implementation.
311
+ if ( set->sieve_storage != NULL ) {
312
+ env_put(t_strconcat("SIEVE_STORAGE=",
313
+ expand_mail_env(set->sieve_storage, var_expand_table), NULL));
315
+ if (set->sieve != NULL) {
316
+ env_put(t_strconcat("SIEVE=",
317
+ expand_mail_env(set->sieve, var_expand_table), NULL));
320
332
if (set->mail_save_crlf)
321
333
env_put("MAIL_SAVE_CRLF=1");
322
334
if (set->mmap_disable)
324
336
set = server->imap;
325
337
else if (strcmp(protocol, "pop3") == 0)
326
338
set = server->pop3;
350
362
void mail_processes_deinit(void)
351
diff -r 8cacf7ad431d src/master/main.c
352
--- a/src/master/main.c Tue Feb 03 18:44:27 2009 -0500
353
+++ b/src/master/main.c Thu Feb 05 09:50:24 2009 +0100
355
if (server->imap != NULL && have_stderr_set(server->imap))
363
diff -urN dovecot-1.2.4.orig/src/master/main.c dovecot-1.2.4/src/master/main.c
364
--- dovecot-1.2.4.orig/src/master/main.c 2009-05-20 23:48:16.000000000 +0200
365
+++ dovecot-1.2.4/src/master/main.c 2009-08-29 17:20:49.000000000 +0200
357
368
if (server->pop3 != NULL && have_stderr_set(server->pop3))
370
+ if (server->managesieve != NULL && have_stderr_set(server->managesieve))
359
+ if (server->managesieve != NULL && have_stderr_set(server->managesieve))
362
373
server = server->next;
363
diff -r 8cacf7ad431d src/master/master-settings-defs.c
364
--- a/src/master/master-settings-defs.c Tue Feb 03 18:44:27 2009 -0500
365
+++ b/src/master/master-settings-defs.c Thu Feb 05 09:50:24 2009 +0100
368
DEF_STR(dict_db_config),
371
+ DEF_INT(managesieve_max_line_length),
372
+ DEF_STR(managesieve_implementation_string),
375
+ DEF_STR(sieve_storage),
380
diff -r 8cacf7ad431d src/master/master-settings.c
381
--- a/src/master/master-settings.c Tue Feb 03 18:44:27 2009 -0500
382
+++ b/src/master/master-settings.c Thu Feb 05 09:50:24 2009 +0100
375
diff -urN dovecot-1.2.4.orig/src/master/master-settings.c dovecot-1.2.4/src/master/master-settings.c
376
--- dovecot-1.2.4.orig/src/master/master-settings.c 2009-08-08 01:46:04.000000000 +0200
377
+++ dovecot-1.2.4/src/master/master-settings.c 2009-08-29 17:20:49.000000000 +0200
385
379
MEMBER(dict_db_config) NULL,
380
MEMBER(dict_process_count) 1,
387
382
+ /* managesieve */
388
383
+ MEMBER(managesieve_max_line_length) 65536,
384
+ MEMBER(managesieve_logout_format) "bytes=%i/%o",
389
385
+ MEMBER(managesieve_implementation_string) PACKAGE,
392
+ MEMBER(sieve_storage) "",
393
+ MEMBER(sieve) NULL,
399
391
auth->parent->pop3->ssl_verify_client_cert = TRUE;
400
392
if (auth->parent->imap != NULL)
401
393
auth->parent->imap->ssl_verify_client_cert = TRUE;
406
398
for (s = auth->sockets; s != NULL; s = s->next) {
408
if (set->protocol == MAIL_PROTOCOL_IMAP) {
399
@@ -555,12 +562,21 @@
403
- if (set->protocol == MAIL_PROTOCOL_IMAP) {
404
+ switch ( set->protocol ) {
405
+ case MAIL_PROTOCOL_IMAP:
409
406
if (strstr(set->protocols, "imap") == NULL)
411
+ } else if (set->protocol == MAIL_PROTOCOL_POP3) {
412
+ if (strstr(set->protocols, "pop3") == NULL)
415
- if (strstr(set->protocols, "pop3") == NULL)
410
+ case MAIL_PROTOCOL_POP3:
411
if (strstr(set->protocols, "pop3") == NULL)
414
+ case MAIL_PROTOCOL_MANAGESIEVE:
416
415
+ if (strstr(set->protocols, "managesieve") == NULL)
424
(void)closedir(dirp);
429
get_process_capability(enum process_type ptype, struct settings *set)
432
return i_strdup(buf);
436
static bool get_imap_capability(struct settings *set)
438
static const char *generated_capability = NULL;
443
+static bool get_managesieve_capability(struct settings *set)
445
+ static const char *generated_capability = NULL;
447
+ if (generated_capability != NULL) {
448
+ /* See get_imap_capability above.. */
449
+ set->managesieve_generated_capability =
450
+ p_strdup(settings_pool, generated_capability);
454
+ generated_capability = get_process_capability(PROCESS_TYPE_MANAGESIEVE, set);
455
+ if (generated_capability == NULL)
458
+ set->managesieve_generated_capability =
459
+ p_strdup(settings_pool, generated_capability);
463
static bool settings_verify(struct settings *set)
466
@@ -965,6 +1001,11 @@
467
strstr(set->server->imap->login_executable, " -D");
468
if (p != NULL && p[3] == '\0')
470
+ p = set->server->managesieve == NULL ? NULL :
471
+ strstr(set->server->managesieve->login_executable, " -D");
472
+ if (p != NULL && p[3] == '\0')
478
@@ -1016,6 +1057,10 @@
420
@@ -1178,7 +1191,7 @@
422
if (strcmp(key, "login") == 0) {
423
i_warning("Ignoring deprecated 'login' section handling. "
424
- "Use protocol imap/pop3 { .. } instead. "
425
+ "Use protocol imap/pop3/managesieve { .. } instead. "
426
"Some settings may have been read incorrectly.");
429
@@ -1201,6 +1214,15 @@
430
error = parse_setting_from_defs(settings_pool,
482
+ if ( set->protocol == MAIL_PROTOCOL_MANAGESIEVE ) {
483
+ if (!get_managesieve_capability(set))
489
@@ -1251,6 +1296,15 @@
490
array_append(&ctx->server->lda_settings, &value, 1);
436
493
+ if (error == NULL &&
437
494
+ (ctx->protocol == MAIL_PROTOCOL_ANY ||
438
495
+ ctx->protocol == MAIL_PROTOCOL_MANAGESIEVE)) {
439
496
+ error = parse_setting_from_defs(settings_pool,
441
498
+ ctx->server->managesieve,
445
@@ -1262,6 +1284,13 @@
505
@@ -1309,6 +1363,13 @@
446
506
array_append(&ctx->server->pop3->plugin_envs,
478
538
+ *server->managesieve = *managesieve_defaults;
480
540
p_array_init(&server->dicts, settings_pool, 4);
541
p_array_init(&server->lda_settings, settings_pool, 12);
481
542
p_array_init(&server->imap->plugin_envs, settings_pool, 8);
482
543
p_array_init(&server->pop3->plugin_envs, settings_pool, 8);
483
544
+ p_array_init(&server->managesieve->plugin_envs, settings_pool, 8);
485
546
server->imap->server = server;
486
547
server->imap->protocol = MAIL_PROTOCOL_IMAP;
487
@@ -1300,6 +1333,12 @@
548
@@ -1348,6 +1413,12 @@
488
549
server->pop3->mail_executable = PKG_LIBEXECDIR"/pop3";
489
550
server->pop3->mail_plugin_dir = MODULEDIR"/pop3";
535
596
ctx.auth = &ctx.server->auth_defaults;
537
598
if (!settings_read(path, NULL, parse_setting, parse_section, &ctx))
538
@@ -1521,7 +1564,9 @@
599
@@ -1570,7 +1645,8 @@
540
601
if (!nochecks && !nofixes) {
541
ctx.root->defaults = settings_is_active(ctx.root->imap) ?
602
def = settings_is_active(ctx.root->imap) ?
542
603
- ctx.root->imap : ctx.root->pop3;
544
+ (settings_is_active(ctx.root->pop3) ?
545
+ ctx.root->pop3 : ctx.root->managesieve);
604
+ ctx.root->imap : ( settings_is_active(ctx.root->pop3) ?
605
+ ctx.root->pop3 : ctx.root->managesieve );
547
path = t_strconcat(ctx.root->defaults->base_dir,
548
"/master.pid", NULL);
549
@@ -1531,7 +1576,8 @@
607
path = t_strconcat(def->base_dir, "/master.pid", NULL);
608
pid_file_check_running(path);
609
@@ -1579,7 +1655,8 @@
551
611
for (server = ctx.root; server != NULL; server = server->next) {
552
612
if ((*server->imap->protocols == '\0' ||
583
643
unsigned int count;
585
645
sets[0] = &default_settings;
586
@@ -1798,6 +1853,11 @@
587
if (set->pop3 != NULL) {
646
@@ -1863,6 +1949,11 @@
588
647
sets[count] = set->pop3;
589
648
set_names[count] = "pop3";
592
651
+ if (set->managesieve != NULL) {
593
652
+ sets[count] = set->managesieve;
594
653
+ set_names[count] = "managesieve";
597
656
settings_dump(setting_defs, sets, set_names, count, nondefaults, 0);
598
diff -r 8cacf7ad431d src/master/master-settings.h
599
--- a/src/master/master-settings.h Tue Feb 03 18:44:27 2009 -0500
600
+++ b/src/master/master-settings.h Thu Feb 05 09:50:24 2009 +0100
657
namespace_settings_dump(set->namespaces, nondefaults);
658
diff -urN dovecot-1.2.4.orig/src/master/master-settings-defs.c dovecot-1.2.4/src/master/master-settings-defs.c
659
--- dovecot-1.2.4.orig/src/master/master-settings-defs.c 2009-04-28 22:01:59.000000000 +0200
660
+++ dovecot-1.2.4/src/master/master-settings-defs.c 2009-08-29 17:20:49.000000000 +0200
662
DEF_STR(dict_db_config),
663
DEF_INT(dict_process_count),
666
+ DEF_INT(managesieve_max_line_length),
667
+ DEF_STR(managesieve_logout_format),
668
+ DEF_STR(managesieve_implementation_string),
672
diff -urN dovecot-1.2.4.orig/src/master/master-settings.h dovecot-1.2.4/src/master/master-settings.h
673
--- dovecot-1.2.4.orig/src/master/master-settings.h 2009-08-08 01:46:04.000000000 +0200
674
+++ dovecot-1.2.4/src/master/master-settings.h 2009-08-29 17:20:49.000000000 +0200
601
675
@@ -4,10 +4,11 @@
602
676
#include "network.h"
615
689
struct listener {
618
691
const char *dict_db_config;
692
unsigned int dict_process_count;
620
694
+ /* managesieve */
621
695
+ unsigned int managesieve_max_line_length;
696
+ const char *managesieve_logout_format;
622
697
+ const char *managesieve_implementation_string;
625
+ const char *sieve_storage;
629
700
ARRAY_TYPE(listener) listens;
630
701
ARRAY_TYPE(listener) ssl_listens;
703
gid_t mail_gid_t, mail_priv_gid_t;
705
const char *imap_generated_capability;
706
+ const char *managesieve_generated_capability;
708
ARRAY_DEFINE(plugin_envs, const char *);
632
711
struct settings *defaults;
633
712
struct settings *imap;
634
713
struct settings *pop3;