Timo Sirainen [Fri, 16 Jan 2015 22:15:44 +0000 (00:15 +0200)]
lib-mail: Added mail-html2text API
What makes it mail-specific is that it allows skipping over data inside
<blockquote>. This code probably doesn't parse HTML perfectly, but hopefully
good enough for HTML emails.
Timo Sirainen [Wed, 14 Jan 2015 23:05:13 +0000 (01:05 +0200)]
lib-charset: Added charset_utf8_to_utf8_begin() wrapper function.
It's never supposed to fail, so it makes it nicer for the callers who need
to use it.
Timo Sirainen [Wed, 14 Jan 2015 23:03:58 +0000 (01:03 +0200)]
lib: Fixed NUL-handling in uni_utf8_*strlen*()
uni_utf8_strlen() could have skipped over the ending NUL byte and caused
read buffer overflows with invalid input.
uni_utf8_strlen_n() and uni_utf8_partial_strlen_n() now allow NUL bytes in
the input and they're treated as regular control characters. Previously the
size was actually treated as max_size with early NUL byte termination.
Technically this is an API change, but I'm not aware of anything using these
functions in an incompatible way.
Timo Sirainen [Wed, 14 Jan 2015 22:10:56 +0000 (00:10 +0200)]
lib-storage: Added "oldestonly" search arg to stop searching after the first non-match.
This parameter works only for doveadm search queries. It's not fully exact
currently, because if mailbox.search_next_update_seq() skips over
non-matching messages we don't stop if the next message matches. So this
parameter is mainly useful for optimization of commands like:
Where the timestamps should be ascending all the time anyway and there's no
point in continuing to search for more mails after the first timestamp is
too high.
Timo Sirainen [Sat, 10 Jan 2015 02:32:42 +0000 (04:32 +0200)]
lib-mail: message-decoder no longer skips lib-charset for UTF8 -> UTF8 translations.
With the previous lib-charset fix this makes message-decoder handle partial
UTF-8 text in input blocks correctly.
Timo Sirainen [Sat, 10 Jan 2015 02:25:21 +0000 (04:25 +0200)]
lib-charset: UTF-8 -> UTF-8 translation was never returning CHARSET_RET_INCOMPLETE_INPUT
Instead the incomplete input was just being modified into broken output.
Timo Sirainen [Tue, 6 Jan 2015 01:15:11 +0000 (03:15 +0200)]
lib: Remove OpenBSD workaround in i_getpw*()
Originally added in 801714cba91b. It was requested to be removed now that 1)
it's fixed in OpenBSD v5.6+ and 2) The workaround caused nonexistent users
to not work correctly (process running out of memory I guess?)
Phil Carmody [Mon, 5 Jan 2015 20:16:59 +0000 (22:16 +0200)]
lib: guid - centralise a 'reset to the empty value' helper function
This helper just ensures that the caller never has to get the sizeof()
right. (Were a guid passed as a function parameter, mistakes could happen.)
Phil Carmody [Mon, 5 Jan 2015 20:15:31 +0000 (22:15 +0200)]
lib: guid - declare some functions as pure
As the functions aren't inline, the compiler can't know if they
can be optimised away, so give it a helping hand.
Phil Carmody [Mon, 5 Jan 2015 20:15:07 +0000 (22:15 +0200)]
lib: array - explain implications of ARRAY_TYPE() in comment
If you use ARRAY_TYPE() to pass an array around, then you must also
use ARRAY_TYPE() to define the array itself, ARRAY() will no longer do.
Reported-by: Arnt Gulbrandsen <arnt@gulbrandsen.priv.no> Signed-off-by: Phil Carmody <phil@dovecot.fi>
Phil Carmody [Mon, 5 Jan 2015 20:12:48 +0000 (22:12 +0200)]
lib: array - new linear search helper
There are large numbers of array_foreach loops which do nothing but search
for the first element which matches some key. This can be abstracted out
into a helper.
Timo Sirainen [Fri, 5 Dec 2014 02:39:11 +0000 (04:39 +0200)]
doveadm: Avoid calling init() in doveadm binary if the command is sent to doveadm-server.
The init() is still always called when -A or -u *wildcards* are used though.
I'm not sure if that can be delayed. At least all commands should be
verified that they don't rely on the current init() location.
Timo Sirainen [Fri, 5 Dec 2014 01:38:08 +0000 (03:38 +0200)]
auth: Don't allow changing username to an empty string.
This is most likely always accidental and Dovecot in general hasn't been
designed to support empty usernames.
Phil Carmody [Mon, 1 Dec 2014 20:43:33 +0000 (22:43 +0200)]
lib: test-array - really really really stop gcc optimising away fatal tests
Gcc 4.6 also was determined to optimise away the calls that should crash.
We therefore have to do *something*, no matter how stupid, with the return
values. This should do it. (please, oh please, oh please, ...)
Phil Carmody [Fri, 28 Nov 2014 08:57:43 +0000 (10:57 +0200)]
lib: test-array - remove possibility to optimise out tests
(void) on a call to a "pure" function was causing some compilers (gcc 4.8)
to not reach the assert within the pure function. Technically it's not a
pure function, as (in the assert fail case) it has effects other than its
return value. However, simply removing the void cast (and then actually
using the return value) also prevents this optimisation.
An additional fatal test was added - there's a difference between an access
outside the allocated range and outside the initialised range.
Phil Carmody [Fri, 28 Nov 2014 08:57:43 +0000 (10:57 +0200)]
lib-test: more delicate *assert() behaviour when doing fatal tests
We shouldn't be i_asserting ourselves when we're in the state of wanting a
test to fail. Therefore instead test_assert to get the assert message, and
ensure that the success flag is cleared to get the FAILED at the end.
Phil Carmody [Tue, 25 Nov 2014 01:48:42 +0000 (03:48 +0200)]
lib: array - additional compile-time checks to array_append
The new two-array helper macro works in this context too.
Note: array_copy doesn't have any protection currently, it isn't
obvious how to wrap that with some safety without breaking interfaces.
It only seems to have one internal user, lib/aqueue.
Phil Carmody [Tue, 25 Nov 2014 01:45:35 +0000 (03:45 +0200)]
lib: test-array - fix off-by-one in test_reverse
i is not used as an index, but as a count. Therefore, it can attain the
array size in the loop without causing any buffer overflows.
Phil Carmody [Tue, 25 Nov 2014 01:31:34 +0000 (03:31 +0200)]
lib: guid - turn uint8_t * parameters into guid_128_t
As we expose the type's internals, there's no concrete difference between
the two, but it might help static code checkers to detect misuse of the
library, or sloppy typing.
Timo Sirainen [Tue, 25 Nov 2014 00:56:37 +0000 (02:56 +0200)]
lib-storage: Don't fetch wanted_fields for messages that don't match the search query.
For example "doveadm fetch text subject foo" was opening all the mails, even
though only a few matched the subject (that was hopefully already in cache
file).
The behavior still isn't perfect though. The wanted_fields should probably
be split into search_wanted_fields and fetch_wanted_fields, but the current
behavior is likely good enough for now.
Stephan Bosch [Sat, 15 Nov 2014 00:37:45 +0000 (02:37 +0200)]
Implemented dot output stream. This outputs data in the dot-escaped format needed for the SMTP data command.
The sequence CRLF.CRLF is sent upon closing the stream.
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.