Phil Carmody [Tue, 8 Sep 2015 16:28:31 +0000 (19:28 +0300)]
lib: test-strnum - do not invite undetectable errors
The very numbers which could cause a broken parser to over-run, the ones we
are testing, are the ones which will be parsed as having a value similar to
'value', so check that no value was returned by using a number completely
dissimilar to that. Otherwise, there might be an accidental mis-parse that
overwrote value, but left its value the same.
Timo Sirainen [Tue, 8 Sep 2015 16:12:26 +0000 (19:12 +0300)]
lib-storage: Replaced some unlink()s with i_unlink*()s where we could.
This changes some mail_storage_set_critical() calls to i_error()s, but
because these unlink() failures don't actually fail the operation it doesn't
matter.
Timo Sirainen [Tue, 8 Sep 2015 16:11:45 +0000 (19:11 +0300)]
lib-index: Replaced some unlink()s with i_unlink*()s where we could.
This changes some mail_index_set_error() calls to i_error()s, but because
these unlink() failures don't actually fail the operation it doesn't matter.
In fact it may be even better that it doesn't overwrite the existing
index->error if it exists.
Timo Sirainen [Tue, 8 Sep 2015 15:49:00 +0000 (18:49 +0300)]
lib: Added i_unlink() and i_unlink_if_exists()
These log the error message on a failed unlink(). They also include the
source code file and line number to make it easier to find which unlink()
actually failed if the path itself doesn't already clearly identify it.
This can be especially useful if the path is (null), "" or contains some
corrupted garbage.
Timo Sirainen [Tue, 8 Sep 2015 15:45:28 +0000 (18:45 +0300)]
lib-storage: Use MAIL_ERROR_NOTPOSSIBLE if mailbox_attribute_*set() fails for read-only attribute.
MAIL_ERROR_PARAMS indicates that there was something wrong with the
parameters itself. But the caller can't know (at least with current APIs)
if it's a read-only attribute it's trying to change before actually doing it.
Timo Sirainen [Tue, 8 Sep 2015 10:41:21 +0000 (13:41 +0300)]
lib-storage: If mail_attribute_dict is set, ignore non-authority rank internal attributes.
This way dsync can still sync things like Sieve scripts, but it doesn't
attempt to sync anything that actually requires dict.
Timo Sirainen [Tue, 8 Sep 2015 10:07:59 +0000 (13:07 +0300)]
lib-charset: Fixed assert-crash with some iconv() versions.
Older glibc iconv() versions seem to skip over invalid characters, at least
with some charsets, while newer versions don't. We were assuming that the
skipping never happened, so if the invalid character was at the end of the
string we could have wrapped size to (size_t)-1 and caused a crash later on.
Timo Sirainen [Mon, 7 Sep 2015 21:07:55 +0000 (00:07 +0300)]
lib-storage: Mailbox list notifications didn't work for INBOX.
Because of some earlier optimizations that changes to INBOX aren't written
to dovecot.list.index.log file.
Timo Sirainen [Mon, 7 Sep 2015 20:55:31 +0000 (23:55 +0300)]
Mailbox list notify API changed to return multiple events at once.
This fixes some issues where a single event could actually trigger multiple
different kinds of events.
lib: Fix hang in safe_sendfile on SmartOS
The call to sendfile on SmartOS can fail with EOPNOTSUPP. This is a valid
error code and documented in the man page. This error code needs to be
handled or else dovecot will retry the sendfile call endlessly and hang.
Timo Sirainen [Mon, 7 Sep 2015 19:14:18 +0000 (22:14 +0300)]
imap: Fixed assert-crash in NOTIFY when using multiple namespaces.
I'm not sure why the original code was trying to add it to multiple
namespaces. A single mailbox name should be matching only a single
namespace (visible one at least). In any case we can't use
mail_namespace_find() with only partial namespaces-list, because it'll
assert-crash if it can't find a namespace for the mailbox.
Timo Sirainen [Mon, 7 Sep 2015 17:24:25 +0000 (20:24 +0300)]
director: Added director_user_kick_delay setting.
This replaces the hardcoded 2 seconds delay. This setting specifies how long
to wait for after user has been kicked from all directors before letting the
user login to the new server. This timeout should be large enough that the
user's existing processes in the old backend should be finished.
Timo Sirainen [Mon, 7 Sep 2015 15:50:24 +0000 (18:50 +0300)]
login proxy: Added delayed disconnection of clients on server mass-disconnect.
login_proxy_max_disconnect_delay setting (default 0 = disabled) controls for
how long time period the disconnections are spread to. The idea behind this
is to avoid load spikes due to client reconnections when a backend server
dies or is restarted.
Timo Sirainen [Mon, 7 Sep 2015 13:23:40 +0000 (16:23 +0300)]
lib-storage: Allow MAIL_ATTRIBUTE_INTERNAL_RANK_DEFAULT to use get=NULL
This is useful for registering internal attributes whose only purpose is to
be able to set/get them via dict. (Because normally the dict access would be
denied completely.)
Timo Sirainen [Mon, 7 Sep 2015 13:22:11 +0000 (16:22 +0300)]
lib-storage: Allow set/get for Dovecot-private attributes via internal attributes.
This allows registering attributes with MAILBOX_ATTRIBUTE_PREFIX_DOVECOT_PVT
prefix and having them be get/set via dict, instead of failing them.
Timo Sirainen [Mon, 7 Sep 2015 13:38:24 +0000 (16:38 +0300)]
lib-storage: Added MAIL_ATTRIBUTE_INTERNAL_FLAG_CHILDREN
This also adds the key to get() and set() functions, so they can know
exactly what key is wanted to be accessed.
Timo Sirainen [Mon, 7 Sep 2015 11:08:52 +0000 (14:08 +0300)]
auth: Fixed passdb skip_password_check / result_success=continue-fail handling
If passdb returned success, but result_success=continue-fail, it means that
the authentication didn't succeed. So we still want to check the password
again and in general treat the request as unauthenticated (especially for
the passdb { skip } setting).
So the current logic means that there are 2 ways for the request to be
treated as authenticated and skipping any password checking:
1) passdb lookup succeeding, with result_success=continue, continue-ok,
return or return-ok
2) passdb lookup not succeeding, with result_failure=continue-ok or
return-ok
It's a bit questionable though if 2) should be allowed.
Timo Sirainen [Thu, 3 Sep 2015 18:37:09 +0000 (21:37 +0300)]
cassandra: Handle async queries internally - don't use sql pooling code.
There's no need to create multiple Cassandra instances, since the single
instance is capable of doing multiple asynchronous requests in parallel.
Timo Sirainen [Thu, 3 Sep 2015 17:55:18 +0000 (20:55 +0300)]
lib-storage: Another fix to using index_storage_mailbox_close() without an opened view.
Calling mail_index_close() without mail_index_open() caused it to
assert-crash.
Timo Sirainen [Thu, 3 Sep 2015 11:10:36 +0000 (14:10 +0300)]
Removed SET_IN_PORT_ZERO - SET_IN_PORT now always allows zeros as well.
A zero in all the port settings means that the port is disabled, which is
also the default. So it shouldn't be an error to explicitly set it to zero
in the config file.
Phil Carmody [Thu, 3 Sep 2015 11:01:57 +0000 (14:01 +0300)]
lib: strnum - simplify hex and oct overflow code
uintmax_t is defined to have modulo-2^n semantics, and therefore the bottom
bits of (uintmax_t) are guaranteed to be all set. Therefore the checking of
the next character read is unnecessary, as it's already done in the loop
control statement itself. (This is not true about the bottom digit base 10,
which is why the check remains in the decimal case)
Timo Sirainen [Wed, 2 Sep 2015 14:36:47 +0000 (17:36 +0300)]
dict: Use the new async APIs for everything.
If the dict backend supports async operations, this means that dict service
can now be configured with client_count>1.
Timo Sirainen [Wed, 2 Sep 2015 14:20:02 +0000 (17:20 +0300)]
lib-sql: Mark Cassandra driver as pooled.
Otherwise all the asynchronous operations will assert-crash, since all the
auto-connecting code is in the sqlpool code.
Timo Sirainen [Wed, 2 Sep 2015 14:19:08 +0000 (17:19 +0300)]
lib-sql: Debugging help - Added assert before clearing sql_result.callback.
If result is unrefed too many times, this still allows accessing the
callback from a debugger.
Timo Sirainen [Tue, 1 Sep 2015 13:25:11 +0000 (16:25 +0300)]
lib-imap-client: If connect() fails immediately, log an error and retry the next IP.
Only if all IPs fail return a full failure. This is mainly intended to skip
IPv6 addresses when IPv6 connectivity doesn't work.
Timo Sirainen [Mon, 31 Aug 2015 21:11:37 +0000 (00:11 +0300)]
auth: Added ":protected" suffix to passdb and userdb field names.
This means that if the field is set only if it hasn't already been set.
Usually an earlier passdb/userdb would have set the field and this is
setting a default (e.g. per-user settings override per-domain settings).
Teemu Huovila [Mon, 31 Aug 2015 10:33:26 +0000 (13:33 +0300)]
lib-fts: Add prefixing contraction filter.
Filters away prefixing contracted words, e.g. "l'homme" -> "homme".
Tokens to be filtered must be lower case. Only supports French in
this initial version.