Stephan Bosch [Fri, 18 May 2018 08:24:46 +0000 (10:24 +0200)]
lib-smtp: client: Fix assertion panic occurring when DATA dot stream cannot be finished immediately.
If o_stream_finish() returns 0, o_stream_send_istream() would be called again
later which causes the panic. Instead, it should only call o_stream_finish() or
o_stream_flush() again to finish the last bit of the output.
Panic was:
Panic: file ostream.c: line 394 (o_stream_send_istream): assertion failed: (!_outstream->finished)
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.
lib-storage: Return correct root path for PATH_TYPE_ALT_MAILBOX
mailbox_list_set_get_root_path(..., MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX, ...)
must return one of three values:
1. if there is no alt storage, return NULL
2. if there is alt storage and MAILBOXDIR is set,
return ${alt_dir}/${mailbox_dir_name}
3. if there is alt storage but MAILBOXDIR is not set, return ${alt_dir}
Case number 3 was broken, and it mistakenly returned ${root_dir} - in other
words, it behaved as MAILBOX_LIST_PATH_TYPE_MAILBOX.
This correction changes the behavior, but this shouldn't cause
incompatibilities since:
1. it affects only storages that support alternate storage
2. it affects only configurations that use empty MAILBOXDIR
The only storage that supports alternate storage setting is dbox but dbox
defaults to MAILBOXDIR=mailboxes. Additionally, it appears to be impossible
to override it to an empty string (setting it to an empty strings causes
dbox to override it with the default - "mailboxes"). Therefore, nobody
should be affected by this change.
Stephan Bosch [Mon, 14 May 2018 21:56:21 +0000 (23:56 +0200)]
lmtp: Fix segfault occurring when a user turns out to be over quota at DATA transfer.
The LMTP recipient context was not updated with the final recipient address when
the RCPT command was accepted. This left a dangling struct smtp_address pointer
which triggered the segfault when used.
Stephan Bosch [Wed, 4 Apr 2018 22:34:49 +0000 (00:34 +0200)]
lib-smtp: server: Fix error message logged for errors occurring in data wrapper stream during DATA transfer.
Used the connection stream rather than the data stream to obtain the error.
Obviously, there is no error on the low-level connection when there is a data
istream (e.g. message size) error.
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 [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.
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 [Tue, 20 Mar 2018 17:14:39 +0000 (18:14 +0100)]
lib-http: server: Properly handle corrupt payload while finishing a request.
The HTTP_REQUEST_PARSE_ERROR_BROKEN_REQUEST was not handled, causing an
assertion panic. This situation occurred when the chunked transfer encoding was
invalid.
Timo Sirainen [Thu, 26 Apr 2018 18:07:31 +0000 (21:07 +0300)]
cassandra: Add proper log levels to logged messages
If logging to "internal handler", i.e. to log process, write the log prefix
that includes the log level. This way Cassandra's trace/debug/info messages
won't end up in error log.
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.
Phil Carmody [Thu, 11 Jan 2018 13:35:42 +0000 (15:35 +0200)]
global - migrate more complicated strncmp expressions to str_begins
Simplify a bunch of verbose var=strlen(); strncmp(,,var) calls.
Fortunately, all of these examples use the length variable, so no
"unused value" warnings occur.
Phil Carmody [Thu, 2 Feb 2017 12:27:58 +0000 (14:27 +0200)]
lib: strfuncs - string match length and prefix checking helpers
strncmp(input, "literal", 7) is an idiom used everywhere, but leaves
room for human error in calculating the length.
strncmp(input, "literal", strlen("literal")) is an idiom also used
everywhere, but is both verbose and might be inefficient on some
legacy or ultralightweight compilers.
The old techniques are presumed to be optimal code-wise, but are
verbose (and, containing redundancy, they leave room for human error),
so make the macro fall back onto this operation, simply avoiding the
redundancy/verbosity.
The macro expansion does not multiply evaluate any of its parameters,
so should be safe even in the strangest of situations.
Timo Sirainen [Wed, 25 Apr 2018 11:19:27 +0000 (14:19 +0300)]
lib-mail: Remove MESSAGE_HEADER_REPLACE_NULS_WITH_0x80 flag
As mentioned in previous commit, 0x80 isn't valid UTF-8 and we shouldn't
encourage using it. This implementation also can't be easily changed to
use unicode replacement character without larger changes to istream-nonuls.
Timo Sirainen [Wed, 25 Apr 2018 11:17:34 +0000 (14:17 +0300)]
lib-mail: Change NUL -> 0x80 replacement to use unicode replacement char instead
Using 0x80 produces invalid UTF-8 output, which we should avoid. Some places
in Dovecot code already requires that input is valid UTF-8, so it's also
safer and easier to use the unicode replacement character.