Timo Sirainen [Sat, 30 Apr 2016 11:55:14 +0000 (14:55 +0300)]
lib-storage: Clear list error before mailbox_list_get_hierarchy_sep()
With ACL plugin enabled the call could have triggered dovecot-acl-list
rebuild, which in turn could have set list errors if it didn't have
permissions to all the mailboxes. This caused IMAP logins to fail.
Timo Sirainen [Sat, 30 Apr 2016 11:19:02 +0000 (14:19 +0300)]
lib-mail: message-parser assert-crashfix
Crashes when multipart MIME header is missing end-of-headers line and the
boundary begins with the same prefix as one of the parent boundaries.
Broken by 7a12331c6
lib-storage: write subscription file in version 2 format
Write subscriptions file in a format that only v2.2.17 or newer can read, so
after dovecot converts the files to the new format, downgrading to a version
older than v2.2.17 is not supported.
Timo Sirainen [Thu, 28 Apr 2016 19:33:14 +0000 (22:33 +0300)]
lib: Set timestamp part more accurately in guid_128_generate()
Previously a long-running process would keep the timestamp close to its
original start time. This doesn't really matter as long as GUIDs are treated
opaque, but some pieces of code prefer to try to use the timestamp fields
since they're already there. This makes such code work more nicely.
Timo Sirainen [Fri, 29 Apr 2016 16:25:52 +0000 (19:25 +0300)]
quota: Added quota_over_flag_lazy_check flag.
By default the quota_over_flag is checked immediately at startup. With this
option the check is done only at a time when the quota is anyway being read.
Timo Sirainen [Fri, 29 Apr 2016 12:50:06 +0000 (15:50 +0300)]
global: Use buffer_get_writable_size() where possible
With 09539f3db increasing buffer's init_size with +1 some fts-icu unit tests
started failing. And in general it's better to use the writable size since
that provides the true size that can be used.
Timo Sirainen [Fri, 29 Apr 2016 12:42:48 +0000 (15:42 +0300)]
quota: Optimize handling a large number of expunges.
This assumes that the mail_expunge() was called in the same order as
sync_notify(), which practically means that they were both done in
ascending uid order. This is usually true.
Timo Sirainen [Fri, 29 Apr 2016 11:07:05 +0000 (14:07 +0300)]
lib-index: Use a bit larger initial records buffer size
For example with a mailbox having 160k messages the buffer size is around
10MB. Adding just 1% more space to it allows a lot more appends before the
buffer needs to be realloced. This reduces CPU usage quite a lot.
Timo Sirainen [Fri, 29 Apr 2016 09:55:52 +0000 (12:55 +0300)]
lib: Use p_malloc() explicitly in first buffer_alloc()
Although there is now code in p_realloc() that it should be just as
efficient, this makes profiling somewhat nicer since it can better
distinguish between actual reallocs and initial allocs.
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 [Mon, 25 Apr 2016 09:07:25 +0000 (12:07 +0300)]
imapc: Fixed crash caused by pool_unref() API change.
Calling pool_unref() set the mail_private->pool=NULL, which crashed in
index_mail_free(). Fixed this by removing the unnecessary ref/unref
entirely. We're already waiting in imapc_mail_close() for all the
existing FETCHes to finish, so the callback will always have only
valid mails with valid pools.
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 [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.
Lennart Weller [Tue, 22 Mar 2016 14:24:22 +0000 (10:24 -0400)]
Support multiple recipient_delimiters
The recipient_delimiter is treated as multiple one-character delimiters
rather than one multi-character delimiter if more than one character is
supplied. The address is split on the first character in
recipient_delimiter found.