Timo Sirainen [Tue, 15 Jan 2019 23:00:22 +0000 (01:00 +0200)]
LAYOUT=index: Fix rebuilding mailbox list index on force-resync
The if-check was a bit confusing because have_backend==TRUE means that there
the mailbox list index is only an index, while have_backend==FALSE means
that the mailbox list index is the only source for the list of mailboxes
(= list index is the backend).
Timo Sirainen [Tue, 2 Oct 2018 07:22:11 +0000 (10:22 +0300)]
lib-master: ipc-client: Don't free command too early
When multiple replies were received by IPC only the final reply should free
the command. This may have caused e.g. "doveadm proxy list" to crash.
Broken by 435f0545b200767c25a5daee17cd6b4998d03710
Timo Sirainen [Wed, 25 Jul 2018 10:17:45 +0000 (13:17 +0300)]
lib-storage: Fix bodystructure parsing crash if header is parsed twice
The second parsing will recreate the parser_ctx, discarding the old parsed
message_part.data for the header. On the second parsing
save_bodystructure_header=FALSE so the message_part.data isn't filled for
the header. Later on the bodystructure parsing assumes the data is set,
and crashes.
This only happened with mail_attachment_detection_options=add-flags-on-save
and Sieve script that first accessed a non-cached header and then used the
"body" extension.
Fixes segfault and also:
Panic: file imap-bodystructure.c: line 116 (part_write_body_multipart): assertion failed: (part->data != NULL)
Timo Sirainen [Tue, 24 Jul 2018 12:00:19 +0000 (15:00 +0300)]
lib-imap: Remove content_subtype==NULL checks
This can never happen after the previous commit. This also changes the
BODYSTRUCTURE output for invalid Content-Types, but since they're invalid
anyway it doesn't really matter what the output is.
Timo Sirainen [Tue, 5 Jun 2018 10:25:30 +0000 (13:25 +0300)]
lib: Add i_stream_nonseekable_try_seek()
This can be used by istreams to more easily implement seeking backwards when
it has to be done by first seeking back to offset 0 and reading from there.
Timo Sirainen [Wed, 15 Nov 2017 13:53:03 +0000 (15:53 +0200)]
lib-imap: imap_envelope_parse() - remove unnecessary data stack frame
imap_envelope_parse_args() isn't using data stack at all, so this
unnecessarily complicates the code. It also prevents using datastack-pool
as the pool parameter.
Timo Sirainen [Fri, 13 Apr 2018 13:14:18 +0000 (16:14 +0300)]
lib-master: If connect() to backend UNIX socket is retried, log a warning
For example if imap-login process needs to retry before it successfully
connects to imap process's socket, a warning is logged. This warning is
important because it means that the imap-login process may have been
sleeping up to 0.5 seconds and causing all the other connections to hang
during it.
It would be better to make this retrying asynchronous, but before spending
time on doing that, lets see if this warning is ever even being logged.
Timo Sirainen [Thu, 3 May 2018 14:06:04 +0000 (17:06 +0300)]
cassandra: Use fallback_consistency on more types of errors
This could allow for example read_consistency=local-quorum with
read_fallback_consistency=quorum, so most of the time the reads are
from local datacenter, but in case it has problems you can switch to
other datacenters.
Timo Sirainen [Tue, 15 May 2018 14:50:27 +0000 (17:50 +0300)]
fs-posix: Strip trailing "/" from filenames
This is mainly because "doveadm fs delete -R" adds it to indicate to the
fs-driver that the whole directory is wanted to be deleted. This change
fixes fs-posix to work with NFS, where otherwise unlink("symlink-to-dir/")
fails with ENOTDIR. Without NFS the same call succeeds.
Timo Sirainen [Thu, 3 May 2018 12:22:09 +0000 (15:22 +0300)]
fs-posix: mkdir missing directory if it's changed by FS_METADATA_WRITE_FNAME
The temp file is created to the initial directory. If the directory is
changed by FS_METADATA_WRITE_FNAME, the new destination directory didn't
necessarily exist. If the link() or rename() fails with ENOENT, try to
mkdir the missing directories.
mdbox: Assume that empty uid maps found during sync are harmless
Instead of failing the sync and causing index rebuild, just skip over
the empty uid maps. Chances are that they these records came from
various plugins that create fake mails.
This was done to call extension record sync handlers, but the previous
commit removes them. Fixes a problem where obsolete cache offsets were
used in some situations:
- Some cache updates are from external transactions and some are from
non-external transactions. This is because cache offset updates are being
added by whatever the parent index transaction is.
- When mail_index_sync_map() is mapping MAIL_INDEX_SYNC_HANDLER_FILE, it
has already synced the map. But it's calling mail_index_sync_record()
for non-external transactions to call expunge handlers and extension
update handlers. It's calling the regular mail_index_sync_record() to do
this work.
- But mail_index_sync_record() is actually still updating the map. So now
mail_index_sync_record() is called for all non-external cache updates,
but not for external cache updates! And since these are somewhat
randomly either external or non-external, the end result is that the
cache offset may be obsolete.
Stephan Bosch [Sat, 14 Apr 2018 00:05:51 +0000 (02:05 +0200)]
lib: Implement str_sanitize_utf8().
Unlike str_sanitize(), this function truncates strings based on a UTF8 code point
limit rather than a maximum size in bytes. Also, the Unicode replacement
character is used to mark invalid/control characters and an ellipsis character
is used to indicate the string truncation. For the normal str_sanitize() this is
done using a question mark and triple dots respectively.
Timo Sirainen [Tue, 17 Apr 2018 12:46:41 +0000 (15:46 +0300)]
imapc: Fix expunges+appends in same session with imapc_features=no-msn-updates
Since the EXPUNGEs were ignored, the sequence numbers weren't updated.
When a new mail arrived, the sequence number sent by the remote IMAP server
pointed to existing mails in imapc's mapping. Fix this by changing the
sequence number if the returned UID is >= next_uid.
Timo Sirainen [Sun, 25 Mar 2018 20:15:58 +0000 (23:15 +0300)]
imapc: Fix local state if mailbox is empty after reconnection
If local indexes had more than 0 mails, but after reconnection the remote
IMAP server replied with "* 0 EXISTS", the mails in local index weren't
expunged. This could have resulted in: