Timo Sirainen [Fri, 5 May 2017 12:20:05 +0000 (15:20 +0300)]
lib-storage: Avoid unnecessary UIDNEXT lookups after saving a mail
The vsize checking code was expecting that this would always be a cheap
operation, but with imapc code it could trigger a remote STATUS (UIDNEXT)
call. Do this only when we've checked that this mailbox is updating vsize
header at all.
Timo Sirainen [Fri, 12 May 2017 12:42:31 +0000 (15:42 +0300)]
imapc-quota: Avoid sending unnecessarily many GETQUOTA[ROOT] commands
The last_refresh == ioloop_timeval check didn't work, because the refresh
itself updated ioloop_timeval. This caused a single quota lookup to issue
multiple GETQUOTA[ROOT] commands to imapc.
Timo Sirainen [Tue, 2 May 2017 09:18:40 +0000 (12:18 +0300)]
lib-imap: imap_append_string_for_humans() - Change CR/LF to space
Practically this shouldn't matter, because in email headers a CR/LF is
always followed by a space/tab. But maybe this can be used for some
other purposes in future, and it makes the unit tests clearer. :)
Timo Sirainen [Tue, 2 May 2017 15:40:43 +0000 (18:40 +0300)]
master: Send SIGQUIT to processes running at deinit to close socket listeners.
This allows Dovecot to be restarted even when some lmtp/doveadm process is
running for a long time. Otherwise it would keep the inet_listener socket
open and prevent the new Dovecot from binding to the port.
Aki Tuomi [Fri, 28 Apr 2017 09:51:20 +0000 (12:51 +0300)]
auth: Add username_filter for passdb block
username_filter lets you specify one or more pattern(s) for
including or excluding users. exclusion patterns are denoted
with ! prefix.
if any exclude matches the username, passdb will be skipped.
if any inclusions is specified, and the username does not match
one of them, passdb will be skipped.
Just write the original invalid keyword string as output. It might not be
entirely invalid - just invalid within this mailbox (e.g. a mailbox doesn't
allow new keywords).
Timo Sirainen [Thu, 27 Apr 2017 09:50:13 +0000 (12:50 +0300)]
lib-index: mail_index_update_keywords() - don't assert if adding/removing 0 keywords
Although it would be nice for the caller to check it, it's easier to do
here. It's mainly a problem with mailbox_keywords_create_valid() that may
unexpectedly create empty keywords.
Phil Carmody [Wed, 3 Feb 2016 16:34:13 +0000 (18:34 +0200)]
lib: bits - new fractional log-like helper
For stats gathering, where the data can have a wide range of values, you
don't necessarily need the same granularity along the full range of values.
For example, 1ms and 11ms latencies are very different, but 1.001s and
1.011s latencies are not worth distinguishing. Something logarithmic seems
more apt. Simply looking at power-of-2 sized bands (e.g. doing log2(n)),
however, is too granular, so these new helpers let you specify how fine
to (linearly) subdivide each of those bands. 1 fractional bit splits
each power of 2 band into 2 halves. 2 fractional bits splits each power
of 2 band into 4 quarters, and so on. 0 fractional bits is just log2().
Exact identification of percentiles is impossible, but it was anyway, as you
simply cannot store all the data required to calculate them. However, a mere
896 buckets will permit you to have 32 bands per power of 2, 5 fracional bits.
The above example would have buckets such as 2.432s-2.496s, and 55.3s-56.3s.
Assuming smooth distribution lets you calculate percentiles more accurately,
just assume within each bucket is a trapezial distribution. This holds even
if the distribution is multi-modal, which it will be. However, maths required.
Timo Sirainen [Mon, 24 Apr 2017 14:59:53 +0000 (17:59 +0300)]
quota: Add imapc backend
This allows using imapc storage with imapc quota. The quota acts as
read-only, so it's used only when the current quota usage is explicitly
asked.
The quota can be looked up using either a mailbox name or quota root name.
By default INBOX's quota is looked up. If there are multiple quota roots
returned for the mailbox, only the first quota root returned by the
QUOTAROOT reply is used.
This avoids index_mail_update_access_parts_pre() from opening the mail
stream unnecessarily for fields that can be looked up via other methods
by the storage.
Timo Sirainen [Fri, 21 Apr 2017 09:54:17 +0000 (12:54 +0300)]
cassandra: Use fallback consistency for CASS_ERROR_LIB_NO_HOSTS_AVAILABLE errors
I'm not entirely sure if this is always appropriate, but at least this error
happens every time when attempting to use write_consistency=two when there
is only a single Cassandra node.
This needs to be done in a bit more complicated way because multiple
SEARCH_FLAGS parameters are wanted to be merged together using a single
shared value.flags. Move this merging last after all the deduplication is
done.
Timo Sirainen [Tue, 11 Apr 2017 12:33:22 +0000 (15:33 +0300)]
auth: Use mem_equals_timing_safe() for all password hash comparisons.
It's unlikely these could be used to perform timing attacks, since the
attacker would have to have broken MD5/SHA badly enough to be able to
quickly generate string that result in wanted hashes. Still, the extra
cost is almost nothing and it's always better to be super paranoid!
Stephan Bosch [Tue, 11 Apr 2017 07:34:11 +0000 (09:34 +0200)]
lib-imap: imap-bodystructure: Fixed handling of a multipart part without children in imap_bodystructure_parse().
In imap_bodystructure_write(), an empty multipart part is addressed by generating an empty text/plain part.
However, when parsing that back with imap_bodystructure_parse() against a parsed message_part tree, this case needs to be considered explicitly.
Otherwise, it will not be able to match the message part hierarchies.
This adds a test suite item that tests both the write (previous commit) and parse functions.
Stephan Bosch [Wed, 12 Apr 2017 08:13:15 +0000 (10:13 +0200)]
lib-imap: imap-bodystructure: Fixed handling of a multipart part without children in imap_bodystructure_write().
In that case it writes an empty text/plain part to prevent generating an invalid BODYSTRUCURE.
However, it always generated the basic BODY version without the extra fields for a full BODYSTRUCTURE.