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.
Martin Cyr [Sat, 13 Jan 2018 21:15:47 +0000 (16:15 -0500)]
Always link krb5 when gssapi is requested
Since krb5_free_context is defined in libkrb5, not libgssapi, it must be
linked, even when gssapi is found.
krb5-config --libs gssapi alone will not provide -lkrb5.
Also, krb5-config --version ANYTHING will always return 0 (at least with
Heimdal).
Phil Carmody [Mon, 11 Dec 2017 12:03:13 +0000 (14:03 +0200)]
lib/lib-test: restore DOVECOT_SRAND feature in DEBUG builds
Add a deterministic PRNG, an ability to force its use, and an
ability to re-use the same sequence later.
Since proper random numbers have been forced into use, making
reproducable tests isn't quite as easy as it used to be, it's 3 steps
rather than 2. When seeing an intermittent test failure:
- rerun the tests with environmental variable DOVECOT_SRAND=kiss
- upon seeing a new failure case, note the seed logged at the failure
- debug using DOVECOT_SRAND=<that number>
In non-DEBUG builds, there's no trace of this code, and the
randomisation that is an inherent part of many tests remains
non-reproduceable.
Works with all of the RNG preferences, getrandom/urandom/arc4.
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.
Stephan Bosch [Fri, 29 Dec 2017 00:17:15 +0000 (01:17 +0100)]
lib-http: client: Implicitly switch ioloop for global shared client context.
If the new ioloop is NULL, close the shared client context. In that case all
shared hosts, peers and idle connetions are closed and destroyed. The context
just remains as a container for settings and shared context. This is only
allowed when there are no clients left.
Stephan Bosch [Fri, 29 Dec 2017 00:05:21 +0000 (01:05 +0100)]
lib-http: client: Set req->client to NULL once the request is destroyed.
The http_client_request_destroy() function does not free the request
immediately, as long as it is still referenced. It can still be referenced by a
connection that has sent it and is waiting for a reply (payload). In the mean
time the actual client can be gone, so we want to make sure nothing is pointing
to that anymore.
This change adds a few extra assertions to make sure nothing tries to use a
NULL client later on. Some direct references to req->client are replaced with a
local client variable if there is one.
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.
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 [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.