Phil Carmody [Fri, 14 Nov 2014 22:06:09 +0000 (00:06 +0200)]
lib: array/hash - protect macro parameters
If a pointer parameter p is ``ptr + offset'', then sizeof(*p) becomes
sizeof(*ptr + offset), which isn't what was wanted. sizeof(*(p)) is the
safe expression to use instead. Ditto for just ``*data'' in array.h.
The macros in hash.h which have been changed have been reindented for
better readability and consistency.
The bracketting of elem in (elem)++ in both of the array_foreach* macros
isn't actually useful, as elem participates in token-pasting elsewhere.
However, the two macros have been made more similar to each other for
better parallelism.
Timo Sirainen [Fri, 14 Nov 2014 08:59:57 +0000 (00:59 -0800)]
imap: namespace { order } parameter now specifies the order returned in NAMESPACE reply.
This is relevant only if there are multiple visible namespaces with the same
type. The default order depends primarily on the length of the prefix because
of internal sorting (the order of equal length prefixes can't really be
relied on).
Timo Sirainen [Thu, 13 Nov 2014 09:29:41 +0000 (11:29 +0200)]
lib-index: Make sure dovecot.index.cache parsing doesn't go to infinite loop.
Although we guarantee this only for files generated with Dovecot v2.2+
because it's too much trouble to check for older versions.
Timo Sirainen [Thu, 13 Nov 2014 08:57:07 +0000 (10:57 +0200)]
lib-storage: Fixed crash if mail_namespaces_init_add() failed due to invalid settings.
Normally the invalid settings were caught by config process already.
Timo Sirainen [Thu, 13 Nov 2014 08:09:28 +0000 (10:09 +0200)]
lib: ostream.stream_errno is now exactly the same as last_failed_errno.
There's a lot of code that checks only for stream_errno instead of
last_failed_errno at the flush time where the stream_errno might have
already been cleared.
I'm not sure why these were separated in the first place. I don't think
there are any stream errors which just correctly go away by retrying the
operation. Perhaps some code could have attempted seeking and try to handle
the ESPIPE error, but that kind of code paths are rare and they could clear
the errors themselves if needed.
Timo Sirainen [Thu, 13 Nov 2014 08:01:37 +0000 (10:01 +0200)]
lib: ostream-file checks "sendfile() not supported" a bit better.
There are other reasons why stream_errno=EINVAL could have been set, at
least in theory.
Timo Sirainen [Thu, 13 Nov 2014 07:53:35 +0000 (09:53 +0200)]
lib-storage: Added "creator" for mail_user.
This allows fixing stats plugin to update stats also for shared mailboxes.
That's a bit complicated change though, so I'm not sure how soon it'll
happen. But at least this change makes it possible more easily later on.
Might have other uses too.
Timo Sirainen [Thu, 13 Nov 2014 07:39:24 +0000 (09:39 +0200)]
lib: Never implicitly clear istream's stream_errno.
I'm not really sure why these were added in the first place. At some point
the stream_errno was cleared in more places, such as just before reading,
but those were also removed already. I don't see any benefit for these, just
potential problems.
Timo Sirainen [Thu, 13 Nov 2014 07:35:59 +0000 (09:35 +0200)]
lib-mail: message_search_msg() shouldn't clear istream's stream_errno.
If the input stream failed, retrying the operation without cached
message_parts is unlikely to help. This also loses the original error
message.
Timo Sirainen [Thu, 13 Nov 2014 07:12:38 +0000 (09:12 +0200)]
dsync: Set MAILBOX_TRANSACTION_FLAG_SYNC also for exporter.
This doesn't really do much because exporter shouldn't be writing anything,
but it allows plugins to find out if transactions is coming from dsync.
Timo Sirainen [Thu, 13 Nov 2014 01:58:51 +0000 (03:58 +0200)]
lmtp: Added support for DSN ORCPT parameter.
If the parameter is specified, it's used as the original recipient address
in Sieve. The ORCPT parameter is also proxied to destination LMTP server if
used (without checking if it supports it). We don't currently advertise DSN
extension, so this feature won't be enabled automatically.
Timo Sirainen [Thu, 13 Nov 2014 00:28:46 +0000 (02:28 +0200)]
stats: Use the new str-table API to reduce memory usage for service strings.
There are only a couple of services, while there can be a lot of sessions.
Timo Sirainen [Wed, 12 Nov 2014 04:58:37 +0000 (06:58 +0200)]
director: Added support for backend cluster "tags".
This allows using a single director ring for multiple backend clusters. By
default everything has an empty tag. A passdb lookup can return
"director_tag" field containing the wanted tag name. If there aren't any
backend servers with the wanted tag, it's treated the same as if there
aren't any backend servers available (= wait for 30 secs for a backend and
then return temporary failure).
Tags can be added to configuration by adding @tag suffix to IPs/hosts. For
example:
"doveadm director add" can also add tags either with @tag suffix or with -t
parameter. "doveadm director status user@domain" requires giving the user's
correct tag with -t parameter or the results won't be correct (empty tag's
results are shown). Tags can't currently be changed for an existing host
without removing it first.
Timo Sirainen [Wed, 12 Nov 2014 04:46:45 +0000 (06:46 +0200)]
director: Don't restart request timeout when director state changes.
If the state keeps changing all the time we'll never return timeouts for the
requests.
Timo Sirainen [Wed, 12 Nov 2014 01:29:04 +0000 (03:29 +0200)]
director: Added director_consistent_hashing setting.
This should have been the default since the beginning. I didn't thik it was
worth the trouble originally because in theory it shouldn't matter much if
users jump between multiple backends. But this makes caching behavior worse,
especially for systems which are using local cache files.
Timo Sirainen [Tue, 11 Nov 2014 23:06:02 +0000 (01:06 +0200)]
doveadm: Support running non-mail commands via doveadm server.
There are still some commands that print their output via printf though, so
they need to be fixed separately.
Timo Sirainen [Tue, 11 Nov 2014 23:04:27 +0000 (01:04 +0200)]
doveadm: Moved commands related code to doveadm-cmd.[ch]
Commands are already split for command line-only commands and commands that
can be run via doveadm-server also.
Timo Sirainen [Thu, 30 Oct 2014 01:33:46 +0000 (18:33 -0700)]
imap-login: Added "x-session-ext-id" parameter for ID command.
It's exactly the same as "x-session-id", but this one can be safely used by
external software without having to worry about causing error messages in
older versions about too long session-id.
Stephan Bosch [Tue, 28 Oct 2014 23:12:09 +0000 (16:12 -0700)]
lib-http: client: Fixed assertion failure in http_client_queue_fail().
Don't explicitly clear the request array after looping through all
requests, since new requests may be added during the loop, not only
removed.
Timo Sirainen [Tue, 28 Oct 2014 04:43:10 +0000 (21:43 -0700)]
lib-http: If there's an error reading chunked http stream, set the error to the istream.
Previously the error string was set, but it was never read by anything.
Timo Sirainen [Mon, 27 Oct 2014 21:26:10 +0000 (23:26 +0200)]
lib: o_stream_uncork() could also cause write errors. Make sure last_failed_errno is updated.
This caused some write errors not to be detected, such as in code like:
o_stream_cork()
o_stream_nsend(..)
o_stream_uncork()
if (o_stream_nfinish() < 0) {
// error not detected because last_failed_errno was 0
}
Timo Sirainen [Mon, 27 Oct 2014 18:10:19 +0000 (20:10 +0200)]
master: Added an assert to catch duplicate fork() PIDs.
This really shouldn't be happening, but apparently it does sometimes. This
should make it easier to debug.
Stephan Bosch [Sun, 26 Oct 2014 16:43:57 +0000 (18:43 +0200)]
lib-http: server: Fixed a hang occurring sometimes when response is sent for a request that had payload.
Forgot to always trigger sending response when processing request payload
finishes.
Timo Sirainen [Sat, 25 Oct 2014 03:19:41 +0000 (06:19 +0300)]
lib-storage: LAYOUT=index now first creates the backend mailbox and only then adds it to list index.
This avoids any race conditions with mailbox creation and opening it.
Timo Sirainen [Fri, 24 Oct 2014 23:42:47 +0000 (02:42 +0300)]
auth: Some unsuccessful passdb lookups weren't returned as failures to passdb lookups.
These lookups were only being done internally, so it usually didn't matter.
Also this only affected things like allow_nets checking and some non-common
passdb { result_* } settings.
Stephan Bosch [Fri, 24 Oct 2014 22:38:42 +0000 (01:38 +0300)]
lib-http: client: Fixed cleanup of remaining waiting requests at connection destroy.
Forgot to dereference the requests for the reference that the connection
itself holds for each waiting request.