Timo Sirainen [Mon, 9 Sep 2019 16:16:19 +0000 (19:16 +0300)]
lib-storage: Make sure ENVELOPE parsing isn't done twice concurrently
If save_envelope=TRUE and ENVELOPE headers aren't already in cache,
header_cache_callback() starts parsing the ENVELOPE. But
imap_envelope_parse_callback() does it as well, so the envelope parsing is
done concurrently by the two callbacks.
Also once the ENVELOPE parsing is done once, make sure it's not done again
if the header is parsed again.
This didn't cause any problems so far, but it fixes the following commit to
work correctly.
Timo Sirainen [Tue, 14 Jan 2020 12:58:05 +0000 (14:58 +0200)]
lib-imap-storage, doveadm: Ignore INBOX ACLs when accessing server metadata
The server metadata is always accessible. INBOX's ACLs aren't relevant,
even though internally for now we're using INBOX for storing the server
metadata.
smtp_server_connection didn't properly copy the xclient_extensions settings
from the smtp_server. In fact it did the opposite of recreating the server
settings using the connection pool. Later on after the connection was freed
and another connection created this could result in crashes.
Timo Sirainen [Tue, 21 Jan 2020 13:59:51 +0000 (15:59 +0200)]
lib-fs: Add errno parameter to fs_set_error() change callers to use it.
This is now explicit so it can't be forgotten accidentally. Fixes several
bugs where errno wasn't set on error conditions, which could have caused
callers to handle the error wrong.
Timo Sirainen [Thu, 28 Nov 2019 18:28:35 +0000 (20:28 +0200)]
lib-storage: Add MAIL_FETCH_REFCOUNT_ID
This returns a unique ID for the mail that is counted by
MAIL_FETCH_REFCOUNT. For example if the refcount is counted using the
file's st_nlinks, then the refcount-id is the file's inode number. This is
likely only going to be used by lazy_expunge_only_last_instance=yes
tracking.
Timo Sirainen [Wed, 11 Dec 2019 12:10:12 +0000 (14:10 +0200)]
lib-master: Simplify auth-master connection code
For UNIX sockets the client_connected callback is always called immediately
after successful connection_client_connect(). So we might as well directly
add auth->connected=TRUE after it succeeds without having to go through the
callback.
If the callback had been called later, the current code would have been
broken because it already assumed that auth->connected=TRUE is set
immediately after returning from master_login_auth_connect(). So this
change just makes it clearer what happens and what is required.
Timo Sirainen [Thu, 12 Dec 2019 10:36:23 +0000 (12:36 +0200)]
lib-storage: Always fix inconsistency when syncing private flags index
The flags index can't be fully synced with the main index at all times
anyway, so don't even try. Just fully sync it always and fix any found
inconsistencies.
Fixes:
Error: dovecot.index.pvt reset, view is now inconsistent
Timo Sirainen [Thu, 12 Dec 2019 10:30:37 +0000 (12:30 +0200)]
lib-index: Fix potential crash when view is synced after index is reset
view_sync_set_log_view_range() sees that index is reset, so it clears the
log_view, which sets log_view->cur=NULL. Later on view_sync_have_expunges()
calls mail_transaction_log_view_mark(), which crashes because
log_view->cur==NULL.
This crash mainly happened when searching for seen flags in a newly created
mailbox with INDEXPVT. This commit doesn't actually fix the bug, but it
fixes the resulting crash.
Timo Sirainen [Tue, 3 Dec 2019 21:55:55 +0000 (23:55 +0200)]
lib-storage: mailbox_get_metadata() - Return cache_fields allocated from data stack
Using mailbox.metacache_pool breaks if it's called multiple times for the
same mailbox and the old results are still used. This happened in
index_copy_cache_fields() when copying mails within the same mailbox. In
some situations this could have caused a crash.
Timo Sirainen [Fri, 29 Nov 2019 15:49:23 +0000 (17:49 +0200)]
lib-fs: Log any pending errors in fs_file_deinit()
If error was set to the file but it wasn't accessed with
fs_file_last_error(), it means the error message would become lost.
Usually this is probably not intended.
Timo Sirainen [Fri, 29 Nov 2019 15:11:15 +0000 (17:11 +0200)]
lib-fs: Log previous fs_file error if it's being overridden
This makes sure that errors aren't lost. If fs_file_last_error() has been
used it means that the error has been looked at and there's no need to log
it.
Some of the "expected" errors won't be logged though. This check is done
based on errno. This is also why this commit reorders
fs_file_set_error_async() to set errno=EAGAIN earlier.
Timo Sirainen [Mon, 25 Nov 2019 11:20:53 +0000 (13:20 +0200)]
lib-fs: Remove fs_set_critical()
The original idea was similar to mail_storage_set_error/critical()
separation. But in storage they are used to clearly separate between
errors caused by untrusted users vs internal errors. In lib-fs case
all the errors are internal errors. Also all the lib-fs callers are
supposed to log the errors unless they decide to handle them specially,
so there's really no need a fs_set_critical() that just causes them to
be logged twice.