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.
Markus Valentin [Tue, 26 Nov 2019 14:30:47 +0000 (15:30 +0100)]
doveadm: mail: Add trans-flags parameter to doveadm mail commands
Add a trans-flags parameter to doveadm-mail calls. This allows to
run mail commands with specific mailbox transaction flags.
mail-storage.h enum mailbox_transaction_flags
All doveadm calls take the defined flag additionally to their orignal
flags. The flags can be set as decimal integer on the doveadm call.
Timo Sirainen [Fri, 22 Nov 2019 14:59:55 +0000 (16:59 +0200)]
lib: connection: Remove clearing of event fields
This was done mainly because the fields could have become mixed up when a
client connection event had a parent server connection event. But now that
the IP and port fields are different for client and server connections this
problem mainly doesn't exist.