]> git.ipfire.org Git - thirdparty/dovecot/core.git/log
thirdparty/dovecot/core.git
8 years agodirector: Run director/host changing doveadm commands only after ring is synced
Timo Sirainen [Fri, 18 Aug 2017 08:51:36 +0000 (11:51 +0300)] 
director: Run director/host changing doveadm commands only after ring is synced

If the ring sync is still pending, the doveadm command may become reverted.
This doesn't fully prevent problems caused by sending doveadm commands
simultaneously to multiple directors, but it should prevent issues when
only a single director is used for doveadm commands.

It would have been nice to enable this also for HOST/DIRECTOR-LIST commands,
but they don't support returning a ring timeout error without changing the
protocol. It's a bit too much effort to change that for now.

8 years agodirector: doveadm HOST-* commands now wait for ring sync before returning OK
Timo Sirainen [Mon, 14 Aug 2017 07:29:47 +0000 (10:29 +0300)] 
director: doveadm HOST-* commands now wait for ring sync before returning OK

This should make it easier for tests and maybe for scripts in general, so
they won't think the command failed when it just takes a while to finish.

8 years agodirector: Cleanup - Doveadm commands now return enum doveadm_director_cmd_ret
Timo Sirainen [Mon, 14 Aug 2017 07:06:34 +0000 (10:06 +0300)] 
director: Cleanup - Doveadm commands now return enum doveadm_director_cmd_ret

8 years agodirector: Cleanup - Move all doveadm commands into an array.
Timo Sirainen [Mon, 14 Aug 2017 07:01:01 +0000 (10:01 +0300)] 
director: Cleanup - Move all doveadm commands into an array.

8 years agomdbox: Use mail_storage_set_index_error() instead of poorly duplicating it
Timo Sirainen [Mon, 21 Aug 2017 12:44:41 +0000 (15:44 +0300)] 
mdbox: Use mail_storage_set_index_error() instead of poorly duplicating it

8 years agolib-storage: Add mail_storage_set_index_error()
Timo Sirainen [Mon, 21 Aug 2017 12:34:40 +0000 (15:34 +0300)] 
lib-storage: Add mail_storage_set_index_error()

8 years agolib-storage: index_mail_set_cache_corrupted() - Don't reset internal error string
Timo Sirainen [Mon, 21 Aug 2017 12:29:46 +0000 (15:29 +0300)] 
lib-storage: index_mail_set_cache_corrupted() - Don't reset internal error string

It's already set correctly by the earlier functions.

8 years agolib-storage: mail_set_mail_cache_corrupted() - set also internal error string
Timo Sirainen [Mon, 21 Aug 2017 12:27:48 +0000 (15:27 +0300)] 
lib-storage: mail_set_mail_cache_corrupted() - set also internal error string

8 years agolib-storage: mailbox_set_index_error() - Set internal error string to index's error
Timo Sirainen [Mon, 21 Aug 2017 12:26:13 +0000 (15:26 +0300)] 
lib-storage: mailbox_set_index_error() - Set internal error string to index's error

8 years agolib-storage: Fix error logging after mail_storage_set_internal_error()
Timo Sirainen [Mon, 21 Aug 2017 12:11:30 +0000 (15:11 +0300)] 
lib-storage: Fix error logging after mail_storage_set_internal_error()

The function doesn't actually set the last_internal_error and it also
doesn't update last_error_is_internal, so calling
mail_storage_get_last_internal_error() afterwards could be returning an
error for some different older error.

Since there's no parameter to set the internal error string, just reset
last_error_is_internal=FALSE.

8 years agolib-index: Avoid opening .log.2 file if .log was reset
Timo Sirainen [Fri, 25 Aug 2017 12:12:06 +0000 (15:12 +0300)] 
lib-index: Avoid opening .log.2 file if .log was reset

After a reset there's no point in trying to read the older log files.
This avoids trying to open .log.2 at least for newly created mailboxes
when trying to lookup log file sequence 1 (since due to some bug/feature
the log files start from sequence 2).

8 years agolog: Log a warning for each service that still has processes at shutdown
Timo Sirainen [Thu, 24 Aug 2017 14:01:34 +0000 (17:01 +0300)] 
log: Log a warning for each service that still has processes at shutdown

This makes it clearer which services are causing log process to hang, and
also which processes may have their logging discarded afterwards.

8 years agolog: Include PID in prefix for internal log messages.
Timo Sirainen [Thu, 24 Aug 2017 14:00:30 +0000 (17:00 +0300)] 
log: Include PID in prefix for internal log messages.

8 years agomaster: Log "Processes aren't dying after reload" only when signals are sent
Timo Sirainen [Thu, 24 Aug 2017 13:31:40 +0000 (16:31 +0300)] 
master: Log "Processes aren't dying after reload" only when signals are sent

This required moving the warning after the "Sent SIG.. to .. processes"
warnings, which is a little bit annoying. However, now it's at least not
unnecessarily logging the warning when it's not doing anything about the
processes.

8 years agomaster: Improve killing processes when they don't die after reload
Timo Sirainen [Thu, 24 Aug 2017 13:24:21 +0000 (16:24 +0300)] 
master: Improve killing processes when they don't die after reload

The old behavior was:
1. Send SIGTERM to all processes, except log
2. Send SIGTERM to all processes, including log
3. Send SIGKILL to all processes, including log

The new behavior is now:
1. Send SIGTERM to all processes, except log
2. Send SIGKILL to all processes, except log

Only after there aren't any processes left except log, send SIGTERM to it.
If that doesn't work, send SIGKILL.

8 years agopop3-migration: Try to assign UIDLs based on dovecot.index.cache
Timo Sirainen [Fri, 25 Aug 2017 10:38:35 +0000 (13:38 +0300)] 
pop3-migration: Try to assign UIDLs based on dovecot.index.cache

Add the UIDLs to (imapc) mailbox cache after they've been assigned.
Try to read them from the cache on the next sync to avoid reading
mails' headers.

This can be disabled with pop3_migration_skip_uidl_cache=yes, just in case
there's some kind of a problem with it.

8 years agopop3-migration: Delete unnecessary POP3 order checking code
Timo Sirainen [Fri, 25 Aug 2017 10:36:11 +0000 (13:36 +0300)] 
pop3-migration: Delete unnecessary POP3 order checking code

Nothing is actually using the result.

8 years agolib-storage: Support LISTINDEX= to disable it
Timo Sirainen [Fri, 25 Aug 2017 10:16:26 +0000 (13:16 +0300)] 
lib-storage: Support LISTINDEX= to disable it

8 years agolib-settings: Escape comma in section name.
Sergey Kitov [Thu, 24 Aug 2017 07:01:02 +0000 (10:01 +0300)] 
lib-settings: Escape comma in section name.

Comma is valid symbol in encoded non-ascii section names, so it
shouldn't be used as splitting symbol in section name.

8 years agoquota plugin: restructure quota_root_get_rule_limits() 46/head
Josef 'Jeff' Sipek [Fri, 18 Aug 2017 12:29:09 +0000 (15:29 +0300)] 
quota plugin: restructure quota_root_get_rule_limits()

If the user has unlimited quota, we have no reason to find the real
mailbox name.

8 years agoapparmor: Call super deinit function
Aki Tuomi [Wed, 23 Aug 2017 10:14:50 +0000 (13:14 +0300)] 
apparmor: Call super deinit function

Otherwise user won't get properly deinitialized, forgotten in
a7a0f3196b2b97577ebd9e804507d58e67508fcf

8 years agolib-storage: Call mail_cache_close_mail() when mail is closed
Timo Sirainen [Fri, 18 Aug 2017 14:38:34 +0000 (17:38 +0300)] 
lib-storage: Call mail_cache_close_mail() when mail is closed

Fixes caching problems with INDEX=MEMORY

8 years agolib-index: Add mail_cache_close_mail() to smartly drop cached data with INDEX=MEMORY
Timo Sirainen [Fri, 18 Aug 2017 14:34:14 +0000 (17:34 +0300)] 
lib-index: Add mail_cache_close_mail() to smartly drop cached data with INDEX=MEMORY

Instead of reseting the entire transaction buffer when 256 kB is reached,
just drop mails have have been marked closed with mail_cache_close_mail().
If that's not enough, continue deleting forcibly until the buffer is below
256 kB.

This is especially important when mail_prefetch_count>0 and INDEX=MEMORY.
In that case there can be multiple mails that are being added to cache
and used later on. If they were dropped from cache too early, the work
would have to be done all over again.

8 years agodoveadm: Actually use resolved IP address(es) in director flush
Aki Tuomi [Fri, 18 Aug 2017 11:58:37 +0000 (14:58 +0300)] 
doveadm: Actually use resolved IP address(es) in director flush

It left the IP variable unitialized which caused host parameter
to be left empty causing flush all. Flushing with IP address
was not affected.

8 years agodoveadm-server: Deinitialize print on connection destroy
Aki Tuomi [Fri, 18 Aug 2017 08:22:52 +0000 (11:22 +0300)] 
doveadm-server: Deinitialize print on connection destroy

Otherwise print remains initialized and can break when reusing the service.

8 years agodirector: Fix rapid reconnection on failed outgoing connections
Timo Sirainen [Fri, 18 Aug 2017 08:09:41 +0000 (11:09 +0300)] 
director: Fix rapid reconnection on failed outgoing connections

last_network_failure wasn't set, which caused a failed outgoing connection
to immediately reconnect to it. This resulted in rapid logging of
connect() errors.

8 years agoglobal: Add/change switch case "fall through" comments
Timo Sirainen [Thu, 17 Aug 2017 10:20:26 +0000 (13:20 +0300)] 
global: Add/change switch case "fall through" comments

These fix warnings with gcc 7's -Wimplicit-fallthrough

8 years agolib: Add missing parenthesis to timeout_add()'s msecs parameter checks
Timo Sirainen [Thu, 17 Aug 2017 11:42:07 +0000 (14:42 +0300)] 
lib: Add missing parenthesis to timeout_add()'s msecs parameter checks

This caused wrong results when the msecs parameter contained e.g. var?1:2

8 years agolib: Fix compiler warning about mixing boolean with multiplication
Timo Sirainen [Thu, 17 Aug 2017 10:14:16 +0000 (13:14 +0300)] 
lib: Fix compiler warning about mixing boolean with multiplication

8 years agodoveadm mcp keypair generate: Fix -f parameter
Timo Sirainen [Thu, 17 Aug 2017 11:17:46 +0000 (14:17 +0300)] 
doveadm mcp keypair generate: Fix -f parameter

8 years agovirtual: Make sure sync_mailbox_idx isn't used uninitialized
Timo Sirainen [Mon, 24 Jul 2017 11:40:31 +0000 (14:40 +0300)] 
virtual: Make sure sync_mailbox_idx isn't used uninitialized

Changing its indexes to start from 1, we can add an assert to check that
it's never the default 0 when we need to use it.

8 years agoapparmor: Add apparmor plugin
Aki Tuomi [Thu, 13 Jul 2017 07:02:26 +0000 (10:02 +0300)] 
apparmor: Add apparmor plugin

It lets dovecot temporarily switch to a new apparmor
context for a user.

8 years agodirector: Make sure users gets expired even on an idle director
Timo Sirainen [Thu, 10 Aug 2017 14:50:04 +0000 (17:50 +0300)] 
director: Make sure users gets expired even on an idle director

Normally expiring gets done while looking up users, but if nothing is doing
that on an idle director the users won't get expired. This can cause confusion
in "doveadm director status" output.

8 years agopush-notification plugin: properly terminate strings
Michael Koch [Wed, 16 Aug 2017 10:53:55 +0000 (13:53 +0300)] 
push-notification plugin: properly terminate strings

Without this fix, if the new message does not contain a from, a subject, and
a snippet the generated JSON will be malformed (the status check at the end
appended a '"' when it shouldn't have).

8 years agoauth: auth_request_log_unknown_user() to call common auth_request_log_login_failure()
Sergey Kitov [Tue, 15 Aug 2017 08:09:07 +0000 (11:09 +0300)] 
auth: auth_request_log_unknown_user() to call common auth_request_log_login_failure()

Separate implementation of auth_request_log_unknown_user() is
replaced with call to auth_request_log_login_failure()
NOTE: behavior of the auth_request_log_unknown_user() is changed and
is in line with auth_request_log_password_mismatch()

8 years agoauth: auth_request_log_password_mismatch() to call common auth_request_log_login_fail...
Sergey Kitov [Tue, 15 Aug 2017 08:07:46 +0000 (11:07 +0300)] 
auth: auth_request_log_password_mismatch() to call common auth_request_log_login_failure()

Separate implementation of auth_request_log_password_mismatch() is
replaced with call to auth_request_log_login_failure()

8 years agoauth: ldap auth bind password mismatch logging is changed
Sergey Kitov [Tue, 15 Aug 2017 08:06:58 +0000 (11:06 +0300)] 
auth: ldap auth bind password mismatch logging is changed

All unknown user and password mismatch logging is performed in the
same way in both auth_bind = yes and auth_bind = no cases.

8 years agoauth: Added auth_request_log_login_failure()
Sergey Kitov [Tue, 15 Aug 2017 06:27:09 +0000 (09:27 +0300)] 
auth: Added auth_request_log_login_failure()

New function implementing functionality of auth_request_log_unknown_user() and auth_request_log_password_mismatch()

8 years agocassandra: Fix confusing debug logging for paged query results.
Timo Sirainen [Mon, 14 Aug 2017 12:44:24 +0000 (15:44 +0300)] 
cassandra: Fix confusing debug logging for paged query results.

Even when caller supported paged queries, the debug output contained
"Paged query has more results, but not supported by the caller".
Clear out the error after sql_result_more() is called, so it won't be
logged.

8 years agoauth: Do not use strcasecmp to compare mechanisms
Aki Tuomi [Fri, 28 Jul 2017 09:35:07 +0000 (12:35 +0300)] 
auth: Do not use strcasecmp to compare mechanisms

This is optimization since strcasecmp is slow

8 years agoauth: Empty schemes cannot be aliases
Aki Tuomi [Fri, 28 Jul 2017 07:20:17 +0000 (10:20 +0300)] 
auth: Empty schemes cannot be aliases

Optimizes cases where empty scheme is compared to PLAIN

8 years agoauth: Use strchr to split encoding and scheme
Aki Tuomi [Mon, 14 Aug 2017 11:48:05 +0000 (14:48 +0300)] 
auth: Use strchr to split encoding and scheme

This is an optimization because usually strchr is faster

8 years agoauth: Use hash table for schemes
Aki Tuomi [Fri, 28 Jul 2017 07:09:06 +0000 (10:09 +0300)] 
auth: Use hash table for schemes

8 years agolib: Add strfastcase_hash
Aki Tuomi [Fri, 28 Jul 2017 06:47:09 +0000 (09:47 +0300)] 
lib: Add strfastcase_hash

Fast case-insensitive hashing which works by masking signed
bytes with 0x20.

8 years agolib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen [Tue, 8 Aug 2017 13:56:02 +0000 (16:56 +0300)] 
lib-index: Fix wrong mail_index_modseq_header automatically

It happens only on the next sync, although that isn't actually guaranteed to
happen. Still, it happens almost always so this should be good enough.

8 years agolib-index: Code cleanup - move code to get_modseq_next_offset_at()
Timo Sirainen [Tue, 8 Aug 2017 13:54:42 +0000 (16:54 +0300)] 
lib-index: Code cleanup - move code to get_modseq_next_offset_at()

In preparation for making the next commit smaller.

8 years agolib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and...
Timo Sirainen [Tue, 8 Aug 2017 11:55:48 +0000 (14:55 +0300)] 
lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()

8 years agolib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen [Tue, 8 Aug 2017 11:01:18 +0000 (14:01 +0300)] 
lib-index: Add unit test to mail_transaction_update_modseq()

8 years agolib-index: Remove tracking of mail_index_modseq_sync.highest_modseq
Timo Sirainen [Sat, 5 Aug 2017 05:38:50 +0000 (14:38 +0900)] 
lib-index: Remove tracking of mail_index_modseq_sync.highest_modseq

It's no longer necessary after the previous changes.

8 years agolib-index: Fix setting highest_modseq correctly in mail_index_modseq_header
Timo Sirainen [Sat, 5 Aug 2017 05:33:12 +0000 (14:33 +0900)] 
lib-index: Fix setting highest_modseq correctly in mail_index_modseq_header

The internally counted ctx->highest_modseq wasn't correct if all of the
records weren't synced. This could have happened for various reasons.
Since the view's current log seq/offset is used for the header, we can
also use the current highest_modseq from the view as well and it's
guaranteed to be correct.

This fixes various potential problems with using QRESYNC and CONDSTORE
extensions. It also fixes potential errors with unhibernating imap
clients, including:

Error: .../dovecot.index.log: Transaction log changed unexpectedly, can't get modseq

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.