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.
Timo Sirainen [Fri, 22 Dec 2017 11:27:48 +0000 (13:27 +0200)]
lib-master: Hide connect(stats-writer) errors when running via CLI
Only hide errors that occur if the stats process isn't running, i.e. when
socket isn't found or there's no listener. This way e.g. permission errors
are still logged, which points to a wrong configuration.
Stephan Bosch [Thu, 21 Dec 2017 22:09:13 +0000 (23:09 +0100)]
lib-smtp: server: STARTTLS command: Call smtp_server_connection_set_ssl_streams() after calling the conn_start_tls() connection callback.
This is called instead smtp_server_connection_set_streams(), so that the connection is now marked as SSL-secured.
This fixes a submission-login bug that prevented client login when ssl=required.
Stephan Bosch [Mon, 18 Dec 2017 15:45:23 +0000 (16:45 +0100)]
lib-smtp: server: Fixed assertion in smtp_server_connection_next_reply() checking whether command is fully replied.
It did not handle LMTP DATA/BDAT command correctly, for which there can be multiple replies.
This fixes mixing local/remote recipients in LMTP, which used to crash:
Panic: file smtp-server-connection.c: line 610 (smtp_server_connection_next_reply): assertion failed: (cmd->state == SMTP_SERVER_COMMAND_STATE_READY_TO_REPLY && smtp_server_command_is_replied(cmd))
Stephan Bosch [Mon, 18 Dec 2017 14:20:07 +0000 (15:20 +0100)]
lib-smtp: command parser: Fix error recovery.
Input characters were not skipped upon error, meaning that error recovery would encounter these again.
This would make the parser parse the same data over and over again, yielding the same error.
This in turn caused the SMTP server application to hang in an infinite input loop, submitting error replies in the process, thereby filling up the process memory until exhaustion.
Problem seen in submission service, but LMTP is also affected.
Timo Sirainen [Mon, 18 Dec 2017 10:06:43 +0000 (12:06 +0200)]
lib-smtp: server: Fix panic when io_remove() is called too late
With submission-login the conn_disconnect() callback ends up in
login-common's client_disconnect(), which closes the file descriptor.
The io_remove() was done afterwards, which caused a crash:
submission-login: Panic: epoll_ctl(del, 18) failed: Bad file descriptor
Timo Sirainen [Thu, 14 Dec 2017 21:10:22 +0000 (23:10 +0200)]
*-login: Avoid unnecessary "OK Waiting for authentication process to respond"
These happened with SSL connections when the process was starting up.
The ssl-istream was triggering the IO callback, which was thinking that the
client was sending a command. If this happened early on before auth process
connection was finished, this caused several unnecessary notifications to
the client.
Stephan Bosch [Thu, 14 Dec 2017 20:50:58 +0000 (21:50 +0100)]
lib-http: client: Check whether client is running in a wait loop with the correct condition.
This used to check client->ioloop != NULL, but now it should check client->waiting.
Previous commit (e8a1b62fe4a81b211dcccd1a58b44f254074eab6) omitted a few instances where this should have been changed.
Stephan Bosch [Thu, 14 Dec 2017 09:46:39 +0000 (10:46 +0100)]
lda: Do not replace the NULL sender with a default <MAILER-DAEMON> address.
Only do this substitution locally where a NULL sender would cause problems, not everywhere else.
This e.g. causes problems when determining whether to send a rejection somewhere; attempts would be made to mail <MAILER-DAEMON>.
Also other envelope-based (Sieve) tests would get confused.
Timo Sirainen [Wed, 13 Dec 2017 23:36:50 +0000 (01:36 +0200)]
LAYOUT=fs: Fix listing prefix/INBOX
Removed some confusing special case code that didn't seem to work very well.
Implemented this now properly so that prefix/INBOX is listed as \NoSelect
mailbox whenever it has children.
It's not actually possible to differentiate between INBOX and prefix/INBOX
in the storage for a inbox=yes namespace, because they both are converted
into the same storage_name=INBOX.
Stephan Bosch [Wed, 13 Dec 2017 20:52:41 +0000 (21:52 +0100)]
lib-http: client: peer: Properly handle claiming an existing connection.
If no other connections were being created, request handling was not restarted.
This problem sometimes caused the client to hang.
Fixed by calling http_client_peer_connection_success() upon claiming an existing connection.
Timo Sirainen [Wed, 13 Dec 2017 12:19:41 +0000 (14:19 +0200)]
imap: Fix o_stream_is_corked() assert check
All the callers cork the stream, so this can only mean that the corking
failed because the connection was already closed. Continue handling the
input anyway.
Fixes:
Panic: file imap-client.c: line 1236 (client_handle_input): assertion failed: (o_stream_is_corked(client->output))