Timo Sirainen [Thu, 24 Nov 2016 15:16:30 +0000 (17:16 +0200)]
lib-index: Add mail_index_unset_fscked()
This can be used to easily remove MAIL_INDEX_HDR_FLAG_FSCKD. It takes a
transaction parameter instead of sync_ctx because some index rebuilds
are done with a separate transaction while the sync_ctx is rolled back.
Timo Sirainen [Thu, 24 Nov 2016 17:53:17 +0000 (19:53 +0200)]
lib-storage: Fail if no namespaces have list=yes
The previous check allowed all namespaces to have list=children. This
crashed later on in mail_namespaces_get_root_sep(), because it couldn't
find any list=yes namespaces.
Timo Sirainen [Tue, 22 Nov 2016 16:33:12 +0000 (18:33 +0200)]
lib-mail: Fix assert-crash in mail_html2text_more() with invalid input.
parse_data() continues forward thinking that it might have valid input,
until it has enough data and realizes that there's nothing valid. This
triggers:
Timo Sirainen [Wed, 23 Nov 2016 21:19:05 +0000 (23:19 +0200)]
lib-storage: Rotate dovecot.list.index.log* more often.
The history in these files isn't as important as in mailbox indexes.
Reduce disk space usage by rotating them more often and deleting the
.log.2 more quickly.
Timo Sirainen [Wed, 23 Nov 2016 20:42:03 +0000 (22:42 +0200)]
lib-storage: Try harder to rename a corrupted mailbox name to its old name.
If the old name exists, use it as a prefix for the new name. This is
especially useful when restoring autocreated mailboxes. A new mailbox
could have already been autocreated, but it's still useful to have
the broken one renamed with the same prefix, so it'll be clear that
these mailboxes should be merged.
Aki Tuomi [Thu, 24 Nov 2016 17:32:44 +0000 (19:32 +0200)]
dsync: Do not try replace remote folder GUID when doing oneway sync
Oneway sync tried to replace remote folder's GUID when
running in one way mode. This causes trouble, e.g.
when running with imapc, because you can't do this.
Timo Sirainen [Wed, 23 Nov 2016 16:43:17 +0000 (18:43 +0200)]
lib-storage: Fix rotation of dovecot.list.index.log
After b9da8540e665138b3cad0b637c08c0ab7d7a7eeb the tail offsets weren't
being updated anymore when mail_index_sync_next() wasn't used to skip
over all the data. Mailbox list index wasn't doing this, and so the log
was never rotated since tail_offset was never equal to head_offset.
Timo Sirainen [Wed, 23 Nov 2016 15:14:48 +0000 (17:14 +0200)]
imapc: Fix assert that checks if mail is expunged locally.
The EXPUNGE may have been sent while imapc_sync_index() was issuing
remote imapc commands. It would end up being in delayed_expunged_uids,
so the assert needs to check that too.
Timo Sirainen [Wed, 23 Nov 2016 11:25:54 +0000 (13:25 +0200)]
sdbox: Don't log an error if stub is added twice
There's no locking for them, so it's fine if two processes add the same
mail. The second one could be ignored, but it was a bit easier to just
let it rename over the first one.
Timo Sirainen [Tue, 22 Nov 2016 14:35:58 +0000 (16:35 +0200)]
lib-fts: Make sure address tokenizer can't return empty tokens.
This happened when address was a token that first looked like it could be
a valid address, but then got truncated due to reaching maxlen, followed
by truncating the UTF8-sequence and finally all the rest of the '-' or
'.' chars that were valid at the beginning of the address are stripped
away by fts_tokenizer_delete_trailing_invalid_char(), leaving nothing left.
Timo Sirainen [Tue, 22 Nov 2016 10:03:01 +0000 (12:03 +0200)]
lib-index: Handle invalid headers as "corruption", not "temporary error"
This is especially required for "Header's corrupted flag is set" error,
which won't get fixed otherwise.
It's a bit more questionable if we should treat major version or CPU
architecture change as corruption, but it's possible those only exist
because of corruption. It's also very unlikely that either is really
happening. Ideally there would be a hash that verifies whether the
header is corrupted or not.
Timo Sirainen [Fri, 18 Nov 2016 14:03:00 +0000 (16:03 +0200)]
imap: Fix recent flags importing when un-hibernating
The initial RECENT counter that was sent didn't include pre-hibernation
\Recent flags.
\Recent flags were also added for mails that were already expunged, which
could have caused recent counter to be wrong later on, and possibly
assert-crash with:
process A: .log is opened with seq=1
process B: Rotates the .log and writes a new dovecot.index with
log_file_seq=2
process A: dovecot.index is opened. mail_transaction_log_view_set() now
wants to file log_file_seq=2 with mail_transaction_log_find_file(), but
because open_count==0, the .log isn't refreshed.
Timo Sirainen [Tue, 15 Nov 2016 16:39:08 +0000 (18:39 +0200)]
lib: Add connection.allow_empty_args_input
This simplifies input_args() callbacks since they don't always have to check
for args[0] == NULL. This is enabled by default, because none of the current
users want it and it's somewhat unlikely there even will be those in future.
Timo Sirainen [Thu, 17 Nov 2016 23:23:13 +0000 (01:23 +0200)]
lib-index: Fix detecting whether caller synced everything in mailbox.
When mailbox_index_sync_begin() was followed by _commit(), without _next()s
in the middle actually syncing the mailbox, the tail_offset was updated to
indicate that the mailbox was fully synced. Existing code didn't rely on
this, so it probably didn't break anything.
This code hasn't worked for a long time, because log_view is always read
fully to the end in _sync_begin().
Without this, it is not possible to instantiate multiple imapc storages.
Any attempts to will result in multiple namespaces sharing the same storage,
regardless of if that was the intention.
This can be called multiple times before mail_index_transaction_finish().
It's going to perform all the work of reordering mails and dropping
unnecessary changes that can be done before changing sequences to UIDs.
This will be needed for the following patch that implements
mail_index_transaction_get_highest_modseq().
Paul Howarth [Mon, 31 Oct 2016 10:49:38 +0000 (10:49 +0000)]
configure: Fix build with old OpenSSL without SSL_clear_options
SSL_clear_options was introduced in OpenSSL 0.9.8m but may be
backported to older versions in "enterprise" OS releases, so a version
check is insufficient here.
It was originally implemented as a macro but is a function in more
recent OpenSSL versions, so a test that works for both cases is needed.
This allows backends that are adding lost mailboxes to mailbox list index to
indicate that they don't actually know the name of the mailbox, and the
mailbox list index should try to figure it out and rename the mailbox to its
proper name.
Timo Sirainen [Wed, 16 Nov 2016 01:06:31 +0000 (03:06 +0200)]
LAYOUT=index: Don't write corrupted mailbox names to box-name header.
This way when opening a mailbox the box-name header isn't overwritten by
a corrupted name.
Keep track of the corrupted names with MAILBOX_LIST_INDEX_FLAG_CORRUPTED_NAME
flag in list index records. The flag isn't removed until the mailbox is
renamed.
Timo Sirainen [Tue, 15 Nov 2016 23:09:57 +0000 (01:09 +0200)]
lib-storage: Prevent renaming mailbox under itself.
This resulted earlier in a loop, which broke the mailbox index.
Note that IMAP already prevented this, so it could only be triggered by
other tools, like doveadm.