Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/deliver/deliver.c @ 5616:0d6cd7281aa7 HEAD
Added quota_full_tempfail setting.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 13 May 2007 20:33:00 +0300 |
parents | f717fb4b31c0 |
children | e41accd3d6f1 |
rev | line source |
---|---|
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
1 /* Copyright (C) 2005-2006 Timo Sirainen */ |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
2 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
3 #include "lib.h" |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
4 #include "lib-signals.h" |
4876
f1d77064884c
Lock handling changes. Everything goes through file-lock API now and there's
Timo Sirainen <tss@iki.fi>
parents:
4848
diff
changeset
|
5 #include "file-lock.h" |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
6 #include "ioloop.h" |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
7 #include "hostpid.h" |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
8 #include "home-expand.h" |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
9 #include "env-util.h" |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
10 #include "fd-set-nonblock.h" |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
11 #include "istream.h" |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
12 #include "istream-seekable.h" |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
13 #include "module-dir.h" |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
14 #include "str.h" |
4637
0af548f101f8
Log all mail saves and save failures.
Timo Sirainen <tss@iki.fi>
parents:
4636
diff
changeset
|
15 #include "str-sanitize.h" |
5050
167c602ef8b4
If config file contained quoted "value", the quotes weren't stripped.
Timo Sirainen <tss@iki.fi>
parents:
5049
diff
changeset
|
16 #include "strescape.h" |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
17 #include "var-expand.h" |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
18 #include "message-address.h" |
5210
b77a67169fc5
While parsing the input stream ignore the mbox hidden headers so that eg.
Timo Sirainen <tss@iki.fi>
parents:
5186
diff
changeset
|
19 #include "istream-header-filter.h" |
b77a67169fc5
While parsing the input stream ignore the mbox hidden headers so that eg.
Timo Sirainen <tss@iki.fi>
parents:
5186
diff
changeset
|
20 #include "mbox-storage.h" |
5500
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
21 #include "mail-namespace.h" |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
22 #include "dict-client.h" |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
23 #include "mbox-from.h" |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
24 #include "auth-client.h" |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
25 #include "mail-send.h" |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
26 #include "duplicate.h" |
5050
167c602ef8b4
If config file contained quoted "value", the quotes weren't stripped.
Timo Sirainen <tss@iki.fi>
parents:
5049
diff
changeset
|
27 #include "../master/syslog-util.h" |
167c602ef8b4
If config file contained quoted "value", the quotes weren't stripped.
Timo Sirainen <tss@iki.fi>
parents:
5049
diff
changeset
|
28 #include "../master/syslog-util.c" /* ugly, ugly.. */ |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
29 #include "deliver.h" |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
30 |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
31 #include <stdio.h> |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
32 #include <stdlib.h> |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
33 #include <unistd.h> |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
34 #include <fcntl.h> |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
35 #include <pwd.h> |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
36 #include <syslog.h> |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
37 |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
38 #define DEFAULT_CONFIG_FILE SYSCONFDIR"/dovecot.conf" |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
39 #define DEFAULT_AUTH_SOCKET_PATH PKG_RUNDIR"/auth-master" |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
40 #define DEFAULT_SENDMAIL_PATH "/usr/lib/sendmail" |
4725
af8caaba0f67
Don't crash with -f "". Changed the default from envelope to be
Timo Sirainen <tss@iki.fi>
parents:
4701
diff
changeset
|
41 #define DEFAULT_ENVELOPE_SENDER "MAILER-DAEMON" |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
42 |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
43 /* After buffer grows larger than this, create a temporary file to /tmp |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
44 where to read the mail. */ |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
45 #define MAIL_MAX_MEMORY_BUFFER (1024*128) |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
46 |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
47 struct deliver_settings *deliver_set; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
48 deliver_mail_func_t *deliver_mail = NULL; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
49 |
5143
5a0506cb73c5
Don't bother trying to save the mail twice into the default mailbox (eg. if it's
Timo Sirainen <tss@iki.fi>
parents:
5141
diff
changeset
|
50 /* FIXME: these two should be in some context struct instead of as globals.. */ |
5a0506cb73c5
Don't bother trying to save the mail twice into the default mailbox (eg. if it's
Timo Sirainen <tss@iki.fi>
parents:
5141
diff
changeset
|
51 static const char *default_mailbox_name = NULL; |
5a0506cb73c5
Don't bother trying to save the mail twice into the default mailbox (eg. if it's
Timo Sirainen <tss@iki.fi>
parents:
5141
diff
changeset
|
52 static bool tried_default_save = FALSE; |
5351
5220d4e6690d
Ignore -m "" parameter. Added -n option to not autocreate the mailbox. If
Timo Sirainen <tss@iki.fi>
parents:
5333
diff
changeset
|
53 static bool no_mailbox_autocreate = FALSE; |
5143
5a0506cb73c5
Don't bother trying to save the mail twice into the default mailbox (eg. if it's
Timo Sirainen <tss@iki.fi>
parents:
5141
diff
changeset
|
54 |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
55 static struct module *modules; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
56 static struct ioloop *ioloop; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
57 |
3620
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3389
diff
changeset
|
58 static void sig_die(int signo, void *context __attr_unused__) |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
59 { |
3620
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3389
diff
changeset
|
60 /* warn about being killed because of some signal, except SIGINT (^C) |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3389
diff
changeset
|
61 which is too common at least while testing :) */ |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3389
diff
changeset
|
62 if (signo != SIGINT) |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3389
diff
changeset
|
63 i_warning("Killed with signal %d", signo); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
64 io_loop_stop(ioloop); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
65 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
66 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
67 static int sync_quick(struct mailbox *box) |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
68 { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
69 struct mailbox_sync_context *ctx; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
70 struct mailbox_sync_rec sync_rec; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
71 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
72 ctx = mailbox_sync_init(box, 0); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
73 while (mailbox_sync_next(ctx, &sync_rec) > 0) |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
74 ; |
4848
967de900c73a
Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
4843
diff
changeset
|
75 return mailbox_sync_deinit(&ctx, 0, NULL); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
76 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
77 |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
78 static struct mailbox * |
5500
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
79 mailbox_open_or_create_synced(struct mail_namespace *namespaces, |
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
80 struct mail_storage **storage_r, const char *name) |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
81 { |
5500
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
82 struct mail_namespace *ns; |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
83 struct mailbox *box; |
5613 | 84 enum mail_error error; |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
85 |
5500
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
86 ns = mail_namespace_find(namespaces, &name); |
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
87 if (ns == NULL) { |
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
88 *storage_r = NULL; |
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
89 return NULL; |
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
90 } |
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
91 *storage_r = ns->storage; |
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
92 |
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
93 box = mailbox_open(ns->storage, name, NULL, MAILBOX_OPEN_FAST | |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
94 MAILBOX_OPEN_KEEP_RECENT); |
5351
5220d4e6690d
Ignore -m "" parameter. Added -n option to not autocreate the mailbox. If
Timo Sirainen <tss@iki.fi>
parents:
5333
diff
changeset
|
95 if (box != NULL || no_mailbox_autocreate) |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
96 return box; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
97 |
5613 | 98 (void)mail_storage_get_last_error(ns->storage, &error); |
99 if (error != MAIL_ERROR_NOTFOUND) | |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
100 return NULL; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
101 |
5613 | 102 /* try creating it. */ |
5500
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
103 if (mail_storage_mailbox_create(ns->storage, name, FALSE) < 0) |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
104 return NULL; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
105 |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
106 /* and try opening again */ |
5500
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
107 box = mailbox_open(ns->storage, name, NULL, MAILBOX_OPEN_FAST | |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
108 MAILBOX_OPEN_KEEP_RECENT); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
109 if (box == NULL) |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
110 return NULL; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
111 |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
112 if (sync_quick(box) < 0) { |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
113 mailbox_close(&box); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
114 return NULL; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
115 } |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
116 return box; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
117 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
118 |
5500
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
119 int deliver_save(struct mail_namespace *namespaces, |
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
120 struct mail_storage **storage_r, const char *mailbox, |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
121 struct mail *mail, enum mail_flags flags, |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
122 const char *const *keywords) |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
123 { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
124 struct mailbox *box; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
125 struct mailbox_transaction_context *t; |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
126 struct mail_keywords *kw; |
4637
0af548f101f8
Log all mail saves and save failures.
Timo Sirainen <tss@iki.fi>
parents:
4636
diff
changeset
|
127 const char *msgid; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
128 int ret = 0; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
129 |
5143
5a0506cb73c5
Don't bother trying to save the mail twice into the default mailbox (eg. if it's
Timo Sirainen <tss@iki.fi>
parents:
5141
diff
changeset
|
130 if (strcmp(mailbox, default_mailbox_name) == 0) |
5a0506cb73c5
Don't bother trying to save the mail twice into the default mailbox (eg. if it's
Timo Sirainen <tss@iki.fi>
parents:
5141
diff
changeset
|
131 tried_default_save = TRUE; |
5a0506cb73c5
Don't bother trying to save the mail twice into the default mailbox (eg. if it's
Timo Sirainen <tss@iki.fi>
parents:
5141
diff
changeset
|
132 |
5500
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
133 box = mailbox_open_or_create_synced(namespaces, storage_r, mailbox); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
134 if (box == NULL) |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
135 return -1; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
136 |
3209
923ff19873d4
Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents:
3199
diff
changeset
|
137 t = mailbox_transaction_begin(box, MAILBOX_TRANSACTION_FLAG_EXTERNAL); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
138 |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
139 kw = strarray_length(keywords) == 0 ? NULL : |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
140 mailbox_keywords_create(t, keywords); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
141 if (mailbox_copy(t, mail, flags, kw, NULL) < 0) |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
142 ret = -1; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
143 mailbox_keywords_free(t, &kw); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
144 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
145 if (ret < 0) |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
146 mailbox_transaction_rollback(&t); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
147 else |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
148 ret = mailbox_transaction_commit(&t, 0); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
149 |
4637
0af548f101f8
Log all mail saves and save failures.
Timo Sirainen <tss@iki.fi>
parents:
4636
diff
changeset
|
150 msgid = mail_get_first_header(mail, "Message-ID"); |
0af548f101f8
Log all mail saves and save failures.
Timo Sirainen <tss@iki.fi>
parents:
4636
diff
changeset
|
151 i_info(ret < 0 ? "msgid=%s: save failed to %s" : |
0af548f101f8
Log all mail saves and save failures.
Timo Sirainen <tss@iki.fi>
parents:
4636
diff
changeset
|
152 "msgid=%s: saved mail to %s", |
0af548f101f8
Log all mail saves and save failures.
Timo Sirainen <tss@iki.fi>
parents:
4636
diff
changeset
|
153 msgid == NULL ? "" : str_sanitize(msgid, 80), |
0af548f101f8
Log all mail saves and save failures.
Timo Sirainen <tss@iki.fi>
parents:
4636
diff
changeset
|
154 str_sanitize(mailbox_get_name(box), 80)); |
0af548f101f8
Log all mail saves and save failures.
Timo Sirainen <tss@iki.fi>
parents:
4636
diff
changeset
|
155 |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
156 mailbox_close(&box); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
157 return ret; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
158 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
159 |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
160 const char *deliver_get_return_address(struct mail *mail) |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
161 { |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
162 struct message_address *addr; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
163 const char *str; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
164 |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
165 str = mail_get_first_header(mail, "Return-Path"); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
166 addr = str == NULL ? NULL : |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
167 message_address_parse(pool_datastack_create(), |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
168 (const unsigned char *)str, |
4636
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
169 strlen(str), 1, FALSE); |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
170 return addr == NULL || addr->mailbox == NULL || addr->domain == NULL ? |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
171 NULL : t_strconcat(addr->mailbox, "@", addr->domain, NULL); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
172 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
173 |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
174 const char *deliver_get_new_message_id(void) |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
175 { |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
176 static int count = 0; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
177 |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
178 return t_strdup_printf("<dovecot-%s-%s-%d@%s>", |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
179 dec2str(ioloop_timeval.tv_sec), |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
180 dec2str(ioloop_timeval.tv_usec), |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
181 count++, deliver_set->hostname); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
182 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
183 |
4963
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
184 #include "settings.h" |
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
185 #include "../master/master-settings.h" |
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
186 #include "../master/master-settings-defs.c" |
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
187 |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
188 #define IS_WHITE(c) ((c) == ' ' || (c) == '\t') |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
189 |
4963
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
190 static bool setting_is_bool(const char *name) |
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
191 { |
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
192 const struct setting_def *def; |
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
193 |
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
194 for (def = setting_defs; def->name != NULL; def++) { |
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
195 if (strcmp(def->name, name) == 0) |
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
196 return def->type == SET_BOOL; |
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
197 } |
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
198 return FALSE; |
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
199 } |
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
200 |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
201 static void config_file_init(const char *path) |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
202 { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
203 struct istream *input; |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
204 const char *key, *value; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
205 char *line, *p, quote; |
5166
cc8b33172a86
Get pop3_uidl_format even if it's inside protocol pop3 {}
Timo Sirainen <tss@iki.fi>
parents:
5148
diff
changeset
|
206 int fd, sections = 0, lda_section = FALSE, pop3_section = FALSE; |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
207 size_t len; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
208 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
209 fd = open(path, O_RDONLY); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
210 if (fd < 0) |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
211 i_fatal_status(EX_CONFIG, "open(%s) failed: %m", path); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
212 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
213 t_push(); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
214 input = i_stream_create_file(fd, default_pool, 1024, TRUE); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
215 while ((line = i_stream_read_next_line(input)) != NULL) { |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
216 /* @UNSAFE: line is modified */ |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
217 |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
218 /* skip whitespace */ |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
219 while (IS_WHITE(*line)) |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
220 line++; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
221 |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
222 /* ignore comments or empty lines */ |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
223 if (*line == '#' || *line == '\0') |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
224 continue; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
225 |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
226 /* strip away comments. pretty kludgy way really.. */ |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
227 for (p = line; *p != '\0'; p++) { |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
228 if (*p == '\'' || *p == '"') { |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
229 quote = *p; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
230 for (p++; *p != quote && *p != '\0'; p++) { |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
231 if (*p == '\\' && p[1] != '\0') |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
232 p++; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
233 } |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
234 if (*p == '\0') |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
235 break; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
236 } else if (*p == '#') { |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
237 *p = '\0'; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
238 break; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
239 } |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
240 } |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
241 |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
242 /* remove whitespace from end of line */ |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
243 len = strlen(line); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
244 while (IS_WHITE(line[len-1])) |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
245 len--; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
246 line[len] = '\0'; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
247 |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
248 value = p = strchr(line, '='); |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
249 if (value == NULL) { |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
250 if (strchr(line, '{') != NULL) { |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
251 if (strcmp(line, "protocol lda {") == 0 || |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
252 strcmp(line, "plugin {") == 0) |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
253 lda_section = TRUE; |
5166
cc8b33172a86
Get pop3_uidl_format even if it's inside protocol pop3 {}
Timo Sirainen <tss@iki.fi>
parents:
5148
diff
changeset
|
254 if (strcmp(line, "protocol pop3 {") == 0) |
cc8b33172a86
Get pop3_uidl_format even if it's inside protocol pop3 {}
Timo Sirainen <tss@iki.fi>
parents:
5148
diff
changeset
|
255 pop3_section = TRUE; |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
256 sections++; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
257 } |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
258 if (*line == '}') { |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
259 sections--; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
260 lda_section = FALSE; |
5166
cc8b33172a86
Get pop3_uidl_format even if it's inside protocol pop3 {}
Timo Sirainen <tss@iki.fi>
parents:
5148
diff
changeset
|
261 pop3_section = FALSE; |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
262 } |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
263 continue; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
264 } |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
265 |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
266 while (p > line && p[-1] == ' ') p--; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
267 key = t_strdup_until(line, p); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
268 |
5166
cc8b33172a86
Get pop3_uidl_format even if it's inside protocol pop3 {}
Timo Sirainen <tss@iki.fi>
parents:
5148
diff
changeset
|
269 if (sections > 0 && !lda_section) { |
cc8b33172a86
Get pop3_uidl_format even if it's inside protocol pop3 {}
Timo Sirainen <tss@iki.fi>
parents:
5148
diff
changeset
|
270 if (!pop3_section || |
cc8b33172a86
Get pop3_uidl_format even if it's inside protocol pop3 {}
Timo Sirainen <tss@iki.fi>
parents:
5148
diff
changeset
|
271 strcmp(key, "pop3_uidl_format") != 0) |
cc8b33172a86
Get pop3_uidl_format even if it's inside protocol pop3 {}
Timo Sirainen <tss@iki.fi>
parents:
5148
diff
changeset
|
272 continue; |
cc8b33172a86
Get pop3_uidl_format even if it's inside protocol pop3 {}
Timo Sirainen <tss@iki.fi>
parents:
5148
diff
changeset
|
273 } |
cc8b33172a86
Get pop3_uidl_format even if it's inside protocol pop3 {}
Timo Sirainen <tss@iki.fi>
parents:
5148
diff
changeset
|
274 |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
275 do { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
276 value++; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
277 } while (*value == ' '); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
278 |
5050
167c602ef8b4
If config file contained quoted "value", the quotes weren't stripped.
Timo Sirainen <tss@iki.fi>
parents:
5049
diff
changeset
|
279 len = strlen(value); |
167c602ef8b4
If config file contained quoted "value", the quotes weren't stripped.
Timo Sirainen <tss@iki.fi>
parents:
5049
diff
changeset
|
280 if (len > 0 && |
167c602ef8b4
If config file contained quoted "value", the quotes weren't stripped.
Timo Sirainen <tss@iki.fi>
parents:
5049
diff
changeset
|
281 ((*value == '"' && value[len-1] == '"') || |
167c602ef8b4
If config file contained quoted "value", the quotes weren't stripped.
Timo Sirainen <tss@iki.fi>
parents:
5049
diff
changeset
|
282 (*value == '\'' && value[len-1] == '\''))) { |
167c602ef8b4
If config file contained quoted "value", the quotes weren't stripped.
Timo Sirainen <tss@iki.fi>
parents:
5049
diff
changeset
|
283 value = str_unescape(p_strndup(unsafe_data_stack_pool, |
167c602ef8b4
If config file contained quoted "value", the quotes weren't stripped.
Timo Sirainen <tss@iki.fi>
parents:
5049
diff
changeset
|
284 value+1, len - 2)); |
167c602ef8b4
If config file contained quoted "value", the quotes weren't stripped.
Timo Sirainen <tss@iki.fi>
parents:
5049
diff
changeset
|
285 } |
4963
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
286 if (setting_is_bool(key) && strcasecmp(value, "yes") != 0) |
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
287 continue; |
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
288 |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
289 env_put(t_strconcat(t_str_ucase(key), "=", value, NULL)); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
290 } |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
291 i_stream_unref(&input); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
292 t_pop(); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
293 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
294 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
295 static const struct var_expand_table * |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
296 get_var_expand_table(const char *user, const char *home) |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
297 { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
298 static struct var_expand_table static_tab[] = { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
299 { 'u', NULL }, |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
300 { 'n', NULL }, |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
301 { 'd', NULL }, |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
302 { 's', NULL }, |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
303 { 'h', NULL }, |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
304 { 'l', NULL }, |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
305 { 'r', NULL }, |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
306 { 'p', NULL }, |
4625 | 307 { 'i', NULL }, |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
308 { '\0', NULL } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
309 }; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
310 struct var_expand_table *tab; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
311 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
312 tab = t_malloc(sizeof(static_tab)); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
313 memcpy(tab, static_tab, sizeof(static_tab)); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
314 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
315 tab[0].value = user; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
316 tab[1].value = t_strcut(user, '@'); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
317 tab[2].value = strchr(user, '@'); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
318 if (tab[2].value != NULL) tab[2].value++; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
319 tab[3].value = "DELIVER"; |
4652
3da6580bb0ed
Don't require home directory to be given. If debug is enabled, log what we
Timo Sirainen <tss@iki.fi>
parents:
4647
diff
changeset
|
320 tab[4].value = home != NULL ? home : |
3da6580bb0ed
Don't require home directory to be given. If debug is enabled, log what we
Timo Sirainen <tss@iki.fi>
parents:
4647
diff
changeset
|
321 "/HOME_DIRECTORY_USED_BUT_NOT_GIVEN_BY_USERDB"; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
322 tab[5].value = NULL; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
323 tab[6].value = NULL; |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
324 tab[7].value = my_pid; |
4625 | 325 tab[8].value = dec2str(geteuid()); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
326 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
327 return tab; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
328 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
329 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
330 static const char * |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
331 expand_mail_env(const char *env, const struct var_expand_table *table) |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
332 { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
333 string_t *str; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
334 const char *p; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
335 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
336 str = t_str_new(256); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
337 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
338 /* it's either type:data or just data */ |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
339 p = strchr(env, ':'); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
340 if (p != NULL) { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
341 while (env != p) { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
342 str_append_c(str, *env); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
343 env++; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
344 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
345 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
346 str_append_c(str, *env++); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
347 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
348 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
349 if (env[0] == '~' && env[1] == '/') { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
350 /* expand home */ |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
351 env = t_strconcat("%h", env+1, NULL); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
352 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
353 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
354 /* expand %vars */ |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
355 var_expand(str, env, table); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
356 return str_c(str); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
357 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
358 |
4636
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
359 static const char *address_sanitize(const char *address) |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
360 { |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
361 struct message_address *addr; |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
362 const char *ret; |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
363 pool_t pool; |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
364 |
4647
5f467dc79a19
Increase default address sanitizer pool size
Timo Sirainen <tss@iki.fi>
parents:
4637
diff
changeset
|
365 pool = pool_alloconly_create("address sanitizer", 256); |
4636
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
366 addr = message_address_parse(pool, (const unsigned char *)address, |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
367 strlen(address), 1, FALSE); |
4725
af8caaba0f67
Don't crash with -f "". Changed the default from envelope to be
Timo Sirainen <tss@iki.fi>
parents:
4701
diff
changeset
|
368 |
af8caaba0f67
Don't crash with -f "". Changed the default from envelope to be
Timo Sirainen <tss@iki.fi>
parents:
4701
diff
changeset
|
369 if (addr == NULL || addr->mailbox == NULL || addr->domain == NULL || |
4636
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
370 *addr->mailbox == '\0') |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
371 ret = DEFAULT_ENVELOPE_SENDER; |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
372 else if (*addr->domain == '\0') |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
373 ret = t_strdup(addr->mailbox); |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
374 else |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
375 ret = t_strdup_printf("%s@%s", addr->mailbox, addr->domain); |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
376 pool_unref(pool); |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
377 return ret; |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
378 } |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
379 |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
380 static struct istream *create_mbox_stream(int fd, const char *envelope_sender) |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
381 { |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
382 const char *mbox_hdr; |
5210
b77a67169fc5
While parsing the input stream ignore the mbox hidden headers so that eg.
Timo Sirainen <tss@iki.fi>
parents:
5186
diff
changeset
|
383 struct istream *input_list[4], *input, *input_filter; |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
384 |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
385 fd_set_nonblock(fd, FALSE); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
386 |
4636
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
387 envelope_sender = address_sanitize(envelope_sender); |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
388 mbox_hdr = mbox_from_create(envelope_sender, ioloop_time); |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
389 |
5210
b77a67169fc5
While parsing the input stream ignore the mbox hidden headers so that eg.
Timo Sirainen <tss@iki.fi>
parents:
5186
diff
changeset
|
390 input = i_stream_create_file(fd, default_pool, 4096, FALSE); |
b77a67169fc5
While parsing the input stream ignore the mbox hidden headers so that eg.
Timo Sirainen <tss@iki.fi>
parents:
5186
diff
changeset
|
391 input_filter = |
b77a67169fc5
While parsing the input stream ignore the mbox hidden headers so that eg.
Timo Sirainen <tss@iki.fi>
parents:
5186
diff
changeset
|
392 i_stream_create_header_filter(input, |
b77a67169fc5
While parsing the input stream ignore the mbox hidden headers so that eg.
Timo Sirainen <tss@iki.fi>
parents:
5186
diff
changeset
|
393 HEADER_FILTER_EXCLUDE | |
b77a67169fc5
While parsing the input stream ignore the mbox hidden headers so that eg.
Timo Sirainen <tss@iki.fi>
parents:
5186
diff
changeset
|
394 HEADER_FILTER_NO_CR, |
b77a67169fc5
While parsing the input stream ignore the mbox hidden headers so that eg.
Timo Sirainen <tss@iki.fi>
parents:
5186
diff
changeset
|
395 mbox_hide_headers, |
b77a67169fc5
While parsing the input stream ignore the mbox hidden headers so that eg.
Timo Sirainen <tss@iki.fi>
parents:
5186
diff
changeset
|
396 mbox_hide_headers_count, |
b77a67169fc5
While parsing the input stream ignore the mbox hidden headers so that eg.
Timo Sirainen <tss@iki.fi>
parents:
5186
diff
changeset
|
397 null_header_filter_callback, |
b77a67169fc5
While parsing the input stream ignore the mbox hidden headers so that eg.
Timo Sirainen <tss@iki.fi>
parents:
5186
diff
changeset
|
398 NULL); |
b77a67169fc5
While parsing the input stream ignore the mbox hidden headers so that eg.
Timo Sirainen <tss@iki.fi>
parents:
5186
diff
changeset
|
399 i_stream_unref(&input); |
b77a67169fc5
While parsing the input stream ignore the mbox hidden headers so that eg.
Timo Sirainen <tss@iki.fi>
parents:
5186
diff
changeset
|
400 |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
401 input_list[0] = i_stream_create_from_data(default_pool, mbox_hdr, |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
402 strlen(mbox_hdr)); |
5210
b77a67169fc5
While parsing the input stream ignore the mbox hidden headers so that eg.
Timo Sirainen <tss@iki.fi>
parents:
5186
diff
changeset
|
403 input_list[1] = input_filter; |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
404 input_list[2] = i_stream_create_from_data(default_pool, "\n", 1); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
405 input_list[3] = NULL; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
406 |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
407 input = i_stream_create_seekable(input_list, default_pool, |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
408 MAIL_MAX_MEMORY_BUFFER, |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
409 "/tmp/dovecot.deliver."); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
410 i_stream_unref(&input_list[0]); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
411 i_stream_unref(&input_list[1]); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
412 i_stream_unref(&input_list[2]); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
413 return input; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
414 } |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
415 |
5141
8c0c4b524d84
Hook all exit()s and if the exit code is one of Dovecot's own FATAL_* ones,
Timo Sirainen <tss@iki.fi>
parents:
5050
diff
changeset
|
416 static void failure_exit_callback(int *status) |
8c0c4b524d84
Hook all exit()s and if the exit code is one of Dovecot's own FATAL_* ones,
Timo Sirainen <tss@iki.fi>
parents:
5050
diff
changeset
|
417 { |
8c0c4b524d84
Hook all exit()s and if the exit code is one of Dovecot's own FATAL_* ones,
Timo Sirainen <tss@iki.fi>
parents:
5050
diff
changeset
|
418 /* we want all our exit codes to be sysexits.h compatible */ |
8c0c4b524d84
Hook all exit()s and if the exit code is one of Dovecot's own FATAL_* ones,
Timo Sirainen <tss@iki.fi>
parents:
5050
diff
changeset
|
419 switch (*status) { |
8c0c4b524d84
Hook all exit()s and if the exit code is one of Dovecot's own FATAL_* ones,
Timo Sirainen <tss@iki.fi>
parents:
5050
diff
changeset
|
420 case FATAL_LOGOPEN: |
8c0c4b524d84
Hook all exit()s and if the exit code is one of Dovecot's own FATAL_* ones,
Timo Sirainen <tss@iki.fi>
parents:
5050
diff
changeset
|
421 case FATAL_LOGWRITE: |
8c0c4b524d84
Hook all exit()s and if the exit code is one of Dovecot's own FATAL_* ones,
Timo Sirainen <tss@iki.fi>
parents:
5050
diff
changeset
|
422 case FATAL_LOGERROR: |
8c0c4b524d84
Hook all exit()s and if the exit code is one of Dovecot's own FATAL_* ones,
Timo Sirainen <tss@iki.fi>
parents:
5050
diff
changeset
|
423 case FATAL_OUTOFMEM: |
8c0c4b524d84
Hook all exit()s and if the exit code is one of Dovecot's own FATAL_* ones,
Timo Sirainen <tss@iki.fi>
parents:
5050
diff
changeset
|
424 case FATAL_EXEC: |
8c0c4b524d84
Hook all exit()s and if the exit code is one of Dovecot's own FATAL_* ones,
Timo Sirainen <tss@iki.fi>
parents:
5050
diff
changeset
|
425 case FATAL_DEFAULT: |
8c0c4b524d84
Hook all exit()s and if the exit code is one of Dovecot's own FATAL_* ones,
Timo Sirainen <tss@iki.fi>
parents:
5050
diff
changeset
|
426 *status = EX_TEMPFAIL; |
8c0c4b524d84
Hook all exit()s and if the exit code is one of Dovecot's own FATAL_* ones,
Timo Sirainen <tss@iki.fi>
parents:
5050
diff
changeset
|
427 break; |
8c0c4b524d84
Hook all exit()s and if the exit code is one of Dovecot's own FATAL_* ones,
Timo Sirainen <tss@iki.fi>
parents:
5050
diff
changeset
|
428 } |
8c0c4b524d84
Hook all exit()s and if the exit code is one of Dovecot's own FATAL_* ones,
Timo Sirainen <tss@iki.fi>
parents:
5050
diff
changeset
|
429 } |
8c0c4b524d84
Hook all exit()s and if the exit code is one of Dovecot's own FATAL_* ones,
Timo Sirainen <tss@iki.fi>
parents:
5050
diff
changeset
|
430 |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
431 static void open_logfile(const char *username) |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
432 { |
5049
1acb3b558c3f
If log_timestamp isn't uncommented in dovecot.conf, use the default.
Timo Sirainen <tss@iki.fi>
parents:
5044
diff
changeset
|
433 const char *prefix, *log_path, *stamp; |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
434 |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
435 prefix = t_strdup_printf("deliver(%s)", username); |
4454
a75da1185a18
Allow log_path settings in config file to be empty without trying to use
Timo Sirainen <tss@iki.fi>
parents:
4445
diff
changeset
|
436 log_path = getenv("LOG_PATH"); |
a75da1185a18
Allow log_path settings in config file to be empty without trying to use
Timo Sirainen <tss@iki.fi>
parents:
4445
diff
changeset
|
437 if (log_path == NULL || *log_path == '\0') { |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
438 const char *env = getenv("SYSLOG_FACILITY"); |
5050
167c602ef8b4
If config file contained quoted "value", the quotes weren't stripped.
Timo Sirainen <tss@iki.fi>
parents:
5049
diff
changeset
|
439 int facility; |
167c602ef8b4
If config file contained quoted "value", the quotes weren't stripped.
Timo Sirainen <tss@iki.fi>
parents:
5049
diff
changeset
|
440 |
167c602ef8b4
If config file contained quoted "value", the quotes weren't stripped.
Timo Sirainen <tss@iki.fi>
parents:
5049
diff
changeset
|
441 if (env == NULL || !syslog_facility_find(env, &facility)) |
167c602ef8b4
If config file contained quoted "value", the quotes weren't stripped.
Timo Sirainen <tss@iki.fi>
parents:
5049
diff
changeset
|
442 facility = LOG_MAIL; |
167c602ef8b4
If config file contained quoted "value", the quotes weren't stripped.
Timo Sirainen <tss@iki.fi>
parents:
5049
diff
changeset
|
443 i_set_failure_syslog(prefix, LOG_NDELAY, facility); |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
444 } else { |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
445 /* log to file or stderr */ |
5333
55260092b094
Fixes to handling log prefixes. imap/pop3 processes now log the
Timo Sirainen <tss@iki.fi>
parents:
5291
diff
changeset
|
446 i_set_failure_file(log_path, t_strconcat(prefix, ": ", NULL)); |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
447 } |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
448 |
4454
a75da1185a18
Allow log_path settings in config file to be empty without trying to use
Timo Sirainen <tss@iki.fi>
parents:
4445
diff
changeset
|
449 log_path = getenv("INFO_LOG_PATH"); |
a75da1185a18
Allow log_path settings in config file to be empty without trying to use
Timo Sirainen <tss@iki.fi>
parents:
4445
diff
changeset
|
450 if (log_path != NULL && *log_path != '\0') |
a75da1185a18
Allow log_path settings in config file to be empty without trying to use
Timo Sirainen <tss@iki.fi>
parents:
4445
diff
changeset
|
451 i_set_info_file(log_path); |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
452 |
5049
1acb3b558c3f
If log_timestamp isn't uncommented in dovecot.conf, use the default.
Timo Sirainen <tss@iki.fi>
parents:
5044
diff
changeset
|
453 stamp = getenv("LOG_TIMESTAMP"); |
1acb3b558c3f
If log_timestamp isn't uncommented in dovecot.conf, use the default.
Timo Sirainen <tss@iki.fi>
parents:
5044
diff
changeset
|
454 if (stamp == NULL) |
1acb3b558c3f
If log_timestamp isn't uncommented in dovecot.conf, use the default.
Timo Sirainen <tss@iki.fi>
parents:
5044
diff
changeset
|
455 stamp = DEFAULT_FAILURE_STAMP_FORMAT; |
1acb3b558c3f
If log_timestamp isn't uncommented in dovecot.conf, use the default.
Timo Sirainen <tss@iki.fi>
parents:
5044
diff
changeset
|
456 i_set_failure_timestamp_format(stamp); |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
457 } |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
458 |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
459 static void print_help(void) |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
460 { |
4727
4710a0429914
Added -f parameter to usage help.
Timo Sirainen <tss@iki.fi>
parents:
4725
diff
changeset
|
461 printf( |
4710a0429914
Added -f parameter to usage help.
Timo Sirainen <tss@iki.fi>
parents:
4725
diff
changeset
|
462 "Usage: deliver [-c <config file>] [-d <destination user>] [-m <mailbox>]\n" |
5603
86886a8fb0f1
Added -e parameter to write rejection error to stderr and exit with
Timo Sirainen <tss@iki.fi>
parents:
5500
diff
changeset
|
463 " [-n] [-e] [-f <envelope sender>]\n"); |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
464 } |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
465 |
5220
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
466 void deliver_env_clean(void) |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
467 { |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
468 const char *tz, *home; |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
469 |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
470 tz = getenv("TZ"); |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
471 if (tz != NULL) |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
472 tz = t_strconcat("TZ=", tz, NULL); |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
473 home = getenv("HOME"); |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
474 if (home != NULL) |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
475 home = t_strconcat("HOME=", home, NULL); |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
476 |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
477 /* Note that if the original environment was set with env_put(), the |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
478 environment strings will be invalid after env_clean(). That's why |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
479 we t_strconcat() them above. */ |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
480 env_clean(); |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
481 |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
482 if (tz != NULL) env_put(tz); |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
483 if (home != NULL) env_put(home); |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
484 } |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
485 |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
486 int main(int argc, char *argv[]) |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
487 { |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
488 const char *config_path = DEFAULT_CONFIG_FILE; |
4636
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
489 const char *envelope_sender = DEFAULT_ENVELOPE_SENDER; |
3660
f2d65601097c
Added -m parameter to store mail to non-INBOX mailbox without Sieve
Timo Sirainen <tss@iki.fi>
parents:
3637
diff
changeset
|
490 const char *mailbox = "INBOX"; |
5220
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
491 const char *auth_socket; |
4563
5d725c24d5a0
Set umask from dovecot.conf, or default to 0077.
Timo Sirainen <tss@iki.fi>
parents:
4548
diff
changeset
|
492 const char *home, *destination, *user, *mail_env, *value; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
493 const struct var_expand_table *table; |
5500
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
494 struct mail_namespace *ns, *mbox_ns; |
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
495 struct mail_storage *storage; |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
496 struct mailbox *box; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
497 struct istream *input; |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
498 struct mailbox_transaction_context *t; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
499 struct mail *mail; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
500 uid_t process_euid; |
5500
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
501 pool_t namespace_pool; |
5603
86886a8fb0f1
Added -e parameter to write rejection error to stderr and exit with
Timo Sirainen <tss@iki.fi>
parents:
5500
diff
changeset
|
502 bool stderr_rejection = FALSE; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
503 int i, ret; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
504 |
5416
22e2a1eef74b
failure callback was still set too late.
Timo Sirainen <tss@iki.fi>
parents:
5351
diff
changeset
|
505 i_set_failure_exit_callback(failure_exit_callback); |
22e2a1eef74b
failure callback was still set too late.
Timo Sirainen <tss@iki.fi>
parents:
5351
diff
changeset
|
506 |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
507 lib_init(); |
5249
784dc7224718
Removed pool parameter from io_loop_create()
Timo Sirainen <tss@iki.fi>
parents:
5220
diff
changeset
|
508 ioloop = io_loop_create(); |
3624
d53d0de2ffbb
ioloop needs to be created before setting signals or we crash
Timo Sirainen <tss@iki.fi>
parents:
3620
diff
changeset
|
509 |
3620
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3389
diff
changeset
|
510 lib_signals_init(); |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3389
diff
changeset
|
511 lib_signals_set_handler(SIGINT, TRUE, sig_die, NULL); |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3389
diff
changeset
|
512 lib_signals_set_handler(SIGTERM, TRUE, sig_die, NULL); |
4903
204d7edc7cdc
Added context parameter type safety checks for most callback APIs.
Timo Sirainen <tss@iki.fi>
parents:
4891
diff
changeset
|
513 lib_signals_ignore(SIGPIPE, TRUE); |
204d7edc7cdc
Added context parameter type safety checks for most callback APIs.
Timo Sirainen <tss@iki.fi>
parents:
4891
diff
changeset
|
514 lib_signals_ignore(SIGALRM, FALSE); |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
515 #ifdef SIGXFSZ |
4903
204d7edc7cdc
Added context parameter type safety checks for most callback APIs.
Timo Sirainen <tss@iki.fi>
parents:
4891
diff
changeset
|
516 lib_signals_ignore(SIGXFSZ, TRUE); |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
517 #endif |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
518 |
5220
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
519 deliver_env_clean(); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
520 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
521 destination = NULL; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
522 for (i = 1; i < argc; i++) { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
523 if (strcmp(argv[i], "-d") == 0) { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
524 /* destination user */ |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
525 i++; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
526 if (i == argc) { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
527 i_fatal_status(EX_USAGE, |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
528 "Missing destination argument"); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
529 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
530 destination = argv[i]; |
5603
86886a8fb0f1
Added -e parameter to write rejection error to stderr and exit with
Timo Sirainen <tss@iki.fi>
parents:
5500
diff
changeset
|
531 } else if (strcmp(argv[i], "-e") == 0) { |
86886a8fb0f1
Added -e parameter to write rejection error to stderr and exit with
Timo Sirainen <tss@iki.fi>
parents:
5500
diff
changeset
|
532 stderr_rejection = TRUE; |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
533 } else if (strcmp(argv[i], "-c") == 0) { |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
534 /* config file path */ |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
535 i++; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
536 if (i == argc) { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
537 i_fatal_status(EX_USAGE, |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
538 "Missing config file path argument"); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
539 } |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
540 config_path = argv[i]; |
3660
f2d65601097c
Added -m parameter to store mail to non-INBOX mailbox without Sieve
Timo Sirainen <tss@iki.fi>
parents:
3637
diff
changeset
|
541 } else if (strcmp(argv[i], "-m") == 0) { |
f2d65601097c
Added -m parameter to store mail to non-INBOX mailbox without Sieve
Timo Sirainen <tss@iki.fi>
parents:
3637
diff
changeset
|
542 /* destination mailbox */ |
f2d65601097c
Added -m parameter to store mail to non-INBOX mailbox without Sieve
Timo Sirainen <tss@iki.fi>
parents:
3637
diff
changeset
|
543 i++; |
f2d65601097c
Added -m parameter to store mail to non-INBOX mailbox without Sieve
Timo Sirainen <tss@iki.fi>
parents:
3637
diff
changeset
|
544 if (i == argc) { |
f2d65601097c
Added -m parameter to store mail to non-INBOX mailbox without Sieve
Timo Sirainen <tss@iki.fi>
parents:
3637
diff
changeset
|
545 i_fatal_status(EX_USAGE, |
f2d65601097c
Added -m parameter to store mail to non-INBOX mailbox without Sieve
Timo Sirainen <tss@iki.fi>
parents:
3637
diff
changeset
|
546 "Missing mailbox argument"); |
f2d65601097c
Added -m parameter to store mail to non-INBOX mailbox without Sieve
Timo Sirainen <tss@iki.fi>
parents:
3637
diff
changeset
|
547 } |
5351
5220d4e6690d
Ignore -m "" parameter. Added -n option to not autocreate the mailbox. If
Timo Sirainen <tss@iki.fi>
parents:
5333
diff
changeset
|
548 /* Ignore -m "". This allows doing -m ${extension} |
5220d4e6690d
Ignore -m "" parameter. Added -n option to not autocreate the mailbox. If
Timo Sirainen <tss@iki.fi>
parents:
5333
diff
changeset
|
549 in Postfix to handle user+mailbox */ |
5220d4e6690d
Ignore -m "" parameter. Added -n option to not autocreate the mailbox. If
Timo Sirainen <tss@iki.fi>
parents:
5333
diff
changeset
|
550 if (*argv[i] != '\0') |
5220d4e6690d
Ignore -m "" parameter. Added -n option to not autocreate the mailbox. If
Timo Sirainen <tss@iki.fi>
parents:
5333
diff
changeset
|
551 mailbox = argv[i]; |
5220d4e6690d
Ignore -m "" parameter. Added -n option to not autocreate the mailbox. If
Timo Sirainen <tss@iki.fi>
parents:
5333
diff
changeset
|
552 } else if (strcmp(argv[i], "-n") == 0) { |
5220d4e6690d
Ignore -m "" parameter. Added -n option to not autocreate the mailbox. If
Timo Sirainen <tss@iki.fi>
parents:
5333
diff
changeset
|
553 /* destination mailbox */ |
5220d4e6690d
Ignore -m "" parameter. Added -n option to not autocreate the mailbox. If
Timo Sirainen <tss@iki.fi>
parents:
5333
diff
changeset
|
554 no_mailbox_autocreate = TRUE; |
4636
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
555 } else if (strcmp(argv[i], "-f") == 0) { |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
556 /* envelope sender address */ |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
557 i++; |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
558 if (i == argc) { |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
559 i_fatal_status(EX_USAGE, |
4725
af8caaba0f67
Don't crash with -f "". Changed the default from envelope to be
Timo Sirainen <tss@iki.fi>
parents:
4701
diff
changeset
|
560 "Missing envelope argument"); |
4636
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
561 } |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
562 envelope_sender = argv[i]; |
5044
1e5b5484c603
Ignore empty parameters. "Unknown argument: xx" printed wrong argument.
Timo Sirainen <tss@iki.fi>
parents:
4963
diff
changeset
|
563 } else if (argv[i][0] != '\0') { |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
564 print_help(); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
565 i_fatal_status(EX_USAGE, |
5044
1e5b5484c603
Ignore empty parameters. "Unknown argument: xx" printed wrong argument.
Timo Sirainen <tss@iki.fi>
parents:
4963
diff
changeset
|
566 "Unknown argument: %s", argv[i]); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
567 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
568 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
569 |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
570 process_euid = geteuid(); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
571 if (destination != NULL) |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
572 user = destination; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
573 else if (process_euid != 0) { |
4763
8bbed82738ec
If we're executing as a normal system user, get the HOME environment from
Timo Sirainen <tss@iki.fi>
parents:
4728
diff
changeset
|
574 /* we're non-root. get our username and possibly our home. */ |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
575 struct passwd *pw; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
576 |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
577 pw = getpwuid(process_euid); |
4763
8bbed82738ec
If we're executing as a normal system user, get the HOME environment from
Timo Sirainen <tss@iki.fi>
parents:
4728
diff
changeset
|
578 if (pw != NULL) { |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
579 user = t_strdup(pw->pw_name); |
4763
8bbed82738ec
If we're executing as a normal system user, get the HOME environment from
Timo Sirainen <tss@iki.fi>
parents:
4728
diff
changeset
|
580 if (getenv("HOME") == NULL) |
8bbed82738ec
If we're executing as a normal system user, get the HOME environment from
Timo Sirainen <tss@iki.fi>
parents:
4728
diff
changeset
|
581 env_put(t_strconcat("HOME=", pw->pw_dir, NULL)); |
8bbed82738ec
If we're executing as a normal system user, get the HOME environment from
Timo Sirainen <tss@iki.fi>
parents:
4728
diff
changeset
|
582 } else { |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
583 i_fatal("Couldn't lookup our username (uid=%s)", |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
584 dec2str(process_euid)); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
585 } |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
586 } else { |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
587 i_fatal_status(EX_USAGE, |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
588 "destination user parameter (-d user) not given"); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
589 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
590 |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
591 config_file_init(config_path); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
592 open_logfile(user); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
593 |
4728
80afcbfce92a
Make mail_debug=yes work with deliver too.
Timo Sirainen <tss@iki.fi>
parents:
4727
diff
changeset
|
594 if (getenv("MAIL_DEBUG") != NULL) |
80afcbfce92a
Make mail_debug=yes work with deliver too.
Timo Sirainen <tss@iki.fi>
parents:
4727
diff
changeset
|
595 env_put("DEBUG=1"); |
80afcbfce92a
Make mail_debug=yes work with deliver too.
Timo Sirainen <tss@iki.fi>
parents:
4727
diff
changeset
|
596 |
5497 | 597 if (getenv("MAIL_PLUGINS") == NULL) |
598 modules = NULL; | |
599 else { | |
600 const char *plugin_dir = getenv("MAIL_PLUGIN_DIR"); | |
601 const char *version; | |
602 | |
603 if (plugin_dir == NULL) | |
604 plugin_dir = MODULEDIR"/lda"; | |
605 | |
606 version = getenv("VERSION_IGNORE") != NULL ? | |
607 NULL : PACKAGE_VERSION; | |
608 modules = module_dir_load(plugin_dir, getenv("MAIL_PLUGINS"), | |
609 TRUE, version); | |
610 } | |
611 | |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
612 if (destination != NULL) { |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
613 auth_socket = getenv("AUTH_SOCKET_PATH"); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
614 if (auth_socket == NULL) |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
615 auth_socket = DEFAULT_AUTH_SOCKET_PATH; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
616 |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
617 ret = auth_client_put_user_env(ioloop, auth_socket, |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
618 destination, process_euid); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
619 if (ret != 0) |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
620 return ret; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
621 |
4805
3c92ff93e241
If user has a home directory, but we can't chdir() there, log an error (but
Timo Sirainen <tss@iki.fi>
parents:
4763
diff
changeset
|
622 /* If possible chdir to home directory, so that core file |
3c92ff93e241
If user has a home directory, but we can't chdir() there, log an error (but
Timo Sirainen <tss@iki.fi>
parents:
4763
diff
changeset
|
623 could be written in case we crash. */ |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
624 home = getenv("HOME"); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
625 if (home != NULL) { |
4843
57955b19a35d
chdir() now gives error only if error is something else than ENOENT. Also
Timo Sirainen <tss@iki.fi>
parents:
4805
diff
changeset
|
626 if (chdir(home) < 0) { |
57955b19a35d
chdir() now gives error only if error is something else than ENOENT. Also
Timo Sirainen <tss@iki.fi>
parents:
4805
diff
changeset
|
627 if (errno != ENOENT) |
57955b19a35d
chdir() now gives error only if error is something else than ENOENT. Also
Timo Sirainen <tss@iki.fi>
parents:
4805
diff
changeset
|
628 i_error("chdir(%s) failed: %m", home); |
57955b19a35d
chdir() now gives error only if error is something else than ENOENT. Also
Timo Sirainen <tss@iki.fi>
parents:
4805
diff
changeset
|
629 else if (getenv("DEBUG") != NULL) |
57955b19a35d
chdir() now gives error only if error is something else than ENOENT. Also
Timo Sirainen <tss@iki.fi>
parents:
4805
diff
changeset
|
630 i_info("Home dir not found: %s", home); |
57955b19a35d
chdir() now gives error only if error is something else than ENOENT. Also
Timo Sirainen <tss@iki.fi>
parents:
4805
diff
changeset
|
631 } |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
632 } |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
633 } else { |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
634 destination = user; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
635 } |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
636 |
4563
5d725c24d5a0
Set umask from dovecot.conf, or default to 0077.
Timo Sirainen <tss@iki.fi>
parents:
4548
diff
changeset
|
637 value = getenv("UMASK"); |
5d725c24d5a0
Set umask from dovecot.conf, or default to 0077.
Timo Sirainen <tss@iki.fi>
parents:
4548
diff
changeset
|
638 if (value == NULL || sscanf(value, "%i", &i) != 1 || i < 0) |
5d725c24d5a0
Set umask from dovecot.conf, or default to 0077.
Timo Sirainen <tss@iki.fi>
parents:
4548
diff
changeset
|
639 i = 0077; |
5d725c24d5a0
Set umask from dovecot.conf, or default to 0077.
Timo Sirainen <tss@iki.fi>
parents:
4548
diff
changeset
|
640 (void)umask(i); |
5d725c24d5a0
Set umask from dovecot.conf, or default to 0077.
Timo Sirainen <tss@iki.fi>
parents:
4548
diff
changeset
|
641 |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
642 deliver_set = i_new(struct deliver_settings, 1); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
643 deliver_set->hostname = getenv("HOSTNAME"); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
644 if (deliver_set->hostname == NULL) |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
645 deliver_set->hostname = my_hostname; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
646 deliver_set->postmaster_address = getenv("POSTMASTER_ADDRESS"); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
647 if (deliver_set->postmaster_address == NULL) { |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
648 i_fatal_status(EX_CONFIG, |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
649 "postmaster_address setting not given"); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
650 } |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
651 deliver_set->sendmail_path = getenv("SENDMAIL_PATH"); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
652 if (deliver_set->sendmail_path == NULL) |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
653 deliver_set->sendmail_path = DEFAULT_SENDMAIL_PATH; |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
654 |
4517
e661182eab75
Berkeley DB dict support is now enabled only when using --with-db configure option.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4454
diff
changeset
|
655 dict_driver_register(&dict_driver_client); |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
656 duplicate_init(); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
657 mail_storage_init(); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
658 mail_storage_register_all(); |
4891
6ab2712f1a93
Only imap binary was actually working.
Timo Sirainen <tss@iki.fi>
parents:
4876
diff
changeset
|
659 mailbox_list_register_all(); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
660 |
5500
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
661 /* MAIL comes from userdb, MAIL_LOCATION from dovecot.conf. |
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
662 FIXME: should remove these and support namespaces.. */ |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
663 mail_env = getenv("MAIL"); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
664 if (mail_env == NULL) |
4701
190a66df2f82
Renamed default_mail_env to mail_location. Keep the default_mail_env working
Timo Sirainen <tss@iki.fi>
parents:
4652
diff
changeset
|
665 mail_env = getenv("MAIL_LOCATION"); |
190a66df2f82
Renamed default_mail_env to mail_location. Keep the default_mail_env working
Timo Sirainen <tss@iki.fi>
parents:
4652
diff
changeset
|
666 if (mail_env == NULL) { |
190a66df2f82
Renamed default_mail_env to mail_location. Keep the default_mail_env working
Timo Sirainen <tss@iki.fi>
parents:
4652
diff
changeset
|
667 /* Keep this for backwards compatibility */ |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
668 mail_env = getenv("DEFAULT_MAIL_ENV"); |
4701
190a66df2f82
Renamed default_mail_env to mail_location. Keep the default_mail_env working
Timo Sirainen <tss@iki.fi>
parents:
4652
diff
changeset
|
669 } |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
670 if (mail_env != NULL) { |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
671 table = get_var_expand_table(destination, getenv("HOME")); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
672 mail_env = expand_mail_env(mail_env, table); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
673 } |
5500
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
674 env_put(t_strconcat("MAIL=", mail_env, NULL)); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
675 |
5497 | 676 module_dir_init(modules); |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
677 |
5500
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
678 namespace_pool = pool_alloconly_create("namespaces", 1024); |
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
679 if (mail_namespaces_init(namespace_pool, destination, &ns) < 0) |
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
680 exit(EX_TEMPFAIL); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
681 |
5500
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
682 mbox_ns = mail_namespaces_init_empty(namespace_pool); |
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
683 if (mail_storage_create(mbox_ns, "mbox", "/tmp", destination, |
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
684 0, FILE_LOCK_METHOD_FCNTL) < 0) |
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
685 i_fatal("Couldn't create internal mbox storage"); |
4636
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
686 input = create_mbox_stream(0, envelope_sender); |
5500
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
687 box = mailbox_open(mbox_ns->storage, "Dovecot Delivery Mail", input, |
4548
2eb8af6f1285
Added MAILBOX_OPEN_MBOX_ONE_MSG_ONLY flag for mailbox_open() which makes it
Timo Sirainen <tss@iki.fi>
parents:
4517
diff
changeset
|
688 MAILBOX_OPEN_NO_INDEX_FILES | |
2eb8af6f1285
Added MAILBOX_OPEN_MBOX_ONE_MSG_ONLY flag for mailbox_open() which makes it
Timo Sirainen <tss@iki.fi>
parents:
4517
diff
changeset
|
689 MAILBOX_OPEN_MBOX_ONE_MSG_ONLY); |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
690 if (box == NULL) |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
691 i_fatal("Can't open delivery mail as mbox"); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
692 if (sync_quick(box) < 0) |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
693 i_fatal("Can't sync delivery mail"); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
694 |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
695 t = mailbox_transaction_begin(box, 0); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
696 mail = mail_alloc(t, 0, NULL); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
697 if (mail_set_seq(mail, 1) < 0) |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
698 i_fatal("mail_set_seq() failed"); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
699 |
5143
5a0506cb73c5
Don't bother trying to save the mail twice into the default mailbox (eg. if it's
Timo Sirainen <tss@iki.fi>
parents:
5141
diff
changeset
|
700 default_mailbox_name = mailbox; |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
701 ret = deliver_mail == NULL ? 0 : |
5500
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
702 deliver_mail(ns, &storage, mail, destination, mailbox); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
703 |
5143
5a0506cb73c5
Don't bother trying to save the mail twice into the default mailbox (eg. if it's
Timo Sirainen <tss@iki.fi>
parents:
5141
diff
changeset
|
704 if (ret == 0 || (ret < 0 && !tried_default_save)) { |
5a0506cb73c5
Don't bother trying to save the mail twice into the default mailbox (eg. if it's
Timo Sirainen <tss@iki.fi>
parents:
5141
diff
changeset
|
705 /* plugins didn't handle this. save into the default mailbox. */ |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
706 i_stream_seek(input, 0); |
5500
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
707 ret = deliver_save(ns, &storage, mailbox, mail, 0, NULL); |
5424
448901e76f93
INBOX fallbacking with -n wasn't working.
Timo Sirainen <tss@iki.fi>
parents:
5416
diff
changeset
|
708 } |
448901e76f93
INBOX fallbacking with -n wasn't working.
Timo Sirainen <tss@iki.fi>
parents:
5416
diff
changeset
|
709 if (ret < 0 && strcasecmp(mailbox, "INBOX") != 0) { |
448901e76f93
INBOX fallbacking with -n wasn't working.
Timo Sirainen <tss@iki.fi>
parents:
5416
diff
changeset
|
710 /* still didn't work. try once more to save it |
448901e76f93
INBOX fallbacking with -n wasn't working.
Timo Sirainen <tss@iki.fi>
parents:
5416
diff
changeset
|
711 to INBOX. */ |
448901e76f93
INBOX fallbacking with -n wasn't working.
Timo Sirainen <tss@iki.fi>
parents:
5416
diff
changeset
|
712 i_stream_seek(input, 0); |
5500
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
713 ret = deliver_save(ns, &storage, "INBOX", mail, 0, NULL); |
5143
5a0506cb73c5
Don't bother trying to save the mail twice into the default mailbox (eg. if it's
Timo Sirainen <tss@iki.fi>
parents:
5141
diff
changeset
|
714 } |
5a0506cb73c5
Don't bother trying to save the mail twice into the default mailbox (eg. if it's
Timo Sirainen <tss@iki.fi>
parents:
5141
diff
changeset
|
715 |
5a0506cb73c5
Don't bother trying to save the mail twice into the default mailbox (eg. if it's
Timo Sirainen <tss@iki.fi>
parents:
5141
diff
changeset
|
716 if (ret < 0) { |
5613 | 717 const char *error_string, *msgid; |
718 enum mail_error error; | |
5143
5a0506cb73c5
Don't bother trying to save the mail twice into the default mailbox (eg. if it's
Timo Sirainen <tss@iki.fi>
parents:
5141
diff
changeset
|
719 int ret; |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
720 |
5613 | 721 error_string = mail_storage_get_last_error(ns->storage, &error); |
5616
0d6cd7281aa7
Added quota_full_tempfail setting.
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
722 if (error != MAIL_ERROR_NOSPACE || |
0d6cd7281aa7
Added quota_full_tempfail setting.
Timo Sirainen <tss@iki.fi>
parents:
5613
diff
changeset
|
723 getenv("QUOTA_FULL_TEMPFAIL") != NULL) { |
5613 | 724 /* Saving to INBOX should always work unless |
725 we're over quota. If it didn't, it's probably a | |
726 configuration problem. */ | |
5143
5a0506cb73c5
Don't bother trying to save the mail twice into the default mailbox (eg. if it's
Timo Sirainen <tss@iki.fi>
parents:
5141
diff
changeset
|
727 return EX_TEMPFAIL; |
5613 | 728 } |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
729 |
5603
86886a8fb0f1
Added -e parameter to write rejection error to stderr and exit with
Timo Sirainen <tss@iki.fi>
parents:
5500
diff
changeset
|
730 msgid = mail_get_first_header(mail, "Message-ID"); |
86886a8fb0f1
Added -e parameter to write rejection error to stderr and exit with
Timo Sirainen <tss@iki.fi>
parents:
5500
diff
changeset
|
731 i_info("msgid=%s: Rejected: %s", |
86886a8fb0f1
Added -e parameter to write rejection error to stderr and exit with
Timo Sirainen <tss@iki.fi>
parents:
5500
diff
changeset
|
732 msgid == NULL ? "" : str_sanitize(msgid, 80), |
5613 | 733 str_sanitize(error_string, 512)); |
5603
86886a8fb0f1
Added -e parameter to write rejection error to stderr and exit with
Timo Sirainen <tss@iki.fi>
parents:
5500
diff
changeset
|
734 |
5143
5a0506cb73c5
Don't bother trying to save the mail twice into the default mailbox (eg. if it's
Timo Sirainen <tss@iki.fi>
parents:
5141
diff
changeset
|
735 /* we'll have to reply with permanent failure */ |
5603
86886a8fb0f1
Added -e parameter to write rejection error to stderr and exit with
Timo Sirainen <tss@iki.fi>
parents:
5500
diff
changeset
|
736 if (stderr_rejection) { |
5613 | 737 fprintf(stderr, "%s\n", error_string); |
5603
86886a8fb0f1
Added -e parameter to write rejection error to stderr and exit with
Timo Sirainen <tss@iki.fi>
parents:
5500
diff
changeset
|
738 return EX_NOPERM; |
86886a8fb0f1
Added -e parameter to write rejection error to stderr and exit with
Timo Sirainen <tss@iki.fi>
parents:
5500
diff
changeset
|
739 } |
5613 | 740 ret = mail_send_rejection(mail, destination, error_string); |
5143
5a0506cb73c5
Don't bother trying to save the mail twice into the default mailbox (eg. if it's
Timo Sirainen <tss@iki.fi>
parents:
5141
diff
changeset
|
741 if (ret != 0) |
5a0506cb73c5
Don't bother trying to save the mail twice into the default mailbox (eg. if it's
Timo Sirainen <tss@iki.fi>
parents:
5141
diff
changeset
|
742 return ret < 0 ? EX_TEMPFAIL : ret; |
5a0506cb73c5
Don't bother trying to save the mail twice into the default mailbox (eg. if it's
Timo Sirainen <tss@iki.fi>
parents:
5141
diff
changeset
|
743 /* ok, rejection sent */ |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
744 } |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
745 i_stream_unref(&input); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
746 |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
747 mail_free(&mail); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
748 mailbox_transaction_rollback(&t); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
749 mailbox_close(&box); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
750 |
5500
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
751 mail_namespaces_deinit(&mbox_ns); |
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5497
diff
changeset
|
752 mail_namespaces_deinit(&ns); |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
753 |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
754 module_dir_unload(&modules); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
755 mail_storage_deinit(); |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
756 |
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
757 duplicate_deinit(); |
4517
e661182eab75
Berkeley DB dict support is now enabled only when using --with-db configure option.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4454
diff
changeset
|
758 dict_driver_unregister(&dict_driver_client); |
3625 | 759 lib_signals_deinit(); |
760 | |
4347
a73d2867f6e1
Moved all the non-Sieve code from dovecot-lda in here and rewrote parts of
Timo Sirainen <tss@iki.fi>
parents:
4253
diff
changeset
|
761 io_loop_destroy(&ioloop); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
762 lib_deinit(); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
763 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
764 return EX_OK; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
765 } |