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.
Timo Sirainen [Mon, 25 Nov 2019 09:06:07 +0000 (11:06 +0200)]
lib-fs: Change last_error from string_t to char *
The string isn't modified in a way that string_t is useful. This change
also allows fs_set_error() parameters to point to previous error string
without breaking.
Timo Sirainen [Fri, 29 Nov 2019 13:25:21 +0000 (15:25 +0200)]
lib: Allow events to store internal pointers
These pointers are independent of event fields, so they're ignored by event
matching, exporting and importing. Their main purpose is to allow storing
internal state to an event and allow it to be accessed by any code that can
access the event.