lib-storage: move snippet generation to mail-save-finish
This is necessary because some storage backends (most notably sdbox) do
not allow getting the mail stream before the mail is fully written out.
(See written_to_disk in sdbox-file.h.)
If we could avoid getting the stream to generate a snippet we could
leave this where it is.
Timo Sirainen [Thu, 15 Feb 2018 16:16:15 +0000 (18:16 +0200)]
imap: Don't set storage callbacks before namespaces are created
This fixes sending untagged OK/NO notifications from storage (e.g. lock
waits/override notifications). It was broken by e031d9aaae59a9f79710dc1138b76b69272615a3
charset-alias-plugin.c:113:27: error: comparison between pointer and zero
character constant [-Werror=pointer-compare]
for (i = 0; keyvalues[i] != '\0'; i++) {
^~
charset-alias-plugin.c:113:14: note: did you mean to dereference the pointer?
for (i = 0; keyvalues[i] != '\0'; i++) {
Stephan Bosch [Wed, 31 Jan 2018 09:27:54 +0000 (10:27 +0100)]
lmtp: local: Use recipient index in lmtp_local_rcpt_reply_overquota().
When used during the DATA command, it should send a reply for the correct
recipient. During the RCPT command there is only one reply due. Added assert
that checks this.
Stephan Bosch [Wed, 31 Jan 2018 09:34:11 +0000 (10:34 +0100)]
lmtp: local: Add explicit cmd parameter to lmtp_local_rcpt_reply_overquota().
Using the RCPT cmd is only valid for the RCPT command and not when quota excess
is detected during DATA. That would cause a segmentation fault, since
rcpt->rcpt.rcpt_cmd == NULL.
Timo Sirainen [Tue, 9 Jan 2018 20:37:25 +0000 (15:37 -0500)]
lib-storage: Lock mailbox_list for mailbox create/delete/rename
This is only required for mailbox creation to fix a race condition with
LAYOUT=index: If INBOX doesn't exist it will rescan the mailboxes to
find out if there are any missing ones. If INBOX creation isn't locked,
it's possible that the first process hasn't finished creating INBOX
before the second process find it and attempts to open it.
The delete and rename locking are probably useful to guard against race
conditions when clients intentionally issues create/delete/rename commands
concurrently.
Timo Sirainen [Tue, 6 Feb 2018 15:35:18 +0000 (17:35 +0200)]
lib: Add file_lock_from_dotlock()
The dotlock creation requires various settings, so the file-lock.h API can't
easily be used to create it. But once created, it's simpler to keep all lock
types in the same struct file_lock, which can be unlocked/freed once
finished.
Stephan Bosch [Wed, 27 Dec 2017 13:38:41 +0000 (14:38 +0100)]
submission: EHLO command: Remove obsolete pending_ehlo handling.
This was used to wait with sending an EHLO reply until the proxy connection to the relay server completes.
The previous commit made this functionality obsolete, since command input handling is blocked entirely until the proxy connection is ready.
Stephan Bosch [Wed, 27 Dec 2017 13:36:10 +0000 (14:36 +0100)]
submission: Block server input handling until proxy connection to relay server completes.
This makes sure we are aware of the full extent of the backend server's capabilities, before we start handling commands.
Before, only EHLO commands were blocked this way, but this did not account for MAIL/RCPT parameters, which are equally dependent.
Fixes problems with clients that send no EHLO after AUTH, like Thunderbird.
Stephan Bosch [Wed, 27 Dec 2017 16:02:12 +0000 (17:02 +0100)]
lib-smtp: server: Add APIs for halting and resuming connection command handling.
Also adds function to start the connection in a pending (halted) state. This way the greeting can already be sent (over SSL if needed), while deferring command handling until some external activity is completed.
Timo Sirainen [Mon, 5 Feb 2018 20:21:13 +0000 (22:21 +0200)]
fts: Don't reindex FTS mails if .cache file is deleted
This means that if fts is enabled, "doveadm index" no longer adds mails
to dovecot.index.cache if it's deleted. However, it was rarely used for
that purpose. More likely due to a corrupted cache file all the mails were
unnecessarily being opened and reindexed.
Timo Sirainen [Mon, 5 Feb 2018 21:54:33 +0000 (23:54 +0200)]
fts: Fix searching headers with TEXT/BODY
TEXT is searching headers and BODY is searching MIME headers. Those headers
were indexed with data language, so search must also include data language
when looking up words. We'll just include the data language for all
searches now, so it should always work correctly.
Stephan Bosch [Fri, 19 Jan 2018 13:44:50 +0000 (14:44 +0100)]
lib-smtp: client: Fix segfault occurring in connection when SSL certificate is invalid.
The connection is using its own local SSL settings to determine whether an
invalid certificate is allowed. However, these local settings were not properly
initialized.
imap: Iterate over ns settings when deciding to add SPECIAL-USE capability
To determine whether we should add the SPECIAL-USE capability to the
OK response to LOGIN, we have to iterate over namespace and mailbox
*settings* since the namespaces haven't been set up yet.
Stephan Bosch [Sun, 24 Dec 2017 14:12:36 +0000 (15:12 +0100)]
submission: Restructure handling of QUIT command.
- Avoid explicitly proxying QUIT command when the proxy connection is not ready: in that case the SMTP client connection will just send QUIT if appropriate, without waiting for reply.
- Add timeout for proxied QUIT command, so that there are no problems when the relay server hangs after QUIT (addresses FIXME).