Timo Sirainen [Mon, 25 Apr 2016 13:58:30 +0000 (16:58 +0300)]
lib-mail: More fixes to istream-header-filter with large input.
Don't assume that when reading the header the second time we'll get exactly
the same header blocks as the first time.
This commit also prevents the filter callback from switching the
matching-decision on non-first header line. This shouldn't be needed and it
could just cause confusion. (It also made it a bit easier to implement this
fix.)
Timo Sirainen [Mon, 25 Apr 2016 13:34:59 +0000 (16:34 +0300)]
lib-mail: Improved istream-header-filter unit test.
Existing code already assumes that the callback is called for all the header
data. So it's not used just for filtering headers but also parsing the
header contents. Make this assumption now explicit as a unit test.
Timo Sirainen [Mon, 25 Apr 2016 11:38:35 +0000 (14:38 +0300)]
dsync: If state is invalid, exit with code 2 instead of tempfail.
We'll have dsync_mailbox_import_*() just return success to everything until
_deinit() is called. The _deinit() will return a failure and set "resync
needed"-flag, which caller will know how to handle.
Timo Sirainen [Fri, 15 Apr 2016 13:12:44 +0000 (16:12 +0300)]
lib-storage: Don't use same session ID for multiple mail_storage_service_next() calls.
dsync does multiple mail_storage_service_next() calls for the same
mail_storage_service_user. This causes stats plugin to send the same
session ID to stats process, which complains about duplicates. Solved this
in a generic way by having the following mail_storage_service_next() calls
append :counter to session ID.
Timo Sirainen [Thu, 21 Apr 2016 15:51:57 +0000 (18:51 +0300)]
Split parts of lib-dict into lib-dict-extra.
Otherwise there's a circular dependency because lib-dict/dict-fs.c depends
on lib-fs, while lib-fs/fs-dict.c depends on lib-dict. This becomes a problem
when compiling --without-shared-libs, although for some reason it works for
me while linking the Dovecot core, but not when linking external plugins.
If inner MIME part had the same --boundary prefix as its parent(s) and
the MIME part body started with the inner --boundary prefix, we didn't yet
have it in the list of valid boundaries, so we thought that the outer
boundary was found and the MIME headers were truncated. But due to an extra
bug we still treated it as if it were the inner boundary, except the MIME
part sizes/offsets were set wrong.
This for example fixes a situation where FETCH [1.2.MIME] returns an extra
newline before the actual headers.
Timo Sirainen [Fri, 22 Apr 2016 13:28:56 +0000 (16:28 +0300)]
dsync: Determine better when rename-algorithm might have gotten stuck.
A hardcoded value of 100 isn't necessarily enough if there are a lot of
mailboxes with a lot of renames. Base the max count on the total number
of mailboxes on both local and remote. And just in case multiple it by 3.
Probably smaller number would be fine too.
Timo Sirainen [Wed, 20 Apr 2016 20:01:45 +0000 (23:01 +0300)]
lib: var_expand() now expands %{nonexistent} to UNSUPPORTED_VARIABLE_nonexistent
Earlier it was expanded to "nonexistent}", which looked more like a bug.
This change hopefully makes it clear enough to understand when a variable isn't
supported.
Timo Sirainen [Tue, 19 Apr 2016 13:55:02 +0000 (16:55 +0300)]
lib-http: Include information about number of request attempts and its timing in response reason.
Because the reason is usually logged as part of the error string, this
causes all of the error messages to include the attempts count and how long
the requests took in total. This should make it easier to understand problems
in error logs.
http_client_request_set_preserve_exact_reason() can be used to disable
modifying the reason string. This may also apply to other reason
modifications that may be done in the future.
Timo Sirainen [Thu, 21 Apr 2016 21:21:12 +0000 (00:21 +0300)]
imapc: Added support for imapc_features=modseq
If the remote server supports CONDSTORE or QRESYNC extensions we'll use the
remote's MODSEQ and HIGHESTMODSEQ counts.
There are some situations where the HIGHESTMODSEQ isn't updated exactly
correctly on an open mailbox, so this feature shouldn't be fully relied on.
It was primarily implemented for dsync+imapc support - both for preserving
modseqs and also for HIGHESTMODSEQ lookups.
Timo Sirainen [Fri, 22 Apr 2016 17:10:34 +0000 (20:10 +0300)]
lib: Improved istream-timeout error message.
We're supposed to check that timeout isn't triggered after a long-running
code, but it's not perfect. So provide the actual timing information we
saw instead of the expected timeout.
Stephan Bosch [Fri, 15 Apr 2016 21:59:24 +0000 (23:59 +0200)]
lib-http: client: Implemented means to set request payload buffer rather than an input stream.
This is not purely a convenience function: there have been bugs caused by allocating a data input stream from a datastack buffer.
With this function, the buffer is copied to the request pool, so that it is durably allocated while the request exists.
This prevents futher mishaps. The server already has an equivalent function for its response object.
Timo Sirainen [Tue, 19 Apr 2016 21:29:49 +0000 (00:29 +0300)]
lib-index: Fixed calling mail_cache_open_and_verify() on an already open cache.
This was done at least by index_index_rebuild_init().
Either the currently open cache->fd was leaked, or if the cache file open()
failed we left the cache in an inconsistent state where cache->fd == -1, but
cache->hdr != NULL, so it caused MAIL_CACHE_IS_UNUSABLE() to also be TRUE. This
could have ended up in an assert:
Panic: file mail-index-lock.c: line 31 (mail_index_lock_fd): assertion failed: (MAIL_INDEX_IS_IN_MEMORY(index))
If this is explicitly set to yes or no, it overrides the global auth_verbose
setting. However, auth_debug=yes overrides all of the auth_verbose settings.
Timo Sirainen [Fri, 15 Apr 2016 12:01:20 +0000 (15:01 +0300)]
lib-stats: Handle better write() to stats process failing with EAGAIN
It only means that the stats process is too busy and the FIFO is filled up.
Retrying the write later should work. We also don't want to log too much about
the same warning, so do it only once per 30 seconds.
Timo Sirainen [Wed, 6 Apr 2016 11:09:13 +0000 (14:09 +0300)]
imapc: Fixed checking of whether same IMAP command keeps crashing server.
reconnect_command_count was counting only the post-login commands, but we
were decreasing it also for pre-login commands. This caused it to shrink to
0 too early.
Timo Sirainen [Wed, 6 Apr 2016 10:52:24 +0000 (13:52 +0300)]
lib-storage: Fixed error handling for mailbox_list_iter_init_namespaces()
If iteration for the first namespace failed, we tried to copy the error
string to error_list, which was the same first namespace's list. This caused
the error string to be freed while it was being copied, so the end result
was that the error became either an empty or garbage string.
Timo Sirainen [Tue, 5 Apr 2016 17:10:53 +0000 (20:10 +0300)]
lib-storage: Changed separator between session_id_prefix and unique part to be ':'
Although '-' wasn't used by default either, it's much more likely that
custom session IDs might contain it. ':' is hopefully less likely to be used.
This allows log parsers that actually want to find out the original session's
all log lines to cut out everything after the initial ':'.
Timo Sirainen [Wed, 6 Apr 2016 19:43:52 +0000 (22:43 +0300)]
lmtp: Changed default LMTP proxy timeout to 125 seconds.
The main problem with LMTP proxy timing out too early is that it causes
duplicates if the backend actually finishes the mail delivery.
The 30 seconds is bad, because there are various timeouts in backend set
to 30 seconds also. 125 seconds is hopefully large enough to hit most of
the 2 minute timeouts and we'll have a few extra seconds left to see the
failure.
Just ignore the -R parameter for doveadm sync, unless -1 parameter is also
used. Alternatively we could also fail the command, but maybe that's
unnecessary extra work.