fts-solr: Append '/' to URL path when missing in configuration
This fixes a crash when url parameter has empty path like
http://localhost:8080 instead of http://localhost:8080/ and makes using
url like http://localhost:8080/solr behave the same as
http://localhost:8080/solr/
Timo Sirainen [Tue, 26 Jun 2018 19:33:33 +0000 (22:33 +0300)]
quota-clone: Fix assert-crash at deinit if quota_clone update fails
The timeout isn't removed on failure, so it crashed with:
Panic: file quota-clone-plugin.c: line 257 (quota_clone_mail_user_deinit_pre): assertion failed: (quser->to_quota_flush == NULL)
Stephan Bosch [Thu, 21 Jun 2018 20:55:50 +0000 (22:55 +0200)]
lib-smtp: server: data command: Hold a reference to the connection while handling input.
Makes sure connection object remains available while command is handled. Fixes a
valgrind error reported for accessing the connection object after it is freed,
which happens for the destroy debug message of the command (even when debugging
is not enabled).
Timo Sirainen [Mon, 25 Jun 2018 09:10:55 +0000 (12:10 +0300)]
imapc: Fix potential assert-crash when selecting empty mailbox
imapc_mailbox_fetch_state_finish() should have been expunging all the mails,
but it didn't happen since UIDNEXT wasn't received yet at the time EXISTS
was sent, so sync_uid_next was always 0 when checking it. Fix this by
calling imapc_mailbox_fetch_state_finish() only after SELECT/EXAMINE tagged
reply is received.
This practically happened only when index files were used. It could also
happen without index files, if the session had received new mails after
opening the mailbox, then getting disconnected and before reconnect was
finished all the mails were externally expunged.
Stephan Bosch [Wed, 20 Jun 2018 12:01:18 +0000 (14:01 +0200)]
lib-smtp: server: Make sure conn->state.data_failed is only set when no previous BDAT/BURL is pending.
Otherwise, the server would sometimes send 503 error for the first BDAT/BURL
command, while a subsequent command was actually failing earlier than the
initial one completed. Additionally, this caused a panic crash.
Panic was:
submission(stephan)<8353><C+7QBfysKluhIAAAmoV78g>: Panic: Input stream /home/stephan/Maildir/cur/1517515808.M176007P2993.johanna,S=1903,W=1956:2,DFS unexpectedly has references
Timo Sirainen [Tue, 19 Jun 2018 12:00:02 +0000 (15:00 +0300)]
quota-clone: Move state tracking to user context
This way there's no need to do multiple flushes when e.g. multiple
mailboxes change.
The flush had to be removed from close(), because the code path recurses:
* mailbox_transaction_commit() when mail is saved
* quota_count() starts counting the quota, which opens and closes mailbox
* quota_clone_mailbox_close() attempts to flush quota, which again recurses
into quota_count(), which returns 0 for the quota value.
Timo Sirainen [Sat, 16 Jun 2018 12:09:53 +0000 (15:09 +0300)]
imapc: Fix assert-crash when reconnecting expunges newly added messages
The initial FETCH 1:* during reconnection may notice some messages that are
missing and tries to expunge them. But those messages could still be in
delayed_sync_trans, and currently lib-index doesn't support expunging anything
but the latest mail from a transaction.
Timo Sirainen [Mon, 18 Jun 2018 13:19:55 +0000 (16:19 +0300)]
lib: If log write returns EAGAIN, use poll() instead of ioloop for waiting
As explained in 861d40b9aebabccae7d48e49a18cbc631ab1fefe commit message,
ioloop can call various callbacks and it can also recurse back to error
logging. Using poll() directly is safer.
Timo Sirainen [Mon, 18 Jun 2018 13:07:30 +0000 (16:07 +0300)]
lib: Revert earlier "log write is blocking" handling change
1) It was buggy, because it set O_NONBLOCK rather than removing it.
2) fd flags are shared across all the processes using the fd. We can't
reliably implement the process title update, because some processes are
blocking on the log write() before they change the process title.
Timo Sirainen [Sat, 16 Jun 2018 16:58:57 +0000 (19:58 +0300)]
lib-imap-client: Remove assert from imapc_client_mailbox_reconnect
It's possible for the assert to trigger if there are multiple reconnections.
imapc_connection_can_reconnect() checks a bit later whether the reconnection
can still be done.
Timo Sirainen [Mon, 18 Jun 2018 16:13:30 +0000 (19:13 +0300)]
imapc: Don't trust mail stream to have correct CRLFs
It's not that expensive to just recalculate them. If they're not correct in
the stream, it can result in e.g. truncated emails due to wrong virtual_size
being used in body_size calculation. The wrong CRLFs can especially happen
if plugins modify the stream in istream_opened() hook.
Timo Sirainen [Wed, 13 Jun 2018 17:09:32 +0000 (20:09 +0300)]
doveadm dump: Fix dumping "vsize" header in dovecot.index
It was trying to print it as the "vsize" header in dovecot.list.index.
This caused confusing output, as well as potentially accessing memory
out of bounds.
Timo Sirainen [Tue, 12 Jun 2018 14:08:04 +0000 (17:08 +0300)]
lib-dcrypt, mail-crypt: Fix leaking memory when using non-global keys
The users' private keys had one reference too much. Because of key cache,
most likely the keys were leaked only once at deinit.
Changed the i_stream_create_decrypt_callback() API so that it allows the
callback to create the key itself without having to store it anywhere.
In this case the key was already added to cache, which increased its
refcount. So an alternative fix would have been to simply unreferenced the
key before returning it. It's a bit ugly though to rely on such caches,
since without the cache the code would be buggy.