]> git.ipfire.org Git - thirdparty/dovecot/core.git/log
thirdparty/dovecot/core.git
8 years agolib-index: Update per-flag modseq value a bit more correctly.
Timo Sirainen [Sat, 5 Aug 2017 05:29:12 +0000 (14:29 +0900)] 
lib-index: Update per-flag modseq value a bit more correctly.

This changes the code to be similar to the per-mail modseq updating in
mail_index_modseq_update(). It probably wasn't exactly wrong previously
either, but this change is required for the following commits.

8 years agolib-index: Fix checking if modseq header is up-to-date
Timo Sirainen [Sat, 5 Aug 2017 05:16:31 +0000 (14:16 +0900)] 
lib-index: Fix checking if modseq header is up-to-date

We were almost always assuming that it is.

8 years agolib-index: Fix modseq tracking with multiple flag updates
Timo Sirainen [Sat, 5 Aug 2017 05:11:17 +0000 (14:11 +0900)] 
lib-index: Fix modseq tracking with multiple flag updates

The earlier code was checking only the first flag record update. If the
first one had only internal flag changes but (some of) the rest didn't,
the modseq wasn't counted correctly. This was probably pretty rare.

8 years agolib-index: Fix modseq tracking for MAIL_INDEX_MAIL_FLAG_UPDATE_MODSEQ
Timo Sirainen [Sat, 5 Aug 2017 05:07:58 +0000 (14:07 +0900)] 
lib-index: Fix modseq tracking for MAIL_INDEX_MAIL_FLAG_UPDATE_MODSEQ

This is used to increase modseq for mails when their private flags change.
Use an already existing MAIL_TRANSACTION_FLAG_UPDATE_IS_INTERNAL() that
does this properly.

(This change preserves another bug, which is fixed in the next commit.)

8 years agodsync: Add missing transaction flags when performing UID renumbering
Timo Sirainen [Wed, 9 Aug 2017 10:17:15 +0000 (13:17 +0300)] 
dsync: Add missing transaction flags when performing UID renumbering

The transaction didn't have MAILBOX_TRANSACTION_FLAG_SYNC or
MAILBOX_TRANSACTION_FLAG_NO_NOTIFY (with DSYNC_BRAIN_FLAG_NO_NOTIFY).

This caused replication-dsync to unnecessarily trigger another dsync
replication notification.

8 years agolib: When logging I/O or timeout leak, log also raw backtrace
Timo Sirainen [Tue, 8 Aug 2017 17:07:18 +0000 (20:07 +0300)] 
lib: When logging I/O or timeout leak, log also raw backtrace

This can be useful when trying to figure out where the io_loop_destroy() was
called from.

8 years agolib-storage: Panic if at mailbox_free() there are open attribute iterators.
Timo Sirainen [Wed, 9 Aug 2017 10:41:34 +0000 (13:41 +0300)] 
lib-storage: Panic if at mailbox_free() there are open attribute iterators.

8 years agopush-notification: Switch to main ioloop while calling drivers' deinit/cleanup callbacks
Timo Sirainen [Wed, 9 Aug 2017 10:23:36 +0000 (13:23 +0300)] 
push-notification: Switch to main ioloop while calling drivers' deinit/cleanup callbacks

Continues a44595f7b1afc7ccbd8653598753b32899d01c76 to other functions.
For example the OX backend would call http_client_wait(), which would move
the I/Os and timeouts to the current ioloop, which might not be main_ioloop
always. When that ioloop gets destroyed, I/O and timeout leaks are logged
and eventually the process crashes when calling http_client_deinit() in
cleanup() (this would happen later for another mail_user).

8 years agolib: Add asserts to make sure running ioloop is always current_ioloop
Timo Sirainen [Tue, 8 Aug 2017 19:11:48 +0000 (22:11 +0300)] 
lib: Add asserts to make sure running ioloop is always current_ioloop

We could also switch current_ioloop to the running ioloop temporarily while
calling callbacks, but this behavior is probably clearer. All of the
existing code should already work this way.

Add the asserts after IO or timeout callback is called, so if the assert
triggers, we can find out which callback caused the change. The initial
assert in io_loop_handler_run() is enough to verify that the initial
ioloop is correct.

8 years agovirtual: Sync backend flags on initial sync when UIDVALIDITY hasn't changed
Aki Tuomi [Wed, 26 Jul 2017 09:53:16 +0000 (12:53 +0300)] 
virtual: Sync backend flags on initial sync when UIDVALIDITY hasn't changed

Before recent fixes the UIDVALIDITY was thought to change almost every time,
so this bug wasn't visible.

8 years agovirtual: Do not store recent flags to virtual index
Aki Tuomi [Wed, 26 Jul 2017 10:35:36 +0000 (13:35 +0300)] 
virtual: Do not store recent flags to virtual index

Setting the flag here would case unnecessary index update
to clear the flag later on.

8 years agolib: If CORE_IO_LEAK environment is set, panic on IO/timeout leaks
Timo Sirainen [Tue, 8 Aug 2017 19:25:13 +0000 (22:25 +0300)] 
lib: If CORE_IO_LEAK environment is set, panic on IO/timeout leaks

8 years agoimapc: Add imapc_features=send-id to send ID x-session-ext-id
Timo Sirainen [Wed, 2 Aug 2017 07:54:27 +0000 (10:54 +0300)] 
imapc: Add imapc_features=send-id to send ID x-session-ext-id

8 years agolib-imap-client: Support sending IMAP ID command including unique x-session-ext-id
Timo Sirainen [Wed, 2 Aug 2017 07:49:33 +0000 (10:49 +0300)] 
lib-imap-client: Support sending IMAP ID command including unique x-session-ext-id

8 years agomdbox: "Inconsistency in map index" wasn't fixing itself automatically
Timo Sirainen [Mon, 7 Aug 2017 21:31:57 +0000 (00:31 +0300)] 
mdbox: "Inconsistency in map index" wasn't fixing itself automatically

Broken by b9da8540e665138b3cad0b637c08c0ab7d7a7eeb

8 years agodoveadm: mailbox_list_index_very_dirty_syncs disabled for force-resync
Sergey Kitov [Mon, 7 Aug 2017 13:03:46 +0000 (16:03 +0300)] 
doveadm: mailbox_list_index_very_dirty_syncs disabled for force-resync

prerun of cmd force-resync sets mailbox_list_index_very_dirty_syncs to
no for mail_storage_service_user befor mail_user is allocated.

8 years agolib-storage: added settings updating function for the mail_storage_service user
Sergey Kitov [Mon, 7 Aug 2017 12:59:35 +0000 (15:59 +0300)] 
lib-storage: added settings updating function for the mail_storage_service user

8 years agolazy-expunge: Log internal errors instead of just "Internal error occurred"
Timo Sirainen [Fri, 4 Aug 2017 15:20:50 +0000 (18:20 +0300)] 
lazy-expunge: Log internal errors instead of just "Internal error occurred"

8 years agolib-storage: If mailbox_list_index_very_dirty_syncs=yes, still rebuild empty list...
Timo Sirainen [Fri, 4 Aug 2017 04:31:19 +0000 (13:31 +0900)] 
lib-storage: If mailbox_list_index_very_dirty_syncs=yes, still rebuild empty list index

8 years agolib-imap-client: Log an info-line when connected to remote server
Timo Sirainen [Tue, 1 Aug 2017 04:48:55 +0000 (13:48 +0900)] 
lib-imap-client: Log an info-line when connected to remote server

Include the remote IP:port ad local IP:port. This allows matching the
connection with the remote server's logs (or e.g. haproxy logs).

8 years agolib-storage: MAIL_STORAGE_SERVICE_FLAG_NO_PLUGINS wasn't working correctly
Timo Sirainen [Sun, 30 Jul 2017 06:39:18 +0000 (09:39 +0300)] 
lib-storage: MAIL_STORAGE_SERVICE_FLAG_NO_PLUGINS wasn't working correctly

Especially with "doveadm user" it still triggered running the plugins,
because doveadm loads all the plugins early.

8 years agoauth: Escape LDAP search filter properly
Aki Tuomi [Thu, 20 Jul 2017 10:24:21 +0000 (13:24 +0300)] 
auth: Escape LDAP search filter properly

This is syntaxical escaping to make ldap servers accept queries
with escapable characters, instead of erroring out.

8 years agodict-ldap: Escape LDAP search filter properly
Aki Tuomi [Thu, 20 Jul 2017 05:49:25 +0000 (08:49 +0300)] 
dict-ldap: Escape LDAP search filter properly

This is syntaxical escaping to make ldap servers accept queries
with escapable characters, instead of erroring out. It is possible
that the filter could have been modified in unexpected ways
if the input comes from untrusted sources.

8 years agolib-ldap: Store error if sending request to LDAP fails
Aki Tuomi [Thu, 20 Jul 2017 05:48:30 +0000 (08:48 +0300)] 
lib-ldap: Store error if sending request to LDAP fails

If the request cannot be sent e.g. due to bad search filter
store the error into the result.

Fixes Panic: file ldap-connection.c: line 709 (ldap_result_has_failed): assertion failed: ((result->openldap_ret == LDAP_SUCCESS) == (result->error_string == NULL))

8 years agolib-http: message parser: Reject messages with invalid Date header when HTTP_MESSAGE_...
Stephan Bosch [Thu, 27 Jul 2017 14:34:34 +0000 (16:34 +0200)] 
lib-http: message parser: Reject messages with invalid Date header when HTTP_MESSAGE_PARSE_FLAG_STRICT flag is enabled.

8 years agolib-http: Fixed bug in date parser: sometimes read one byte past end of input.
Stephan Bosch [Thu, 27 Jul 2017 14:30:20 +0000 (16:30 +0200)] 
lib-http: Fixed bug in date parser: sometimes read one byte past end of input.

This caused spurious parse errors.

8 years agolib-http: test-http-response-parser: Show error message for tests of invalid responses.
Stephan Bosch [Thu, 27 Jul 2017 14:03:44 +0000 (16:03 +0200)] 
lib-http: test-http-response-parser: Show error message for tests of invalid responses.

8 years agoimap: Flush response to client before starting possibly long operation
Aki Tuomi [Wed, 26 Jul 2017 16:47:16 +0000 (19:47 +0300)] 
imap: Flush response to client before starting possibly long operation

Fixes Error: Timeout communicating with /var/run/dovecot/imap-master (version received)

8 years agoimap: Set client created before initializing namespaces
Aki Tuomi [Wed, 26 Jul 2017 16:42:48 +0000 (19:42 +0300)] 
imap: Set client created before initializing namespaces

Fixes Panic: file master-service.c: line 819 (master_service_client_connection_destroyed): assertion failed: (service->master_status.available_count < service->total_available_count)

8 years agolib-storage: Hide and rmdir \NoSelect leaf mailboxes with NO-NOSELECT
Timo Sirainen [Tue, 25 Jul 2017 17:53:18 +0000 (20:53 +0300)] 
lib-storage: Hide and rmdir \NoSelect leaf mailboxes with NO-NOSELECT

If the leaf is successfully rmdir()ed, rmdir() also its parents.

This doesn't work perfectly with if there are multiple levels of \NoSelect
mailboxes. For example with "a/b/c" the listing will already have returned
"a" and "a/b" before it reaches the "a/b/c" code, which will rmdir all of
them, but it's a bit too late at that point. It's too much work to fix
though, and the situation will be fixed on the next list anyway.

8 years agolib-storage: Add setting to disable \NoSelect mailboxes
Timo Sirainen [Tue, 25 Jul 2017 13:10:51 +0000 (16:10 +0300)] 
lib-storage: Add setting to disable \NoSelect mailboxes

Enabled using mail_location = ...:NO-NOSELECT

Trying to create \NoSelect "dir/" will result just creating "dir", similar
to how Maildir++ layout already did it.

Deleting a mailbox will delete all of its \NoSelect parents.

8 years agolib-storage: Mailbox rename shouldn't auto-rmdir parent index dirs with ITERINDEX
Timo Sirainen [Tue, 25 Jul 2017 12:54:37 +0000 (15:54 +0300)] 
lib-storage: Mailbox rename shouldn't auto-rmdir parent index dirs with ITERINDEX

For example:
 - create a/b
 - rename a/b c

This resulted in "a" existing in mail root directory, but not in index
directory. With ITERINDEX this meant that the "a" was lost.

8 years agolib-storage: index: Made MIME FILENAME search criterion match case-insensitively.
Stephan Bosch [Tue, 23 May 2017 12:05:02 +0000 (14:05 +0200)] 
lib-storage: index: Made MIME FILENAME search criterion match case-insensitively.

8 years agodoveadm service status: Add doveadm_stop field
Timo Sirainen [Wed, 19 Jul 2017 18:24:48 +0000 (21:24 +0300)] 
doveadm service status: Add doveadm_stop field

This indicates whether "doveadm service stop" was used for the service.

8 years agolib-storage: If root dir already exists as file, log better error message.
Timo Sirainen [Tue, 25 Jul 2017 06:35:31 +0000 (09:35 +0300)] 
lib-storage: If root dir already exists as file, log better error message.

8 years agolib: Fix compiler warning in var-expand-if
Timo Sirainen [Tue, 25 Jul 2017 07:39:43 +0000 (10:39 +0300)] 
lib: Fix compiler warning in var-expand-if

8 years agolib: Fix static analyzer warnings in var-expand-if
Timo Sirainen [Tue, 25 Jul 2017 06:43:56 +0000 (09:43 +0300)] 
lib: Fix static analyzer warnings in var-expand-if

8 years agolib-storage: Try to get mailbox list index's permissions from its parent directory
Timo Sirainen [Mon, 24 Jul 2017 18:08:33 +0000 (21:08 +0300)] 
lib-storage: Try to get mailbox list index's permissions from its parent directory

This avoids stat()ing the mail/index root directory, which is especially
useful when mailbox list index is stored in tmpfs.

8 years agolib-index: Add mail_index_use_existing_permissions()
Timo Sirainen [Mon, 24 Jul 2017 18:07:44 +0000 (21:07 +0300)] 
lib-index: Add mail_index_use_existing_permissions()

This has annoyingly lot of copy&pasting from
mailbox_list_get_permissions_stat(), but there didn't seem to be any nice
place where to share the code.

8 years agolib-storage: If ITERINDEX is set, delay checking whether mail root exists
Timo Sirainen [Mon, 24 Jul 2017 17:48:25 +0000 (20:48 +0300)] 
lib-storage: If ITERINDEX is set, delay checking whether mail root exists

In future this could be done even without ITERINDEX. It's not done yet,
since it might break backwards compatibility with some systems.

8 years agolib-storage: Allow LISTINDEX to point to a different directory
Timo Sirainen [Sat, 22 Jul 2017 15:39:19 +0000 (18:39 +0300)] 
lib-storage: Allow LISTINDEX to point to a different directory

Most importantly because the mailbox list index is only a cache, it could be
safely pointed to e.g. tmpfs to save disk I/O.

8 years agovar-expand-if: Remove unused variable par_start
Aki Tuomi [Mon, 24 Jul 2017 15:30:01 +0000 (18:30 +0300)] 
var-expand-if: Remove unused variable par_start

8 years agolib-storage: Add mailbox_list_index_include_inbox setting
Timo Sirainen [Mon, 24 Jul 2017 11:17:22 +0000 (14:17 +0300)] 
lib-storage: Add mailbox_list_index_include_inbox setting

This controls whether to update INBOX's STATUS information in the mailbox
list index. It can be useful especially if LISTINDEX points to a tmpfs,
but perhaps also in other situations.

I considered adding a more generic setting to exclude other mailboxes, but
the namespace prefixes and hierarchy separators get a bit complicated with
shared mailboxes. It's probably also not very useful to change this for
anything but the INBOX.

8 years agoexample-config: Add mailbox_list_index_very_dirty_syncs
Timo Sirainen [Mon, 24 Jul 2017 11:12:55 +0000 (14:12 +0300)] 
example-config: Add mailbox_list_index_very_dirty_syncs

8 years agolib-master: Allow userdb to return postlogin socket path.
Timo Sirainen [Sun, 23 Jul 2017 09:32:38 +0000 (12:32 +0300)] 
lib-master: Allow userdb to return postlogin socket path.

Returning "postlogin=socketpath" as userdb extra field overrides the
postlogin socket path in the service { executable } parameter.

8 years agolib-storage: If userdb returns chdir extra field, chdir() there instead of home
Timo Sirainen [Mon, 24 Jul 2017 13:37:42 +0000 (16:37 +0300)] 
lib-storage: If userdb returns chdir extra field, chdir() there instead of home

This can avoid unnecessary home directory accesses if indexes are stored
outside the home and there's no other reason to chdir() to home.

8 years agolib-storage: If chdir(home) fails due to EACCES, don't log two errors.
Timo Sirainen [Mon, 24 Jul 2017 13:36:45 +0000 (16:36 +0300)] 
lib-storage: If chdir(home) fails due to EACCES, don't log two errors.

8 years agovar-expand: Add tests for var_expand conditionals
Aki Tuomi [Mon, 24 Jul 2017 10:31:49 +0000 (13:31 +0300)] 
var-expand: Add tests for var_expand conditionals

8 years agovar-expand: Add support for conditionals
Aki Tuomi [Mon, 24 Jul 2017 10:31:02 +0000 (13:31 +0300)] 
var-expand: Add support for conditionals

%{if;value-a,op,value-b:true-value:false-value}

8 years agovirtual: Make sure index is rewritten when new mailboxes are added
Timo Sirainen [Fri, 21 Jul 2017 16:52:23 +0000 (19:52 +0300)] 
virtual: Make sure index is rewritten when new mailboxes are added

Otherwise multiple bbox->sync_mailbox_idx point to 0 and they keep overwriting
each others in the header. This causes the header to be constantly updated with
wrong contents.

8 years agolib-storage: Add UIDVALIDITY to mailbox list index on mailbox create
Timo Sirainen [Thu, 20 Jul 2017 13:18:46 +0000 (16:18 +0300)] 
lib-storage: Add UIDVALIDITY to mailbox list index on mailbox create

This avoids an unnecessary secondary write later on when opening the
mailbox.

8 years agolib-storage: Don't update INBOX's sync status to mailbox list index
Timo Sirainen [Thu, 20 Jul 2017 13:01:46 +0000 (16:01 +0300)] 
lib-storage: Don't update INBOX's sync status to mailbox list index

It's not actually used so there's no need to update it either.
Broken by 70092709cdc803c87b8f4ef1b0548eb45515bdae

8 years agolib-sql: Remove duplicate Cassandra consistency names
Martti Rannanjärvi [Thu, 20 Jul 2017 06:46:00 +0000 (09:46 +0300)] 
lib-sql: Remove duplicate Cassandra consistency names

8 years agovirtual: Do not remove mailbox notify if the mailbox is closed
Aki Tuomi [Thu, 20 Jul 2017 08:01:37 +0000 (11:01 +0300)] 
virtual: Do not remove mailbox notify if the mailbox is closed

The backend mailbox close/open status is not related to
the notify API usage. The notify is removed in
virtual_mailbox_close_internal instead when we are
actually deinitializing.

8 years agovirtual: Optimize mailbox_notify_changes() when there's only a single backend mailbox
Timo Sirainen [Wed, 19 Jul 2017 20:19:12 +0000 (23:19 +0300)] 
virtual: Optimize mailbox_notify_changes() when there's only a single backend mailbox

8 years agolib-storage: mailbox_watch_extract_notify_fd() - give better reason if mailbox has...
Timo Sirainen [Wed, 19 Jul 2017 20:11:12 +0000 (23:11 +0300)] 
lib-storage: mailbox_watch_extract_notify_fd() - give better reason if mailbox has no IOs

This happens currently with virtual mailboxes.

8 years agolib: io_loop_extract_notify_fd() - Don't crash if no notifys have been added
Timo Sirainen [Wed, 19 Jul 2017 20:09:13 +0000 (23:09 +0300)] 
lib: io_loop_extract_notify_fd() - Don't crash if no notifys have been added

8 years agoimap: Add %{appended} to imap_logout_format
Martti Rannanjärvi [Tue, 11 Jul 2017 10:12:46 +0000 (13:12 +0300)] 
imap: Add %{appended} to imap_logout_format

8 years agodoc: Change del to deleted in imap_logout_format default to match code
Martti Rannanjärvi [Mon, 3 Jul 2017 12:20:14 +0000 (15:20 +0300)] 
doc: Change del to deleted in imap_logout_format default to match code

8 years agoimap-client: Add %{autoexpunged} to imap_logout_format
Martti Rannanjärvi [Mon, 3 Jul 2017 14:12:08 +0000 (17:12 +0300)] 
imap-client: Add %{autoexpunged} to imap_logout_format

8 years agoimap-client: Add const char *disconnect_reason to client
Martti Rannanjärvi [Tue, 4 Jul 2017 06:25:21 +0000 (09:25 +0300)] 
imap-client: Add const char *disconnect_reason to client

This is to allow using reason given to client_disconnect() via timeout
context.

8 years agolib-index: Fix next_uid lookup in open transaction that has appended mails
Timo Sirainen [Wed, 19 Jul 2017 10:43:09 +0000 (13:43 +0300)] 
lib-index: Fix next_uid lookup in open transaction that has appended mails

The appended mails were used for returning an updated
mail_index_header.next_uid, but only if the mails were assigned UIDs in
mail_index_append(). It should have updated the next_uid also after
mail_index_append_finish_uids() was used to assign the UIDs.

This fixes setting first_recent_uid correctly for virtual mailboxes when the
sync finds new mails. Avoids multiple sessions from getting \Recent flags
for the same mails.

8 years agocassandra: Fix read/write buffer overflows after adding CASSANDRA_QUERY_TYPE_READ_MORE
Timo Sirainen [Wed, 19 Jul 2017 07:37:25 +0000 (10:37 +0300)] 
cassandra: Fix read/write buffer overflows after adding CASSANDRA_QUERY_TYPE_READ_MORE

8 years agolib-sql: Add assert to sql_result_more_s()
Timo Sirainen [Wed, 19 Jul 2017 07:35:43 +0000 (10:35 +0300)] 
lib-sql: Add assert to sql_result_more_s()

Should avoid a warning from static analyzer.

8 years agovirtual: Stop watching notification on backend box close
Aki Tuomi [Wed, 19 Jul 2017 09:03:58 +0000 (12:03 +0300)] 
virtual: Stop watching notification on backend box close

Fixes Panic: file mail-index.c: line 662 (mail_index_close_nonopened): assertion failed: (index->views == NULL)

8 years agovirtual: Stop notifications only if they were started
Aki Tuomi [Tue, 18 Jul 2017 18:04:47 +0000 (21:04 +0300)] 
virtual: Stop notifications only if they were started

Fixes Panic: file mail-storage.c: line 1950: assertion failed: (box->opened)

8 years agopop3-migration: Add unit test for checking that trailing tabs are stripped
Timo Sirainen [Wed, 19 Jul 2017 07:58:43 +0000 (10:58 +0300)] 
pop3-migration: Add unit test for checking that trailing tabs are stripped

8 years agolib-mail: message_header_hash() - add v4 that strips tabs
Timo Sirainen [Wed, 19 Jul 2017 07:57:36 +0000 (10:57 +0300)] 
lib-mail: message_header_hash() - add v4 that strips tabs

This helps with Zimbra, which strips away trailing tabs in BODY[HEADER].

8 years agolib-index: Mark index deleted if index log file is missing
Aki Tuomi [Tue, 18 Jul 2017 11:37:53 +0000 (14:37 +0300)] 
lib-index: Mark index deleted if index log file is missing

This fixes all kinds of errors caused by mailbox being
deleted by another process.

8 years agolib-index: Fix mail_index_get_modification_time() to work when index isn't open.
Timo Sirainen [Tue, 18 Jul 2017 11:42:23 +0000 (14:42 +0300)] 
lib-index: Fix mail_index_get_modification_time() to work when index isn't open.

index->filepath may be NULL after a failed index open, and it's a bit unsafe
to trust that index->log->filepath isn't NULL either.  So just build the full
path from elements that are definitely non-NULL.

Also stat() only dovecot.index.log, because it's always supposed to exist.
If it doesn't, something's broken and stat()ing dovecot.index doesn't make
much sense.

This commit removes mail_transaction_log_get_mtime(), which is no longer
needed.

Fixes:
Panic: file mail-index.c: line 931 (mail_index_file_set_syscall_error): assertion failed: (filepath != NULL)

8 years agolib-storage: Don't allow removing \Recent flags with mail_update_flags()
Timo Sirainen [Tue, 18 Jul 2017 09:39:44 +0000 (12:39 +0300)] 
lib-storage: Don't allow removing \Recent flags with mail_update_flags()

Reverts an ancient commit 7deb24e7453249d09741641bff0f269f68165033. I don't
know why it was added in the first place. Normally \Recent flags are
removed during sync with MAIL_INDEX_SYNC_FLAG_DROP_RECENT. This should be
enough, especially since it's not even possible to remove a single \Recent
flag - only update the first_recent_uid.

The code was also wrong: It was dropping \Recent flags even when
modify_type/flags combination didn't ask for it. Even if this was fixed,
there would still be race conditions with multiple processes since this
update is done without locking.

Fixes:
Error: Recent flags state corrupted for mailbox

8 years agolib-storage: If mail_index_header.first_recent_uid shrinks, reset \Recent flags
Timo Sirainen [Tue, 18 Jul 2017 08:57:24 +0000 (11:57 +0300)] 
lib-storage: If mail_index_header.first_recent_uid shrinks, reset \Recent flags

This should never happen.

8 years agocassandra: Improve logging for multipage queries
Timo Sirainen [Mon, 17 Jul 2017 15:10:49 +0000 (18:10 +0300)] 
cassandra: Improve logging for multipage queries

warn_timeout is applied to both individual page requests as well as the sum
of all the page requests.

8 years agocassandra: Add page_size setting to enable paged results for queries
Timo Sirainen [Mon, 17 Jul 2017 14:54:07 +0000 (17:54 +0300)] 
cassandra: Add page_size setting to enable paged results for queries

8 years agocassandra: Add wrapper functions in preparation for following commits
Timo Sirainen [Mon, 17 Jul 2017 14:51:03 +0000 (17:51 +0300)] 
cassandra: Add wrapper functions in preparation for following commits

No functional changes. Shrinks the following commits.

8 years agodict-sql: Add support for sql_result_more()
Timo Sirainen [Mon, 17 Jul 2017 14:54:36 +0000 (17:54 +0300)] 
dict-sql: Add support for sql_result_more()

8 years agolib-sql: Add API support for asynchronously iterating over rows.
Timo Sirainen [Mon, 17 Jul 2017 11:22:35 +0000 (14:22 +0300)] 
lib-sql: Add API support for asynchronously iterating over rows.

sql_query() can already do an async lookup, but the full result needs
to be available immediately. This can be inefficient for large results.
Add a new SQL_RESULT_NEXT_MORE return value and sql_result_more() for
asynchronously requesting more results.

This changes the API a bit, but isn't done by default by any drivers yet.
Also callers that can't handle this are hopefully checking for "ret < 0",
which allows them to handle such an async-more request as an error
instead.

sql_result_next_row() will be changed to return enum in a separate commit to
keep backwards compatibility in v2.2.x.

8 years agoimapc: Fix caching >= 32 kB mail bodies
Timo Sirainen [Mon, 17 Jul 2017 11:05:45 +0000 (14:05 +0300)] 
imapc: Fix caching >= 32 kB mail bodies

When closing the mail, only in-memory mail bodies were stored to cache.

8 years agolib-index: Add missing colon to log text
Aki Tuomi [Mon, 17 Jul 2017 07:46:14 +0000 (10:46 +0300)] 
lib-index: Add missing colon to log text

It's added elsewhere

8 years agomaster: Change service "connections are being dropped" warning interval to 1 second
Timo Sirainen [Fri, 14 Jul 2017 14:00:21 +0000 (17:00 +0300)] 
master: Change service "connections are being dropped" warning interval to 1 second

When this is happening, it's often accompanied with all kinds of other errors and
these warnings drown in them. Make them easier to notice by reducing the interval
from 60 seconds to 1 second.

8 years agolib-storage: mailbox_create_missing_dir() - Fix handling NULL mailbox directory
Timo Sirainen [Thu, 13 Jul 2017 13:20:53 +0000 (16:20 +0300)] 
lib-storage: mailbox_create_missing_dir() - Fix handling NULL mailbox directory

It would have caused stat(NULL), which would have failed.
Broken by 7071a02a8413fb409ade1625f6a1763c7493b66b

8 years agolib-storage: When index dir rmdir() fails with ENOTEMPTY, retry it for 1 second
Timo Sirainen [Thu, 13 Jul 2017 23:11:56 +0000 (02:11 +0300)] 
lib-storage: When index dir rmdir() fails with ENOTEMPTY, retry it for 1 second

This helps to avoid leaving those index directories lying around with NFS.
Hopefully within the 1 second any existing processes that have been keeping those
files open have finished their task. Especially IMAP IDLE will take 0.5 seconds
to start syncing indexes and realize that they're deleted.

8 years agolib-index: If refreshing finds dovecot.index.log gone, assume the mailbox was deleted
Timo Sirainen [Thu, 13 Jul 2017 22:54:31 +0000 (01:54 +0300)] 
lib-index: If refreshing finds dovecot.index.log gone, assume the mailbox was deleted

Don't try to recreate the log file again. It can just cause further problems.

A way to reproduce this problem with NFS when INDEX dir is specified:
 * create mailbox foo, select foo, IDLE
 * delete mailbox foo
--> foo's index is recreated back by IDLEing process

8 years agoquota: Fix negative storage-based quota_warnings to work with count backend
Timo Sirainen [Thu, 13 Jul 2017 00:15:36 +0000 (03:15 +0300)] 
quota: Fix negative storage-based quota_warnings to work with count backend

Finishes f9362223346d10a5866b376ed227b77b26ea4292, which fixed it for
"messages" but not for "storage".

8 years agoquota: When setting auto_updating to transaction, skip invisible quota roots
Timo Sirainen [Wed, 12 Jul 2017 23:56:33 +0000 (02:56 +0300)] 
quota: When setting auto_updating to transaction, skip invisible quota roots

Skip the quota root also if the mailbox matches "ignore" quota_rule.
This is only an optimization fix so that unnecessary work isn't done for
quota roots that aren't actually used.

8 years agolib-storage: mailbox_create_missing_dir() - Handle mailbox delete race condition
Timo Sirainen [Wed, 12 Jul 2017 13:18:42 +0000 (16:18 +0300)] 
lib-storage: mailbox_create_missing_dir() - Handle mailbox delete race condition

Make sure the directory isn't created if the mail root directory no longer
exists. This might happen during mailbox deletion when another process is
opening the mailbox at the same time.

8 years agolib-storage: Improve MAILBOX_LIST_PROP_AUTOCREATE_DIRS related comments
Timo Sirainen [Wed, 12 Jul 2017 13:15:13 +0000 (16:15 +0300)] 
lib-storage: Improve MAILBOX_LIST_PROP_AUTOCREATE_DIRS related comments

8 years agolib-lda: Fix crash if syncing save destination mailbox fails
Timo Sirainen [Sun, 9 Jul 2017 08:31:44 +0000 (11:31 +0300)] 
lib-lda: Fix crash if syncing save destination mailbox fails

8 years agolib-index: Fix compiler warning with 32bit time_t
Timo Sirainen [Wed, 12 Jul 2017 14:54:44 +0000 (17:54 +0300)] 
lib-index: Fix compiler warning with 32bit time_t

8 years agolib-index: Track .log.2 rotation time in index header
Timo Sirainen [Tue, 11 Jul 2017 12:35:16 +0000 (15:35 +0300)] 
lib-index: Track .log.2 rotation time in index header

This avoids unnecessarily stat()ing the file. Also it's a bit better
since it's tracking the actual rotation time, not the mtime of what the
.log file happened to have at the time of rotation.

The initial rotation timestamp is written only to the dovecot.index header
without going through dovecot.index.log. This works, because the
dovecot.index is written practically always after a log rotation. For the
rare cases when it doesn't happen, the dovecot.index.log.2 just gets
deleted later after the next log rotation.

8 years agolib-index: Check .log.2 rotation only when syncing
Timo Sirainen [Tue, 11 Jul 2017 12:33:56 +0000 (15:33 +0300)] 
lib-index: Check .log.2 rotation only when syncing

Instead of also whenever appending transactions to .log file. This
shouldn't change the behavior much, and it's needed for the following
change to work correctly.

8 years agodoveadm dump: Include "last temp file scan" in index header dump
Timo Sirainen [Tue, 11 Jul 2017 12:32:33 +0000 (15:32 +0300)] 
doveadm dump: Include "last temp file scan" in index header dump

8 years agolib-index: Use nfs_safe_stat() to avoid having to handle stat() ESTALE error
Timo Sirainen [Tue, 11 Jul 2017 11:31:10 +0000 (14:31 +0300)] 
lib-index: Use nfs_safe_stat() to avoid having to handle stat() ESTALE error

Slightly simplifies the code.

8 years agolib-http: message parser: Allow duplicate date header if HTTP_MESSAGE_PARSE_FLAG_STRI...
Stephan Bosch [Tue, 11 Jul 2017 12:34:06 +0000 (14:34 +0200)] 
lib-http: message parser: Allow duplicate date header if HTTP_MESSAGE_PARSE_FLAG_STRICT is not set.

The last instance of the date header is used.

8 years agolib-http: Restructured the header, message, request, and response parsers to have...
Stephan Bosch [Tue, 11 Jul 2017 12:18:47 +0000 (14:18 +0200)] 
lib-http: Restructured the header, message, request, and response parsers to have an extensible and consistent API using flags.

Extended the test suites with a few cases that test parsing with and without the STRICT flag.

8 years agosdbox: Create missing mail directory on resync if index directory exists
Timo Sirainen [Tue, 11 Jul 2017 11:14:47 +0000 (14:14 +0300)] 
sdbox: Create missing mail directory on resync if index directory exists

This problem should be visible only with ITERINDEX enabled.

8 years agolib: Created basic test suite for ostream-buffer.
Stephan Bosch [Sun, 2 Jul 2017 10:05:36 +0000 (12:05 +0200)] 
lib: Created basic test suite for ostream-buffer.

8 years agolib-storage: Remove user namespaces on hook error
Aki Tuomi [Tue, 11 Jul 2017 07:45:16 +0000 (10:45 +0300)] 
lib-storage: Remove user namespaces on hook error

If there is a hook error during namespaces added
remove the namespaces from user. This avoids attempts
to use the namespaces later on without proper initialization.

8 years agolib-storage: Ensure list index is present
Aki Tuomi [Tue, 11 Jul 2017 07:26:38 +0000 (10:26 +0300)] 
lib-storage: Ensure list index is present

Otherwise we end up with signal 11 crash later on.

8 years agolib-ssl-iostream: Fix compiler warning
Timo Sirainen [Fri, 7 Apr 2017 06:23:01 +0000 (09:23 +0300)] 
lib-ssl-iostream: Fix compiler warning

~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS makes it unsigned, so it doesn't fit
into signed 32bit long.