Timo Sirainen [Fri, 13 Feb 2015 14:38:35 +0000 (16:38 +0200)]
Link all libstorage.la dependencies into the library itself instead.
Instead of keeping a lot of different libraries in LIBDOVECOT_STORAGE, which
have circular dependencies and may cause linking issues.
Timo Sirainen [Tue, 10 Feb 2015 11:12:42 +0000 (13:12 +0200)]
dovecot.m4: External plugins can now more easily run their tests via Valgrind.
DC_DOVECOT macro automatically adds RUN_TEST variable to Makefiles, which
can be used to call any test programs. If valgrind exists, the tests are run
through it. This is done by writing run-test.sh to the build directory, so
the original run-test.sh in hg is no longer needed.
Timo Sirainen [Mon, 9 Feb 2015 11:03:47 +0000 (13:03 +0200)]
doveadm: Reverted changeset 3b89f2f4ffb3, which avoided calling init() for proxied commands.
The init() is required for all commands that print something, because
otherwise the doveadm_print_header*() isn't called and the commands crash.
The reason for the original change was that some commands' init() attempted
to do too much work on the proxy, which ended up failing. So looks like the
proper fix is to just remove this kind of extra work from init().
Timo Sirainen [Fri, 6 Feb 2015 16:18:10 +0000 (18:18 +0200)]
lib: Added module_dir_try_load_missing() that returns error instead of logging it.
Also module_names now can be given for it without i_fatal() being called.
Timo Sirainen [Fri, 6 Feb 2015 15:06:36 +0000 (17:06 +0200)]
lib-storage: Set the user log prefix earlier when initializing user.
So the full prefix with session and other useful information is included in
the log message as early as possible. Some fatal/panic errors wouldn't even
have shown the username.
Timo Sirainen [Thu, 5 Feb 2015 17:40:25 +0000 (19:40 +0200)]
dsync: Fixed crash in earlier patch if node didn't have a namespace.
This shouldn't have happened except in test-dsync-mailbox-tree-sync, but
easier and safer to fix it here.
Timo Sirainen [Thu, 5 Feb 2015 17:36:29 +0000 (19:36 +0200)]
dsync: Added assert to make sure namespace prefix isn't attempted to be renamed.
This can happen, I'm just not sure how exactly.. The previous behavior
caused assert-crashes also, this change just makes it happen earlier.
Timo Sirainen [Thu, 5 Feb 2015 17:20:17 +0000 (19:20 +0200)]
dsync: Don't assert-crash in configs where INBOX doesn't have a parent namespace.
The inbox=yes namespace of course exists, but if there is no prefix="" or
prefix=INBOX/ namespace, then INBOX doesn't clearly belong to any namespace.
Timo Sirainen [Tue, 3 Feb 2015 18:27:49 +0000 (20:27 +0200)]
dsync: Make sure when fixing mailbox names we don't try to change the namespace prefix.
Although in normal installations this it wouldn't have happened in any case.
Timo Sirainen [Tue, 3 Feb 2015 16:33:12 +0000 (18:33 +0200)]
imapc: Added imapc_features=search support for sending SEARCH commands.
Currently requires the remote server to support ESEARCH (but this would be
easy to avoid). This is only minimally tested for now, so bugs may exist
(especially related to sub-queries).
Timo Sirainen [Tue, 3 Feb 2015 08:15:38 +0000 (10:15 +0200)]
lib-imap-client: Implemented support for GMail [THROTTLED] resp-text-code.
If we receive it, start throttling future commands by waiting exponentially
longer until we no longer receive [THROTTLED]. Max wait time is currently
16 seconds.
Stephan Bosch [Mon, 2 Feb 2015 21:48:30 +0000 (23:48 +0200)]
lib-http: client: Fixed double unref of request when error occurs during http_client_request_try_retry().
Much like when the request is first submitted, any errors that occur while attempting a retry from within the callback are now delayed in a zero timer.
Phil Carmody [Mon, 2 Feb 2015 08:24:42 +0000 (10:24 +0200)]
lib: array - two helpers to avoid wasteful array_count
There's no need to dereference array->element_size and
perform a division when all you care about is the boolean
isempty/nonempty predicate:
Changing 6 of them has the following impact on the code:
$ size src/lib-imap-client/imapc-connection.o
text data bss dec hex filename
20879 0 4 20883 5193 src/lib-imap-client/imapc-connection.o
$ size src/lib-imap-client/imapc-connection.o
text data bss dec hex filename
20796 0 4 20800 5140 src/lib-imap-client/imapc-connection.o
Timo Sirainen [Fri, 30 Jan 2015 10:19:58 +0000 (12:19 +0200)]
imap: Dynamic capabilities weren't being added correctly when imap_capability setting was used.
They were supposed to be added when '+' prefix was used in imap_capability
and not added when it wasn't. But the behavior was exactly the opposite.
Timo Sirainen [Fri, 30 Jan 2015 09:52:33 +0000 (11:52 +0200)]
lib: Various fixes to str_sanitize*()
- UTF-8 sequences could have been truncated to become partial sequences
- Truncation may not have happened at all to text containing UTF-8
- str_sanitize_append() might have truncated string beyond what we were
appending, although that happened only if max_len was very small
Timo Sirainen [Thu, 29 Jan 2015 16:43:15 +0000 (18:43 +0200)]
lib-ssl-iostream: Don't set EPIPE/ECONNRESET error to istream when connection is closed.
Several istream users verify at EOF that stream_errno=0 and fail if it
isn't.
Phil Carmody [Sat, 24 Jan 2015 00:15:45 +0000 (02:15 +0200)]
lib: array - helper to swap array buffer ownership
Currently there's no simple way to create a replacement for an array,
and then atomically switch in that replacement. With this helper,
you can just exchange ownership of the two lists and then free the
new list (which now contains the old buffer).
Timo Sirainen [Fri, 23 Jan 2015 21:19:24 +0000 (23:19 +0200)]
imapc: Merged gmail-pop3 and gmail-labels-keyword features into a single gmail-migration feature
There's really no other reason to use them except for migration.
Timo Sirainen [Fri, 23 Jan 2015 21:18:01 +0000 (23:18 +0200)]
imapc: With gmail-labels-keyword feature add the $GMailHaveLabels only to \All mailbox
This is primarily intended for migration, and with this behavior dsync can
be run just once so it's faster.
Phil Carmody [Tue, 20 Jan 2015 23:51:46 +0000 (01:51 +0200)]
plugins/fts: expunge-log - create flattened in-RAM log with no backing storage
Combine each record in a source expunge log. This source log does not get
deleted afterwards.
Phil Carmody [Tue, 20 Jan 2015 23:47:25 +0000 (01:47 +0200)]
plugins/fts: expunge-log - permit append helpers to have no log to write to
This is for creating an in-RAM, later queriable, structure which you do not
want to be written to backing storage. As when you've finished with one, there's
no concept of a "commit", provide an alternative "abort" way out. These are
identical apart from the call to the write() routine, so refactor the two.
Phil Carmody [Tue, 20 Jan 2015 23:44:31 +0000 (01:44 +0200)]
lib: seq-range-array - add range changes
Pull the _add_range() guts into a private helper function, and add a new
_add_range_count() helper which also returns the number of SEQs added.
data-stack.c:477:29: runtime error: negation of 8 cannot be represented in type 'unsigned long'
data-stack.c:495:15: runtime error: negation of 8 cannot be represented in type 'unsigned long'
Which is of course complete bollocks. There is no 8, there's only an 8ul, and
the negation of 8ul is 0xfffffff8ul (or a wider equivalent). That's the law.
However, the pointer arithmetic which follows the negation, whilst almost
certainly working in practice, is probably bogus, so just make the thing
signed before the negation, and both problems go away.
Reported-by: Teemu Huovila <teemu.huovila@dovecot.fi> Signed-off-by: Phil Carmody <phil@dovecot.fi>
Timo Sirainen [Tue, 20 Jan 2015 19:54:58 +0000 (21:54 +0200)]
imapc: Implemented imapc_features=gmail-pop3 that also migrates pop3_deleted_flag.
This also caused gmail-pop3-uidl feature to be renamed to simply gmail-pop3,
which includes both the features.
Timo Sirainen [Tue, 20 Jan 2015 02:30:27 +0000 (04:30 +0200)]
imapc: Added imapc_features=gmail-labels-keyword
This is a bit kludgy feature mainly intended for migrations from GMail.
Unfortunately I couldn't figure out any nicer way to do this for now.
GMail's "All Mail" folder contains all messages in all folders, but it also
contains some messages that don't exist in other folders. For migrations we
want to copy only those messages that don't exist elsewhere. This can now be
achieved with something like:
Note that dsync can't handle inserting mails into folders, so if doveadm
backup is already run once and one of the existing mails loses all labels,
doveadm backup will delete the whole folder and start again.
Timo Sirainen [Tue, 20 Jan 2015 01:23:29 +0000 (03:23 +0200)]
dsync: If same GUID already exists in storage, try to copy it instead of recreating the mail.
This way most mailbox backends can reduce disk space by only doing a
reference count update.
This feature isn't enabled by default. A virtual "All Mails" mailbox needs
to be configured using the virtual plugin. Then you need to give this
mailbox as -a parameter, e.g.:
doveadm sync -a "Virtual/All Mails" ...
Currently this is implemented by reading through all the GUIDs in the
virtual mailbox. This of course isn't very efficient for things like
incremental replication. An upcoming conversation plugin will keep track of
all the mails' GUIDs, so in future replication should be able to have this
functionality efficiently as well.
Timo Sirainen [Tue, 20 Jan 2015 01:14:37 +0000 (03:14 +0200)]
virtual plugin: Read virtual index header when opening virtual mailbox.
This allows doing some mailbox accessing without actually syncing the
mailbox. For example MAIL_FETCH_MAILBOX_NAME can be used without crashing.
Timo Sirainen [Mon, 19 Jan 2015 21:43:37 +0000 (23:43 +0200)]
dsync: Added -t <timestamp> parameter to save only mails newer than <timestamp>
If one side has old mails that don't exist on the other side, they are
ignored (not synced and not deleted).
Timo Sirainen [Mon, 19 Jan 2015 21:40:27 +0000 (23:40 +0200)]
lib-storage: Added mail_parse_human_timestamp() to parse human-writable timestamps.
This isn't really the ideal location for the function, but since it uses
both lib-settings and lib-imap, there's not any good location for it that I
can think of..
Timo Sirainen [Mon, 19 Jan 2015 20:24:42 +0000 (22:24 +0200)]
doveadm: Added missing error handling to various mail commands.
This fixes assert-crash that happened when the commands failed, because they
hadn't set any exit_code.
Timo Sirainen [Mon, 19 Jan 2015 19:58:19 +0000 (21:58 +0200)]
lib-storage: Removed caching body snippet while message is being saved.
This broke saving mails with dbox, because it attempts to open the mails
too early. Also the generation was a bit costly operation to do if it wasn't
actually wanted to be cached.
So in future we'd first want to check if body snippet is actually wanted. If
it is, then generate the potential snippets while the message is being
parsed (always generate the snippet for the best found MIME part, replacing
existing snippets when needed). This requires the message_snippet_generate()
API to support sending input as partial message_blocks.
Timo Sirainen [Mon, 19 Jan 2015 19:52:21 +0000 (21:52 +0200)]
dbox: Added asserts to make sure the mail body isn't tried to be read too early while saving.
If the mail headers are still being written, the opening will just fail
thinking the mail is corrupted.
Timo Sirainen [Sat, 17 Jan 2015 00:40:11 +0000 (02:40 +0200)]
auth: Changed passdb { continue-ok } handling for credentials lookups.
If the last passdb after it doesn't return credentials, use the first
passdb's credentials. This allows implementing plugins that modify the
passdb result without actually changing the credentials.
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.