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).
Stephan Bosch [Sun, 24 Dec 2017 11:15:29 +0000 (12:15 +0100)]
submission: Initialize proxy connection before starting the SMTP server connection.
The smtp_server_connection_login() function gets pre-login connection data from login service, which can contain commands.
The execution of commands expects the proxy connection object to be initialized.
Stephan Bosch [Mon, 22 Jan 2018 22:43:18 +0000 (23:43 +0100)]
lib-program-client: Flush/finish the output stream after o_stream_send_istream().
There may still be data in the output stream buffer. Failing to flush this
leads to truncated output. For the output towards the program o_stream_finish()
is used, since there may be an ostream_dot in between (or something else for
future features).
Stephan Bosch [Wed, 24 Jan 2018 00:09:16 +0000 (01:09 +0100)]
lib-program-client: remote: Don't change exit_code in program_client_remote_disconnect() when program_input is already NULL.
When the program_input is NULL, the stream is finished, meaning that the
exit_code is set based on the return code. There can be a program_input for
remote streams, even when the program produces no output.
Timo Sirainen [Mon, 22 Jan 2018 22:04:28 +0000 (00:04 +0200)]
lib-index: Fix removal of forced cache decisions from existing cache files
The forced-flags are written to the cache file when the file is created.
They were also read back, and the force-flag was preserved even when the
configuration was removed.
Timo Sirainen [Mon, 25 Dec 2017 09:10:19 +0000 (11:10 +0200)]
imapc: Add imapc_features=no-msn-updates
This is a stricter version of fetch-msn-workarounds. The MSNs aren't trusted
at all. This means any new untagged EXISTS and EXPUNGE replies are ignored,
as well as untagged FETCH replies that don't include UID.
A potential downside with this feature is that UID FETCH/STORE commands
sent to expunged messages will likely fail without the IMAP client being
notified of the EXPUNGEs. New mails are also not noticed, so this should
be used only when it's known that the clients don't keep the connection
open for long.
Timo Sirainen [Mon, 25 Dec 2017 14:11:26 +0000 (16:11 +0200)]
imapc: Fix sending initial FETCH after reconnection SELECTs mailbox
Move sending the FETCH when the SELECT returns tagged OK reply instead of
delaying it until mailbox is next synced. Most importantly this allows
sending the FETCH before any retried commands that are also sent after
SELECT receives tagged reply.
Timo Sirainen [Mon, 25 Dec 2017 17:34:31 +0000 (19:34 +0200)]
imapc: If mailbox select fails, rollback any changes done to it
Required by the following changes that start adding changes immediately
after SELECT. If the initial syncing doesn't finish successfully, these
changes need to be reverted.
Timo Sirainen [Wed, 17 Jan 2018 13:03:06 +0000 (15:03 +0200)]
lib-imap-client: Avoid "Unknown tag" errors for aborted commands
If mailbox is closed before all command replies were received, the commands
were aborted but they'll still receive the replies from server. Remember
the aborted commands' tag numbers so they can be ignored.
Stephan Bosch [Wed, 3 Jan 2018 18:46:58 +0000 (19:46 +0100)]
auth: client protocol: Recognize empty initial response field as an absent initial response for older clients.
Particularly, Exim sends an empty initial response field in the AUTH request for
an authentication command that has no initial response. Originally, Dovecot
allowed this, but this was recently changed so that the EXTERNAL SASL mechanism
works properly from ManageSieve. This commit makes it allowed again for older
authentication clients to send an empty initial response field for an
authentication command that has no initial response part. Sending '=' for an
empty initial response is still allowed in general.
Timo Sirainen [Mon, 18 Dec 2017 13:21:44 +0000 (15:21 +0200)]
global: Rename timing API to stats-dist API
The API wasn't really about timings specifically, but about statistics in
general. The new stats service was already using it for tracking statistics
for non-timing related numbers.
Timo Sirainen [Mon, 25 Dec 2017 16:24:35 +0000 (18:24 +0200)]
lib-storage: mail_storage_set_index_error() - handle NULL index error
This avoids assert-crashing later on in mail*_get_last_internal_error().
This could potentially be an assert instead of setting it as "BUG", but
it looks like there are various code paths in lib-index that return -1
without setting an error. (That's to avoid duplicate error logging,
although it could now be fixed with mail_index_set_error_nolog().)
Timo Sirainen [Mon, 25 Dec 2017 16:18:14 +0000 (18:18 +0200)]
lib-storage: Set index error on transaction commit() callback
The commit callback is setting errors to storage. However, it's being
called from mail_index_transaction_commit() whose callers are expecting
the error to be in index. If that index error was attempted to be used,
it could have been wrong or NULL. Fix this by setting the same storage
error also to the index.
Timo Sirainen [Thu, 28 Dec 2017 12:10:23 +0000 (14:10 +0200)]
dsync: Add per-mailbox sync lock that is always used.
Both importing and exporting gets the lock before they even sync the
mailbox. The lock is kept until the import/export finishes. This guarantees
that no matter how dsync is run, two dsyncs can't be working on the same
mailbox at the same time.
This lock is in addition to the optional per-user lock enabled by the -l
parameter. If the -l parameter is used, the same lock timeout is used for
the per-mailbox lock. Otherwise 30s timeout is used.
This should help to avoid email duplication when replication is enabled for
public namespaces, and maybe in some other rare situations as well.