Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/deliver/deliver.c @ 5351:5220d4e6690d HEAD
Ignore -m "" parameter. Added -n option to not autocreate the mailbox. If
saving to given mailbox fails, fallback to saving to INBOX.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 17 Mar 2007 14:07:39 +0200 |
parents | 55260092b094 |
children | 22e2a1eef74b |
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" |
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
|
21 #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
|
22 #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
|
23 #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
|
24 #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
|
25 #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
|
26 #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
|
27 #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
|
28 #include "deliver.h" |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
29 |
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
|
30 #include <stdio.h> |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
31 #include <stdlib.h> |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
32 #include <unistd.h> |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
33 #include <fcntl.h> |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
34 #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
|
35 #include <syslog.h> |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
36 |
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
|
37 #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
|
38 #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
|
39 #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
|
40 #define DEFAULT_ENVELOPE_SENDER "MAILER-DAEMON" |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
41 |
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
|
42 /* 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
|
43 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
|
44 #define MAIL_MAX_MEMORY_BUFFER (1024*128) |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
45 |
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
|
46 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
|
47 deliver_mail_func_t *deliver_mail = NULL; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
48 |
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
|
49 /* 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
|
50 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
|
51 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
|
52 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
|
53 |
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
|
54 static struct module *modules; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
55 static struct ioloop *ioloop; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
56 |
3620
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3389
diff
changeset
|
57 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
|
58 { |
3620
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3389
diff
changeset
|
59 /* 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
|
60 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
|
61 if (signo != SIGINT) |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3389
diff
changeset
|
62 i_warning("Killed with signal %d", signo); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
63 io_loop_stop(ioloop); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
64 } |
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 static int sync_quick(struct mailbox *box) |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
67 { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
68 struct mailbox_sync_context *ctx; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
69 struct mailbox_sync_rec sync_rec; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
70 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
71 ctx = mailbox_sync_init(box, 0); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
72 while (mailbox_sync_next(ctx, &sync_rec) > 0) |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
73 ; |
4848
967de900c73a
Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents:
4843
diff
changeset
|
74 return mailbox_sync_deinit(&ctx, 0, NULL); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
75 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
76 |
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
|
77 static struct mailbox * |
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 mailbox_open_or_create_synced(struct mail_storage *storage, const char *name) |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
79 { |
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
|
80 struct mailbox *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
|
81 bool syntax, temp; |
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
|
82 |
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 box = mailbox_open(storage, name, NULL, MAILBOX_OPEN_FAST | |
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
|
84 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
|
85 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
|
86 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
|
87 |
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
|
88 (void)mail_storage_get_last_error(storage, &syntax, &temp); |
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
|
89 if (syntax || temp) |
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
|
90 return NULL; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
91 |
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
|
92 /* probably the mailbox just doesn't exist. try creating it. */ |
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
|
93 if (mail_storage_mailbox_create(storage, name, FALSE) < 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
|
94 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
|
95 |
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 /* and try opening again */ |
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 box = mailbox_open(storage, name, NULL, MAILBOX_OPEN_FAST | |
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
|
98 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
|
99 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
|
100 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
|
101 |
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
|
102 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
|
103 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
|
104 return NULL; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
105 } |
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
|
106 return box; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
107 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
108 |
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
|
109 int deliver_save(struct mail_storage *storage, const char *mailbox, |
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 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
|
111 const char *const *keywords) |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
112 { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
113 struct mailbox *box; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
114 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
|
115 struct mail_keywords *kw; |
4637
0af548f101f8
Log all mail saves and save failures.
Timo Sirainen <tss@iki.fi>
parents:
4636
diff
changeset
|
116 const char *msgid; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
117 int ret = 0; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
118 |
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
|
119 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
|
120 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
|
121 |
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
|
122 box = mailbox_open_or_create_synced(storage, mailbox); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
123 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
|
124 return -1; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
125 |
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
|
126 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
|
127 |
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
|
128 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
|
129 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
|
130 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
|
131 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
|
132 mailbox_keywords_free(t, &kw); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
133 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
134 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
|
135 mailbox_transaction_rollback(&t); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
136 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
|
137 ret = mailbox_transaction_commit(&t, 0); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
138 |
4637
0af548f101f8
Log all mail saves and save failures.
Timo Sirainen <tss@iki.fi>
parents:
4636
diff
changeset
|
139 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
|
140 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
|
141 "msgid=%s: saved mail to %s", |
0af548f101f8
Log all mail saves and save failures.
Timo Sirainen <tss@iki.fi>
parents:
4636
diff
changeset
|
142 msgid == NULL ? "" : str_sanitize(msgid, 80), |
0af548f101f8
Log all mail saves and save failures.
Timo Sirainen <tss@iki.fi>
parents:
4636
diff
changeset
|
143 str_sanitize(mailbox_get_name(box), 80)); |
0af548f101f8
Log all mail saves and save failures.
Timo Sirainen <tss@iki.fi>
parents:
4636
diff
changeset
|
144 |
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
|
145 mailbox_close(&box); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
146 return ret; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
147 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
148 |
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
|
149 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
|
150 { |
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
|
151 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
|
152 const char *str; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
153 |
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
|
154 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
|
155 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
|
156 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
|
157 (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
|
158 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
|
159 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
|
160 NULL : t_strconcat(addr->mailbox, "@", addr->domain, NULL); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
161 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
162 |
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
|
163 const char *deliver_get_new_message_id(void) |
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 static int count = 0; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
166 |
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
|
167 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
|
168 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
|
169 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
|
170 count++, deliver_set->hostname); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
171 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
172 |
4963
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
173 #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
|
174 #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
|
175 #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
|
176 |
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
|
177 #define IS_WHITE(c) ((c) == ' ' || (c) == '\t') |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
178 |
4963
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
179 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
|
180 { |
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
181 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
|
182 |
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
183 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
|
184 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
|
185 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
|
186 } |
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
187 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
|
188 } |
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
189 |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
190 static void config_file_init(const char *path) |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
191 { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
192 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
|
193 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
|
194 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
|
195 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
|
196 size_t len; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
197 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
198 fd = open(path, O_RDONLY); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
199 if (fd < 0) |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
200 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
|
201 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
202 t_push(); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
203 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
|
204 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
|
205 /* @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
|
206 |
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 /* 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
|
208 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
|
209 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
|
210 |
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
|
211 /* 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
|
212 if (*line == '#' || *line == '\0') |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
213 continue; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
214 |
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
|
215 /* 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
|
216 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
|
217 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
|
218 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
|
219 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
|
220 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
|
221 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
|
222 } |
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 (*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
|
224 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
|
225 } 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
|
226 *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
|
227 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
|
228 } |
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 } |
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 |
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 /* 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
|
232 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
|
233 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
|
234 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
|
235 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
|
236 |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
237 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
|
238 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
|
239 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
|
240 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
|
241 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
|
242 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
|
243 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
|
244 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
|
245 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
|
246 } |
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 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
|
248 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
|
249 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
|
250 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
|
251 } |
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 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
|
253 } |
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
|
254 |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
255 while (p > line && p[-1] == ' ') p--; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
256 key = t_strdup_until(line, p); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
257 |
5166
cc8b33172a86
Get pop3_uidl_format even if it's inside protocol pop3 {}
Timo Sirainen <tss@iki.fi>
parents:
5148
diff
changeset
|
258 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
|
259 if (!pop3_section || |
cc8b33172a86
Get pop3_uidl_format even if it's inside protocol pop3 {}
Timo Sirainen <tss@iki.fi>
parents:
5148
diff
changeset
|
260 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
|
261 continue; |
cc8b33172a86
Get pop3_uidl_format even if it's inside protocol pop3 {}
Timo Sirainen <tss@iki.fi>
parents:
5148
diff
changeset
|
262 } |
cc8b33172a86
Get pop3_uidl_format even if it's inside protocol pop3 {}
Timo Sirainen <tss@iki.fi>
parents:
5148
diff
changeset
|
263 |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
264 do { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
265 value++; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
266 } while (*value == ' '); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
267 |
5050
167c602ef8b4
If config file contained quoted "value", the quotes weren't stripped.
Timo Sirainen <tss@iki.fi>
parents:
5049
diff
changeset
|
268 len = strlen(value); |
167c602ef8b4
If config file contained quoted "value", the quotes weren't stripped.
Timo Sirainen <tss@iki.fi>
parents:
5049
diff
changeset
|
269 if (len > 0 && |
167c602ef8b4
If config file contained quoted "value", the quotes weren't stripped.
Timo Sirainen <tss@iki.fi>
parents:
5049
diff
changeset
|
270 ((*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
|
271 (*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
|
272 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
|
273 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
|
274 } |
4963
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
275 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
|
276 continue; |
b13c7888563c
deliver was treating boolean settings set to "no" as if they were "yes"
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
277 |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
278 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
|
279 } |
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
|
280 i_stream_unref(&input); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
281 t_pop(); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
282 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
283 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
284 static const struct var_expand_table * |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
285 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
|
286 { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
287 static struct var_expand_table static_tab[] = { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
288 { 'u', NULL }, |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
289 { 'n', NULL }, |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
290 { 'd', NULL }, |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
291 { 's', NULL }, |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
292 { 'h', NULL }, |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
293 { 'l', NULL }, |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
294 { 'r', NULL }, |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
295 { 'p', NULL }, |
4625 | 296 { 'i', NULL }, |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
297 { '\0', NULL } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
298 }; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
299 struct var_expand_table *tab; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
300 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
301 tab = t_malloc(sizeof(static_tab)); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
302 memcpy(tab, static_tab, sizeof(static_tab)); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
303 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
304 tab[0].value = user; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
305 tab[1].value = t_strcut(user, '@'); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
306 tab[2].value = strchr(user, '@'); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
307 if (tab[2].value != NULL) tab[2].value++; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
308 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
|
309 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
|
310 "/HOME_DIRECTORY_USED_BUT_NOT_GIVEN_BY_USERDB"; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
311 tab[5].value = NULL; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
312 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
|
313 tab[7].value = my_pid; |
4625 | 314 tab[8].value = dec2str(geteuid()); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
315 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
316 return tab; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
317 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
318 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
319 static const char * |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
320 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
|
321 { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
322 string_t *str; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
323 const char *p; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
324 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
325 str = t_str_new(256); |
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 /* it's either type:data or just data */ |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
328 p = strchr(env, ':'); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
329 if (p != NULL) { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
330 while (env != p) { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
331 str_append_c(str, *env); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
332 env++; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
333 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
334 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
335 str_append_c(str, *env++); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
336 } |
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 if (env[0] == '~' && env[1] == '/') { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
339 /* expand home */ |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
340 env = t_strconcat("%h", env+1, NULL); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
341 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
342 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
343 /* expand %vars */ |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
344 var_expand(str, env, table); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
345 return str_c(str); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
346 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
347 |
4636
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
348 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
|
349 { |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
350 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
|
351 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
|
352 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
|
353 |
4647
5f467dc79a19
Increase default address sanitizer pool size
Timo Sirainen <tss@iki.fi>
parents:
4637
diff
changeset
|
354 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
|
355 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
|
356 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
|
357 |
af8caaba0f67
Don't crash with -f "". Changed the default from envelope to be
Timo Sirainen <tss@iki.fi>
parents:
4701
diff
changeset
|
358 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
|
359 *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
|
360 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
|
361 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
|
362 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
|
363 else |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
364 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
|
365 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
|
366 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
|
367 } |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
368 |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
369 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
|
370 { |
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
|
371 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
|
372 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
|
373 |
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
|
374 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
|
375 |
4636
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
376 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
|
377 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
|
378 |
5210
b77a67169fc5
While parsing the input stream ignore the mbox hidden headers so that eg.
Timo Sirainen <tss@iki.fi>
parents:
5186
diff
changeset
|
379 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
|
380 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
|
381 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
|
382 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
|
383 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
|
384 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
|
385 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
|
386 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
|
387 NULL); |
b77a67169fc5
While parsing the input stream ignore the mbox hidden headers so that eg.
Timo Sirainen <tss@iki.fi>
parents:
5186
diff
changeset
|
388 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
|
389 |
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
|
390 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
|
391 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
|
392 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
|
393 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
|
394 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
|
395 |
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
|
396 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
|
397 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
|
398 "/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
|
399 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
|
400 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
|
401 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
|
402 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
|
403 } |
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 |
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
|
405 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
|
406 { |
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
|
407 /* 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
|
408 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
|
409 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
|
410 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
|
411 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
|
412 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
|
413 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
|
414 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
|
415 *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
|
416 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
|
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 } |
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 |
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
|
420 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
|
421 { |
5049
1acb3b558c3f
If log_timestamp isn't uncommented in dovecot.conf, use the default.
Timo Sirainen <tss@iki.fi>
parents:
5044
diff
changeset
|
422 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
|
423 |
5291
41b80786c06f
failure_exit_callback hook was set too late, so if log opening failed it
Timo Sirainen <tss@iki.fi>
parents:
5249
diff
changeset
|
424 i_set_failure_exit_callback(failure_exit_callback); |
41b80786c06f
failure_exit_callback hook was set too late, so if log opening failed it
Timo Sirainen <tss@iki.fi>
parents:
5249
diff
changeset
|
425 |
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
|
426 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
|
427 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
|
428 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
|
429 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
|
430 int facility; |
167c602ef8b4
If config file contained quoted "value", the quotes weren't stripped.
Timo Sirainen <tss@iki.fi>
parents:
5049
diff
changeset
|
431 |
167c602ef8b4
If config file contained quoted "value", the quotes weren't stripped.
Timo Sirainen <tss@iki.fi>
parents:
5049
diff
changeset
|
432 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
|
433 facility = LOG_MAIL; |
167c602ef8b4
If config file contained quoted "value", the quotes weren't stripped.
Timo Sirainen <tss@iki.fi>
parents:
5049
diff
changeset
|
434 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
|
435 } 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
|
436 /* 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
|
437 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
|
438 } |
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
|
439 |
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
|
440 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
|
441 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
|
442 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
|
443 |
5049
1acb3b558c3f
If log_timestamp isn't uncommented in dovecot.conf, use the default.
Timo Sirainen <tss@iki.fi>
parents:
5044
diff
changeset
|
444 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
|
445 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
|
446 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
|
447 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
|
448 } |
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
|
449 |
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
|
450 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
|
451 { |
4727
4710a0429914
Added -f parameter to usage help.
Timo Sirainen <tss@iki.fi>
parents:
4725
diff
changeset
|
452 printf( |
4710a0429914
Added -f parameter to usage help.
Timo Sirainen <tss@iki.fi>
parents:
4725
diff
changeset
|
453 "Usage: deliver [-c <config file>] [-d <destination user>] [-m <mailbox>]\n" |
5351
5220d4e6690d
Ignore -m "" parameter. Added -n option to not autocreate the mailbox. If
Timo Sirainen <tss@iki.fi>
parents:
5333
diff
changeset
|
454 " [-n] [-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
|
455 } |
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
|
456 |
5220
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
457 void deliver_env_clean(void) |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
458 { |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
459 const char *tz, *home; |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
460 |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
461 tz = getenv("TZ"); |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
462 if (tz != NULL) |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
463 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
|
464 home = getenv("HOME"); |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
465 if (home != NULL) |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
466 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
|
467 |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
468 /* 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
|
469 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
|
470 we t_strconcat() them above. */ |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
471 env_clean(); |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
472 |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
473 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
|
474 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
|
475 } |
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
476 |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
477 int main(int argc, char *argv[]) |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
478 { |
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
|
479 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
|
480 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
|
481 const char *mailbox = "INBOX"; |
5220
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
482 const char *auth_socket; |
4563
5d725c24d5a0
Set umask from dovecot.conf, or default to 0077.
Timo Sirainen <tss@iki.fi>
parents:
4548
diff
changeset
|
483 const char *home, *destination, *user, *mail_env, *value; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
484 const struct var_expand_table *table; |
3260
6a179bf1272e
Moved several getenv()s from lib-storage to main code. deliver binary was
Timo Sirainen <tss@iki.fi>
parents:
3255
diff
changeset
|
485 enum mail_storage_flags flags; |
4876
f1d77064884c
Lock handling changes. Everything goes through file-lock API now and there's
Timo Sirainen <tss@iki.fi>
parents:
4848
diff
changeset
|
486 enum file_lock_method lock_method; |
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
|
487 struct mail_storage *storage, *mbox_storage; |
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 struct mailbox *box; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
489 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
|
490 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
|
491 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
|
492 uid_t process_euid; |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
493 int i, ret; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
494 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
495 lib_init(); |
5249
784dc7224718
Removed pool parameter from io_loop_create()
Timo Sirainen <tss@iki.fi>
parents:
5220
diff
changeset
|
496 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
|
497 |
3620
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3389
diff
changeset
|
498 lib_signals_init(); |
3360cc019737
Implemented new signal handling framework, which makes handling signals much
Timo Sirainen <tss@iki.fi>
parents:
3389
diff
changeset
|
499 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
|
500 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
|
501 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
|
502 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
|
503 #ifdef SIGXFSZ |
4903
204d7edc7cdc
Added context parameter type safety checks for most callback APIs.
Timo Sirainen <tss@iki.fi>
parents:
4891
diff
changeset
|
504 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
|
505 #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
|
506 |
5220
7fbdcce95982
Keep only TZ and HOME environments when calling sendmail.
Timo Sirainen <tss@iki.fi>
parents:
5210
diff
changeset
|
507 deliver_env_clean(); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
508 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
509 destination = NULL; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
510 for (i = 1; i < argc; i++) { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
511 if (strcmp(argv[i], "-d") == 0) { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
512 /* destination user */ |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
513 i++; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
514 if (i == argc) { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
515 i_fatal_status(EX_USAGE, |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
516 "Missing destination argument"); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
517 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
518 destination = argv[i]; |
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
|
519 } 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
|
520 /* config file path */ |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
521 i++; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
522 if (i == argc) { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
523 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
|
524 "Missing config file path argument"); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
525 } |
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
|
526 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
|
527 } 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
|
528 /* destination mailbox */ |
f2d65601097c
Added -m parameter to store mail to non-INBOX mailbox without Sieve
Timo Sirainen <tss@iki.fi>
parents:
3637
diff
changeset
|
529 i++; |
f2d65601097c
Added -m parameter to store mail to non-INBOX mailbox without Sieve
Timo Sirainen <tss@iki.fi>
parents:
3637
diff
changeset
|
530 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
|
531 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
|
532 "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
|
533 } |
5351
5220d4e6690d
Ignore -m "" parameter. Added -n option to not autocreate the mailbox. If
Timo Sirainen <tss@iki.fi>
parents:
5333
diff
changeset
|
534 /* 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
|
535 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
|
536 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
|
537 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
|
538 } 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
|
539 /* destination mailbox */ |
5220d4e6690d
Ignore -m "" parameter. Added -n option to not autocreate the mailbox. If
Timo Sirainen <tss@iki.fi>
parents:
5333
diff
changeset
|
540 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
|
541 } 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
|
542 /* 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
|
543 i++; |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
544 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
|
545 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
|
546 "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
|
547 } |
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
548 envelope_sender = argv[i]; |
5044
1e5b5484c603
Ignore empty parameters. "Unknown argument: xx" printed wrong argument.
Timo Sirainen <tss@iki.fi>
parents:
4963
diff
changeset
|
549 } 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
|
550 print_help(); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
551 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
|
552 "Unknown argument: %s", argv[i]); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
553 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
554 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
555 |
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
|
556 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
|
557 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
|
558 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
|
559 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
|
560 /* 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
|
561 struct passwd *pw; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
562 |
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
|
563 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
|
564 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
|
565 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
|
566 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
|
567 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
|
568 } 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
|
569 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
|
570 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
|
571 } |
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 } else { |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
573 i_fatal_status(EX_USAGE, |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
574 "destination user parameter (-d user) not given"); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
575 } |
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 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
|
578 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
|
579 |
4728
80afcbfce92a
Make mail_debug=yes work with deliver too.
Timo Sirainen <tss@iki.fi>
parents:
4727
diff
changeset
|
580 if (getenv("MAIL_DEBUG") != NULL) |
80afcbfce92a
Make mail_debug=yes work with deliver too.
Timo Sirainen <tss@iki.fi>
parents:
4727
diff
changeset
|
581 env_put("DEBUG=1"); |
80afcbfce92a
Make mail_debug=yes work with deliver too.
Timo Sirainen <tss@iki.fi>
parents:
4727
diff
changeset
|
582 |
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 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
|
584 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
|
585 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
|
586 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
|
587 |
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
|
588 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
|
589 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
|
590 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
|
591 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
|
592 |
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
|
593 /* 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
|
594 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
|
595 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
|
596 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
|
597 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
|
598 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
|
599 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
|
600 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
|
601 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
|
602 } |
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
|
603 } |
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
|
604 } 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
|
605 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
|
606 } |
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
|
607 |
4563
5d725c24d5a0
Set umask from dovecot.conf, or default to 0077.
Timo Sirainen <tss@iki.fi>
parents:
4548
diff
changeset
|
608 value = getenv("UMASK"); |
5d725c24d5a0
Set umask from dovecot.conf, or default to 0077.
Timo Sirainen <tss@iki.fi>
parents:
4548
diff
changeset
|
609 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
|
610 i = 0077; |
5d725c24d5a0
Set umask from dovecot.conf, or default to 0077.
Timo Sirainen <tss@iki.fi>
parents:
4548
diff
changeset
|
611 (void)umask(i); |
5d725c24d5a0
Set umask from dovecot.conf, or default to 0077.
Timo Sirainen <tss@iki.fi>
parents:
4548
diff
changeset
|
612 |
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
|
613 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
|
614 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
|
615 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
|
616 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
|
617 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
|
618 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
|
619 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
|
620 "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
|
621 } |
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
|
622 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
|
623 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
|
624 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
|
625 |
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
|
626 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
|
627 duplicate_init(); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
628 mail_storage_init(); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
629 mail_storage_register_all(); |
4891
6ab2712f1a93
Only imap binary was actually working.
Timo Sirainen <tss@iki.fi>
parents:
4876
diff
changeset
|
630 mailbox_list_register_all(); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
631 |
4701
190a66df2f82
Renamed default_mail_env to mail_location. Keep the default_mail_env working
Timo Sirainen <tss@iki.fi>
parents:
4652
diff
changeset
|
632 /* MAIL comes from userdb, MAIL_LOCATION from dovecot.conf */ |
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
|
633 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
|
634 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
|
635 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
|
636 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
|
637 /* 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
|
638 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
|
639 } |
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
|
640 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
|
641 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
|
642 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
|
643 } |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
644 |
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
|
645 if (getenv("MAIL_PLUGINS") == 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
|
646 modules = 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
|
647 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
|
648 const char *plugin_dir = getenv("MAIL_PLUGIN_DIR"); |
5186
a7627141ec7f
Don't compare to PACKAGE_VERSION in lib/ core directly, rather make
Timo Sirainen <tss@iki.fi>
parents:
5166
diff
changeset
|
649 const char *version; |
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
|
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 if (plugin_dir == 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
|
652 plugin_dir = MODULEDIR"/lda"; |
5186
a7627141ec7f
Don't compare to PACKAGE_VERSION in lib/ core directly, rather make
Timo Sirainen <tss@iki.fi>
parents:
5166
diff
changeset
|
653 |
a7627141ec7f
Don't compare to PACKAGE_VERSION in lib/ core directly, rather make
Timo Sirainen <tss@iki.fi>
parents:
5166
diff
changeset
|
654 version = getenv("VERSION_IGNORE") != NULL ? |
a7627141ec7f
Don't compare to PACKAGE_VERSION in lib/ core directly, rather make
Timo Sirainen <tss@iki.fi>
parents:
5166
diff
changeset
|
655 NULL : PACKAGE_VERSION; |
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 modules = module_dir_load(plugin_dir, getenv("MAIL_PLUGINS"), |
5186
a7627141ec7f
Don't compare to PACKAGE_VERSION in lib/ core directly, rather make
Timo Sirainen <tss@iki.fi>
parents:
5166
diff
changeset
|
657 TRUE, version); |
5148
7f2c39d7a2cc
module_dir_load() doesn't call init() functions anymore. Added a new
Timo Sirainen <tss@iki.fi>
parents:
5143
diff
changeset
|
658 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
|
659 } |
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
|
660 |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
661 /* FIXME: how should we handle namespaces? */ |
4121
f63ff46276a8
Use mail_storage_parse_env(), even though this code doesn't even compile
Timo Sirainen <tss@iki.fi>
parents:
4070
diff
changeset
|
662 mail_storage_parse_env(&flags, &lock_method); |
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 storage = mail_storage_create_with_data(mail_env, destination, |
3260
6a179bf1272e
Moved several getenv()s from lib-storage to main code. deliver binary was
Timo Sirainen <tss@iki.fi>
parents:
3255
diff
changeset
|
664 flags, lock_method); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
665 if (storage == NULL) { |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
666 i_fatal_status(EX_CONFIG, |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
667 "Failed to create storage for '%s' with mail '%s'", |
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 destination, mail_env == NULL ? "(null)" : mail_env); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
669 } |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
670 |
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
|
671 mbox_storage = mail_storage_create("mbox", "/tmp", destination, 0, |
4876
f1d77064884c
Lock handling changes. Everything goes through file-lock API now and there's
Timo Sirainen <tss@iki.fi>
parents:
4848
diff
changeset
|
672 FILE_LOCK_METHOD_FCNTL); |
4636
630e6121fb8d
Added -f parameter to specify the envelope sender which is used in mbox
Timo Sirainen <tss@iki.fi>
parents:
4625
diff
changeset
|
673 input = create_mbox_stream(0, 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
|
674 box = mailbox_open(mbox_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
|
675 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
|
676 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
|
677 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
|
678 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
|
679 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
|
680 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
|
681 |
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
|
682 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
|
683 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
|
684 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
|
685 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
|
686 |
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
|
687 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
|
688 ret = deliver_mail == 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
|
689 deliver_mail(storage, mail, destination, mailbox); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
690 |
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
|
691 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
|
692 /* 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
|
693 i_stream_seek(input, 0); |
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
|
694 ret = deliver_save(storage, mailbox, mail, 0, NULL); |
5351
5220d4e6690d
Ignore -m "" parameter. Added -n option to not autocreate the mailbox. If
Timo Sirainen <tss@iki.fi>
parents:
5333
diff
changeset
|
695 if (ret < 0 && strcasecmp(mailbox, "INBOX") != 0) { |
5220d4e6690d
Ignore -m "" parameter. Added -n option to not autocreate the mailbox. If
Timo Sirainen <tss@iki.fi>
parents:
5333
diff
changeset
|
696 /* still didn't work. try once more to save it |
5220d4e6690d
Ignore -m "" parameter. Added -n option to not autocreate the mailbox. If
Timo Sirainen <tss@iki.fi>
parents:
5333
diff
changeset
|
697 to INBOX. */ |
5220d4e6690d
Ignore -m "" parameter. Added -n option to not autocreate the mailbox. If
Timo Sirainen <tss@iki.fi>
parents:
5333
diff
changeset
|
698 i_stream_seek(input, 0); |
5220d4e6690d
Ignore -m "" parameter. Added -n option to not autocreate the mailbox. If
Timo Sirainen <tss@iki.fi>
parents:
5333
diff
changeset
|
699 ret = deliver_save(storage, "INBOX", mail, 0, NULL); |
5220d4e6690d
Ignore -m "" parameter. Added -n option to not autocreate the mailbox. If
Timo Sirainen <tss@iki.fi>
parents:
5333
diff
changeset
|
700 } |
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
|
701 } |
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
|
702 |
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
|
703 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
|
704 const char *error; |
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 bool syntax, temporary_error; |
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
|
706 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
|
707 |
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
|
708 error = mail_storage_get_last_error(storage, &syntax, |
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
|
709 &temporary_error); |
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
|
710 if (temporary_error) |
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
|
711 return EX_TEMPFAIL; |
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
|
712 |
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
|
713 /* we'll have to reply with permanent failure */ |
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 ret = mail_send_rejection(mail, destination, error); |
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 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
|
716 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
|
717 /* 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
|
718 } |
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
|
719 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
|
720 |
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
|
721 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
|
722 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
|
723 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
|
724 |
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
|
725 mail_storage_destroy(&mbox_storage); |
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
|
726 mail_storage_destroy(&storage); |
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
|
727 |
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
|
728 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
|
729 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
|
730 |
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
|
731 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
|
732 dict_driver_unregister(&dict_driver_client); |
3625 | 733 lib_signals_deinit(); |
734 | |
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
|
735 io_loop_destroy(&ioloop); |
3199
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
736 lib_deinit(); |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
737 |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
738 return EX_OK; |
938f948651f1
Added initial version of Dovecot LDA.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
739 } |