]> git.ipfire.org Git - thirdparty/dovecot/core.git/log
thirdparty/dovecot/core.git
7 years agoauth: Use correct username is auth policy requests
Aki Tuomi [Mon, 5 Feb 2018 12:26:15 +0000 (14:26 +0200)] 
auth: Use correct username is auth policy requests

When doing master authentication as first, use
the username of the user, not master user, for policy lookup.

7 years agolib-ssl-iostream: Assert-crash if input stream has IO already set
Timo Sirainen [Thu, 8 Feb 2018 00:26:23 +0000 (02:26 +0200)] 
lib-ssl-iostream: Assert-crash if input stream has IO already set

7 years agolib: Add i_stream_get_root_io() and use it to deduplicate code
Timo Sirainen [Thu, 8 Feb 2018 00:22:18 +0000 (02:22 +0200)] 
lib: Add i_stream_get_root_io() and use it to deduplicate code

7 years agolib-smtp: Recreate connection IO after streams change
Timo Sirainen [Thu, 8 Feb 2018 08:53:50 +0000 (10:53 +0200)] 
lib-smtp: Recreate connection IO after streams change

This fixes hangs after STARTTLS.

Originally by Stephan Bosch

7 years agolib: Add connection_streams_changed()
Timo Sirainen [Thu, 8 Feb 2018 08:52:57 +0000 (10:52 +0200)] 
lib: Add connection_streams_changed()

Originally by Stephan Bosch

7 years agodoveadm: client: Set IO only after enabling SSL
Timo Sirainen [Thu, 8 Feb 2018 00:38:23 +0000 (02:38 +0200)] 
doveadm: client: Set IO only after enabling SSL

io_add_istream() needs to be used with the SSL istream, otherwise it can
cause hangs.

7 years agolib-imap-client: Fix IO after enabling SSL
Timo Sirainen [Thu, 8 Feb 2018 00:28:54 +0000 (02:28 +0200)] 
lib-imap-client: Fix IO after enabling SSL

io_add_istream() needs to be used with the SSL istream, otherwise it can
cause hangs.

7 years agoreplication: Don't send notification for changes done by dsync transactions
Timo Sirainen [Tue, 6 Feb 2018 13:12:26 +0000 (15:12 +0200)] 
replication: Don't send notification for changes done by dsync transactions

7 years agolib-storage: Set mailbox_transaction_context.flags earlier
Timo Sirainen [Tue, 6 Feb 2018 13:10:48 +0000 (15:10 +0200)] 
lib-storage: Set mailbox_transaction_context.flags earlier

Set it in index_transaction_init() so plugins' transaction_begin() methods
see it after calling super.transaction_begin().

7 years agoold-stats: Set process dumpable during stats gathering
Aki Tuomi [Thu, 8 Feb 2018 11:04:48 +0000 (13:04 +0200)] 
old-stats: Set process dumpable during stats gathering

/proc/self/io is not accessible otherwise

7 years agolib: Add restrict_access_get/set_dumpable
Aki Tuomi [Thu, 8 Feb 2018 11:03:37 +0000 (13:03 +0200)] 
lib: Add restrict_access_get/set_dumpable

7 years agolib: Clarify restrict_access_allow_coredumps
Aki Tuomi [Thu, 8 Feb 2018 11:01:50 +0000 (13:01 +0200)] 
lib: Clarify restrict_access_allow_coredumps

7 years agolib-index: Fix assert-crash with lock_method=dotlock
Timo Sirainen [Wed, 7 Feb 2018 14:17:13 +0000 (16:17 +0200)] 
lib-index: Fix assert-crash with lock_method=dotlock

The dotlock wasn't deleted in all code paths. Fix this by simplifying
the unlocking to be done the same way with and without dotlock.

Fixes:
Panic: file mail-cache.c: line 624 (mail_cache_lock_file): assertion failed: (cache->dotlock == NULL)

7 years agolib-storage: Lock mailbox_list for mailbox create/delete/rename
Timo Sirainen [Tue, 9 Jan 2018 20:37:25 +0000 (15:37 -0500)] 
lib-storage: Lock mailbox_list for mailbox create/delete/rename

This is only required for mailbox creation to fix a race condition with
LAYOUT=index: If INBOX doesn't exist it will rescan the mailboxes to
find out if there are any missing ones. If INBOX creation isn't locked,
it's possible that the first process hasn't finished creating INBOX
before the second process find it and attempts to open it.

The delete and rename locking are probably useful to guard against race
conditions when clients intentionally issues create/delete/rename commands
concurrently.

7 years agolib-storage: Add mailbox_list_[un]lock()
Timo Sirainen [Tue, 9 Jan 2018 20:36:58 +0000 (15:36 -0500)] 
lib-storage: Add mailbox_list_[un]lock()

7 years agolib-storage: mailbox_delete() - Fix cleanup in error handling
Timo Sirainen [Tue, 9 Jan 2018 20:35:13 +0000 (15:35 -0500)] 
lib-storage: mailbox_delete() - Fix cleanup in error handling

If removing index deletion mark failed, box->deleting wasn't set to FALSE
and the mailbox was left opened.

7 years agolib-storage: mailbox_rename() - Use source storage for errors
Timo Sirainen [Tue, 9 Jan 2018 20:33:26 +0000 (15:33 -0500)] 
lib-storage: mailbox_rename() - Use source storage for errors

It was documented to use source storage for errors, but some of the errors
were set to destination storage.

7 years agolib-storage: mail_storage_lock_create() - add support for dotlocks
Timo Sirainen [Tue, 6 Feb 2018 16:01:04 +0000 (18:01 +0200)] 
lib-storage: mail_storage_lock_create() - add support for dotlocks

7 years agolib-storage: Change mail_user_lock_file_create() to use mail_storage_lock_create()
Timo Sirainen [Tue, 6 Feb 2018 15:49:15 +0000 (17:49 +0200)] 
lib-storage: Change mail_user_lock_file_create() to use mail_storage_lock_create()

7 years agolib-storage: Add mail_storage_lock_create()
Timo Sirainen [Tue, 6 Feb 2018 15:47:37 +0000 (17:47 +0200)] 
lib-storage: Add mail_storage_lock_create()

This is split off of mailbox_lock_file_create().

7 years agolib: Add file_lock_from_dotlock()
Timo Sirainen [Tue, 6 Feb 2018 15:35:18 +0000 (17:35 +0200)] 
lib: Add file_lock_from_dotlock()

The dotlock creation requires various settings, so the file-lock.h API can't
easily be used to create it. But once created, it's simpler to keep all lock
types in the same struct file_lock, which can be unlocked/freed once
finished.

7 years agolib-smtp: server: Fix assertion failure occurring for a second failed BDAT/BURL command.
Stephan Bosch [Mon, 25 Dec 2017 23:38:58 +0000 (00:38 +0100)] 
lib-smtp: server: Fix assertion failure occurring for a second failed BDAT/BURL command.

Assertion was:

Panic: file smtp-server-cmd-data.c: line 420 (smtp_server_connection_data_chunk_init): assertion failed: (data_cmd->chunk_first)

7 years agosubmission: EHLO command: Remove obsolete pending_ehlo handling.
Stephan Bosch [Wed, 27 Dec 2017 13:38:41 +0000 (14:38 +0100)] 
submission: EHLO command: Remove obsolete pending_ehlo handling.

This was used to wait with sending an EHLO reply until the proxy connection to the relay server completes.
The previous commit made this functionality obsolete, since command input handling is blocked entirely until the proxy connection is ready.

7 years agosubmission: Block server input handling until proxy connection to relay server completes.
Stephan Bosch [Wed, 27 Dec 2017 13:36:10 +0000 (14:36 +0100)] 
submission: Block server input handling until proxy connection to relay server completes.

This makes sure we are aware of the full extent of the backend server's capabilities, before we start handling commands.
Before, only EHLO commands were blocked this way, but this did not account for MAIL/RCPT parameters, which are equally dependent.
Fixes problems with clients that send no EHLO after AUTH, like Thunderbird.

7 years agolib-smtp: server: Add APIs for halting and resuming connection command handling.
Stephan Bosch [Wed, 27 Dec 2017 16:02:12 +0000 (17:02 +0100)] 
lib-smtp: server: Add APIs for halting and resuming connection command handling.

Also adds function to start the connection in a pending (halted) state. This way the greeting can already be sent (over SSL if needed), while deferring command handling until some external activity is completed.

7 years agolib-smtp: server: Prevent calling smtp_server_connection_login() after smtp_server_co...
Stephan Bosch [Wed, 27 Dec 2017 15:31:12 +0000 (16:31 +0100)] 
lib-smtp: server: Prevent calling smtp_server_connection_login() after smtp_server_connection_start().

Added assertion.

7 years agolib-smtp: server: Protect smpt_server_connection_start() from being called multiple...
Stephan Bosch [Wed, 27 Dec 2017 15:22:22 +0000 (16:22 +0100)] 
lib-smtp: server: Protect smpt_server_connection_start() from being called multiple times.

7 years agolib-smtp: server: Delay handling initial input (from login service) until after smtp_...
Stephan Bosch [Wed, 27 Dec 2017 15:18:16 +0000 (16:18 +0100)] 
lib-smtp: server: Delay handling initial input (from login service) until after smtp_server_connection_start().

Instead, it is now handled in normal io callback.

7 years agolib-smtp: server: Remove implicit smtp_server_connection_start() from smtp_server_con...
Stephan Bosch [Wed, 27 Dec 2017 14:56:03 +0000 (15:56 +0100)] 
lib-smtp: server: Remove implicit smtp_server_connection_start() from smtp_server_connection_login().

7 years agolib-smtp: server: Moved smtp_server_connection_start() after smtp_server_connection_l...
Stephan Bosch [Wed, 27 Dec 2017 14:59:23 +0000 (15:59 +0100)] 
lib-smtp: server: Moved smtp_server_connection_start() after smtp_server_connection_login().

Also fixes an indent problem in the header comment implicitly.

7 years agolib-smtp: server: Moved ssl_start argument from smtp_server_connection_start() to...
Stephan Bosch [Wed, 27 Dec 2017 14:52:13 +0000 (15:52 +0100)] 
lib-smtp: server: Moved ssl_start argument from smtp_server_connection_start() to smtp_server_connection_create().

This frees smtp_server_connection_start() for general use.

7 years agofs-posix: Fix iterating directories when readdir() returns DT_UNKNOWN
Timo Sirainen [Tue, 6 Feb 2018 10:37:34 +0000 (12:37 +0200)] 
fs-posix: Fix iterating directories when readdir() returns DT_UNKNOWN

Files were iterated correctly, but directories weren't. This mainly broke
directory iteration with NFS when nordirplus mount option was used.

7 years agofts: Don't reindex FTS mails if .cache file is deleted
Timo Sirainen [Mon, 5 Feb 2018 20:21:13 +0000 (22:21 +0200)] 
fts: Don't reindex FTS mails if .cache file is deleted

This means that if fts is enabled, "doveadm index" no longer adds mails
to dovecot.index.cache if it's deleted. However, it was rarely used for
that purpose. More likely due to a corrupted cache file all the mails were
unnecessarily being opened and reindexed.

7 years agocassandra: Make sure timestamp is always logged (if set) with debug_queries=y
Timo Sirainen [Wed, 7 Feb 2018 13:28:45 +0000 (15:28 +0200)] 
cassandra: Make sure timestamp is always logged (if set) with debug_queries=y

It wasn't logged in some code paths.

7 years agocassandra: Fix setting timestamp for transaction queries with v3 protocol
Timo Sirainen [Wed, 7 Feb 2018 13:27:07 +0000 (15:27 +0200)] 
cassandra: Fix setting timestamp for transaction queries with v3 protocol

It was working for prepared statements, but not for non-prepared statements.

7 years agofts: Fix searching headers with TEXT/BODY
Timo Sirainen [Mon, 5 Feb 2018 21:54:33 +0000 (23:54 +0200)] 
fts: Fix searching headers with TEXT/BODY

TEXT is searching headers and BODY is searching MIME headers. Those headers
were indexed with data language, so search must also include data language
when looking up words. We'll just include the data language for all
searches now, so it should always work correctly.

7 years agofts: Fix searching SEARCH_HEADER_ADDRESS/COMPRESS_LWSP
Timo Sirainen [Mon, 5 Feb 2018 21:51:51 +0000 (23:51 +0200)] 
fts: Fix searching SEARCH_HEADER_ADDRESS/COMPRESS_LWSP

These are "non-language" headers that are being searched, so they need to be
searched using data language.

7 years agolib-http: queue: Update the correct timout while dropping a request from the delay...
Stephan Bosch [Fri, 12 Jan 2018 20:03:41 +0000 (21:03 +0100)] 
lib-http: queue: Update the correct timout while dropping a request from the delay queue.

The absolute request timeout rather than the delay timeout was updated for the
removal of the request from the delay queue.

7 years agolib: time-util: Fix timeval_cmp_margin() to correctly handle a margin crossing the...
Stephan Bosch [Tue, 6 Feb 2018 14:50:19 +0000 (15:50 +0100)] 
lib: time-util: Fix timeval_cmp_margin() to correctly handle a margin crossing the second boundary.

The timeval_cmp_margin() function incorrectly assumed that the margin is
irrelevent when the tv_sec values are different.

7 years agolib: test-time-util: Put all test data for timeval_cmp() test in a single struct...
Stephan Bosch [Tue, 6 Feb 2018 15:51:23 +0000 (16:51 +0100)] 
lib: test-time-util: Put all test data for timeval_cmp() test in a single struct array.

7 years agosubmission: Add settings that configure the connect and command reply timeouts.
Stephan Bosch [Sat, 27 Jan 2018 22:20:08 +0000 (23:20 +0100)] 
submission: Add settings that configure the connect and command reply timeouts.

7 years agolib-smtp: client: Assign only connection settings during connection initialization.
Stephan Bosch [Fri, 19 Jan 2018 22:32:31 +0000 (23:32 +0100)] 
lib-smtp: client: Assign only connection settings during connection initialization.

Due to some copy-paste mistake, some global client settings were assigned
instead.

7 years agolib-smtp: client: Always use per-connection settings in connection.
Stephan Bosch [Fri, 19 Jan 2018 22:31:05 +0000 (23:31 +0100)] 
lib-smtp: client: Always use per-connection settings in connection.

Some part of the connection code referred to global client settings.

7 years agolib-smtp: client: Properly allow per-connection SSL configuration.
Stephan Bosch [Fri, 19 Jan 2018 15:05:18 +0000 (16:05 +0100)] 
lib-smtp: client: Properly allow per-connection SSL configuration.

Although this was already partially possible, the connection was still always
using the global client SSL context.

7 years agolib-smtp: client: Fix segfault occurring in connection when SSL certificate is invalid.
Stephan Bosch [Fri, 19 Jan 2018 13:44:50 +0000 (14:44 +0100)] 
lib-smtp: client: Fix segfault occurring in connection when SSL certificate is invalid.

The connection is using its own local SSL settings to determine whether an
invalid certificate is allowed. However, these local settings were not properly
initialized.

7 years agosubmission: Enable verbose reporting of relay server certificate problems.
Stephan Bosch [Mon, 22 Jan 2018 17:51:21 +0000 (18:51 +0100)] 
submission: Enable verbose reporting of relay server certificate problems.

7 years agoimap: Iterate over ns settings when deciding to add SPECIAL-USE capability
Josef 'Jeff' Sipek [Mon, 29 Jan 2018 14:55:51 +0000 (09:55 -0500)] 
imap: Iterate over ns settings when deciding to add SPECIAL-USE capability

To determine whether we should add the SPECIAL-USE capability to the
OK response to LOGIN, we have to iterate over namespace and mailbox
*settings* since the namespaces haven't been set up yet.

7 years agolib-storage: Fix adding body.snippet to cache
Timo Sirainen [Thu, 25 Jan 2018 10:27:41 +0000 (12:27 +0200)] 
lib-storage: Fix adding body.snippet to cache

Unless body.snippet was in mail_always_cache_fields, it didn't get added to
the cache file.

7 years agolib-storage: Add comment to how mail_cache_field_can/want_add() is used
Timo Sirainen [Thu, 25 Jan 2018 10:35:51 +0000 (12:35 +0200)] 
lib-storage: Add comment to how mail_cache_field_can/want_add() is used

7 years agolib-index: Update comments for mail_cache_decision_*()
Timo Sirainen [Thu, 25 Jan 2018 10:35:35 +0000 (12:35 +0200)] 
lib-index: Update comments for mail_cache_decision_*()

7 years agolib-mail: mail-html2text - Validate UCS4 codepoint
Aki Tuomi [Fri, 5 Jan 2018 07:51:00 +0000 (09:51 +0200)] 
lib-mail: mail-html2text - Validate UCS4 codepoint

Fixes: Panic: file unichar.c: line 160 (uni_ucs4_to_utf8_c): assertion failed: (uni_is_valid_ucs4(chr))
7 years agolib-imap-urlauth: Fix segfault occurring when userid part is missing for "user+"...
Stephan Bosch [Wed, 31 Jan 2018 21:14:49 +0000 (22:14 +0100)] 
lib-imap-urlauth: Fix segfault occurring when userid part is missing for "user+" or "submit+" URLAUTH access.

7 years agosubmission-login: Fail CLIENT_AUTH_RESULT_MECH_SSL_REQUIRED authentication result...
Stephan Bosch [Sat, 23 Dec 2017 22:49:02 +0000 (23:49 +0100)] 
submission-login: Fail CLIENT_AUTH_RESULT_MECH_SSL_REQUIRED authentication result with 523 5.7.10 error.

Defined in RFC5248, Section 2.4.

7 years agosubmission: BURL command: Return more appropriate 554 5.7.14 error when BURL/URLAUTH...
Stephan Bosch [Wed, 27 Dec 2017 14:18:14 +0000 (15:18 +0100)] 
submission: BURL command: Return more appropriate 554 5.7.14 error when BURL/URLAUTH is not configured.

Defined in RFC5248, Section 2.4.

7 years agolib-imap-client: continue imapc operation on parsing errors.
Sergey Kitov [Mon, 8 Jan 2018 09:38:37 +0000 (11:38 +0200)] 
lib-imap-client: continue imapc operation on parsing errors.

7 years agolib-storage: Set keyword based on attachment presence when saving
Aki Tuomi [Sat, 11 Nov 2017 08:07:42 +0000 (10:07 +0200)] 
lib-storage: Set keyword based on attachment presence when saving

If attachment is detected, use $HasAttachment, if not
use $HasNoAttachment

7 years agolib-storage: Add attachment detection settings
Aki Tuomi [Mon, 20 Nov 2017 08:09:23 +0000 (10:09 +0200)] 
lib-storage: Add attachment detection settings

7 years agolib-mail: Add message_part_has_attachment
Aki Tuomi [Fri, 10 Nov 2017 12:32:44 +0000 (14:32 +0200)] 
lib-mail: Add message_part_has_attachment

7 years agolib-smtp: client: Fix timeout leak sometimes occurring at unexpected remote disconnect.
Stephan Bosch [Sun, 28 Jan 2018 10:44:26 +0000 (11:44 +0100)] 
lib-smtp: client: Fix timeout leak sometimes occurring at unexpected remote disconnect.

While disconnected, newly submitted commands are queued, yet scheduled for
immediate failure. The timeout used for that was not cleaned up.

7 years agodovecot-config: Update lib-stats directory to lib-old-stats
Timo Sirainen [Wed, 27 Dec 2017 10:05:50 +0000 (12:05 +0200)] 
dovecot-config: Update lib-stats directory to lib-old-stats

7 years agosubmission-login: Fixed handling of ssl=required for trusted connections.
Stephan Bosch [Sat, 23 Dec 2017 18:40:09 +0000 (19:40 +0100)] 
submission-login: Fixed handling of ssl=required for trusted connections.

Normally, SSL is not required for trusted connections (e.g. localhost), but submission-login did not follow this standard.

7 years agosubmission: Restructure handling of QUIT command.
Stephan Bosch [Sun, 24 Dec 2017 14:12:36 +0000 (15:12 +0100)] 
submission: Restructure handling of QUIT command.

- Avoid explicitly proxying QUIT command when the proxy connection is not ready: in that case the SMTP client connection will just send QUIT if appropriate, without waiting for reply.
- Add timeout for proxied QUIT command, so that there are no problems when the relay server hangs after QUIT (addresses FIXME).

7 years agosubmission: Dropped unused field from struct client.
Stephan Bosch [Sun, 24 Dec 2017 13:52:07 +0000 (14:52 +0100)] 
submission: Dropped unused field from struct client.

7 years agosubmission-login: Fix pipelining of commands beyond AUTH.
Stephan Bosch [Sun, 24 Dec 2017 11:17:48 +0000 (12:17 +0100)] 
submission-login: Fix pipelining of commands beyond AUTH.

The master_data_prefix was initialized wrong; it omitted the expected '\0' byte after the helo field.

7 years agosubmission: Initialize proxy connection before starting the SMTP server connection.
Stephan Bosch [Sun, 24 Dec 2017 11:15:29 +0000 (12:15 +0100)] 
submission: Initialize proxy connection before starting the SMTP server connection.

The smtp_server_connection_login() function gets pre-login connection data from login service, which can contain commands.
The execution of commands expects the proxy connection object to be initialized.

7 years agolib-program-client: Make an explicit enum for the exit code.
Stephan Bosch [Fri, 26 Jan 2018 19:37:32 +0000 (20:37 +0100)] 
lib-program-client: Make an explicit enum for the exit code.

Before, the meaning of the code was confusing, since the actual program returns
a different set of values.

7 years agolib-program-client: local: Add test for big data I/O.
Stephan Bosch [Sat, 20 Jan 2018 20:32:07 +0000 (21:32 +0100)] 
lib-program-client: local: Add test for big data I/O.

7 years agolib-program-client: Document the purpose of the use_dotstream setting.
Stephan Bosch [Wed, 24 Jan 2018 00:17:59 +0000 (01:17 +0100)] 
lib-program-client: Document the purpose of the use_dotstream setting.

7 years agolib-program-client: Add comments to program_input/program_output functions.
Stephan Bosch [Tue, 23 Jan 2018 20:14:18 +0000 (21:14 +0100)] 
lib-program-client: Add comments to program_input/program_output functions.

7 years agolib-program-client: Flush/finish the output stream after o_stream_send_istream().
Stephan Bosch [Mon, 22 Jan 2018 22:43:18 +0000 (23:43 +0100)] 
lib-program-client: Flush/finish the output stream after o_stream_send_istream().

There may still be data in the output stream buffer. Failing to flush this
leads to truncated output. For the output towards the program o_stream_finish()
is used, since there may be an ostream_dot in between (or something else for
future features).

7 years agolib-program-client: remote: Don't change exit_code in program_client_remote_disconnec...
Stephan Bosch [Wed, 24 Jan 2018 00:09:16 +0000 (01:09 +0100)] 
lib-program-client: remote: Don't change exit_code in program_client_remote_disconnect() when program_input is already NULL.

When the program_input is NULL, the stream is finished, meaning that the
exit_code is set based on the return code. There can be a program_input for
remote streams, even when the program produces no output.

7 years agolib-program-client: Simplify cleanup of dot input stream in program_client_program_in...
Stephan Bosch [Tue, 23 Jan 2018 20:38:27 +0000 (21:38 +0100)] 
lib-program-client: Simplify cleanup of dot input stream in program_client_program_input().

7 years agolib-program-client: Restructure reading input from program to simplify handling of...
Stephan Bosch [Tue, 23 Jan 2018 20:24:35 +0000 (21:24 +0100)] 
lib-program-client: Restructure reading input from program to simplify handling of dot input stream.

7 years agolib-program-client: Use reliable means of checking for input stream EOF.
Stephan Bosch [Mon, 22 Jan 2018 22:25:34 +0000 (23:25 +0100)] 
lib-program-client: Use reliable means of checking for input stream EOF.

7 years agolib-program-client: Remove check for -2 returned from i_stream_read_more().
Stephan Bosch [Wed, 24 Jan 2018 20:48:07 +0000 (21:48 +0100)] 
lib-program-client: Remove check for -2 returned from i_stream_read_more().

The stream must have space for at least 1 byte.

7 years agolib-program-client: Remove useless stream eof check.
Stephan Bosch [Tue, 23 Jan 2018 21:16:26 +0000 (22:16 +0100)] 
lib-program-client: Remove useless stream eof check.

It also looks to be problematic.

7 years agoimap: support for FETCH SNIPPET
Josef 'Jeff' Sipek [Thu, 4 Jan 2018 17:44:16 +0000 (12:44 -0500)] 
imap: support for FETCH SNIPPET

7 years agoimapc: Fix deleting mailbox
Timo Sirainen [Mon, 22 Jan 2018 11:33:29 +0000 (13:33 +0200)] 
imapc: Fix deleting mailbox

Broken by f8f30bd27e41e1041a8de0b97f35d7d75e0a412e

7 years agolib-auth: Remove request after abort
Aki Tuomi [Fri, 26 Jan 2018 08:55:54 +0000 (10:55 +0200)] 
lib-auth: Remove request after abort

Otherwise the request will still stay in hash table
and get dereferenced when all requests are aborted
causing an attempt to access free'd memory.

Found by Apollon Oikonomopoulos <apoikos@debian.org>

Broken in 1a29ed2f96da1be22fa5a4d96c7583aa81b8b060

7 years agolib-auth: Fix memory leak in auth_client_request_abort()
Timo Sirainen [Mon, 18 Dec 2017 14:50:51 +0000 (16:50 +0200)] 
lib-auth: Fix memory leak in auth_client_request_abort()

This caused memory leaks when authentication was aborted. For example
with IMAP:

a AUTHENTICATE PLAIN
*

Broken by 9137c55411aa39d41c1e705ddc34d5bd26c65021

7 years agolib-index: Write forced cache decision changes immediately to cache file
Timo Sirainen [Wed, 24 Jan 2018 16:01:48 +0000 (18:01 +0200)] 
lib-index: Write forced cache decision changes immediately to cache file

When mail_always/never_cache_fields doesn't match the current caching
decisions in the cache file, write the updated decisions to the file.

7 years agolib-index: Code cleanup for reading caching decisions
Timo Sirainen [Wed, 24 Jan 2018 16:01:23 +0000 (18:01 +0200)] 
lib-index: Code cleanup for reading caching decisions

No functional changes.

7 years agolib-index: Finish fixing removal of forced cache decisions from existing cache files
Timo Sirainen [Wed, 24 Jan 2018 15:58:57 +0000 (17:58 +0200)] 
lib-index: Finish fixing removal of forced cache decisions from existing cache files

6ef2504d020461b0f480766c41596595a4300023 didn't fix it for already known
fields.

7 years agolib-index: Fix removal of forced cache decisions from existing cache files
Timo Sirainen [Mon, 22 Jan 2018 22:04:28 +0000 (00:04 +0200)] 
lib-index: Fix removal of forced cache decisions from existing cache files

The forced-flags are written to the cache file when the file is created.
They were also read back, and the force-flag was preserved even when the
configuration was removed.

7 years agolib-index: Fix adding forced cache decisions to existing cache files
Timo Sirainen [Mon, 22 Jan 2018 15:38:32 +0000 (17:38 +0200)] 
lib-index: Fix adding forced cache decisions to existing cache files

If a field already existed in the cache file, the cache decision from the
file was always used. This caused force-decisions to be ignored.

7 years agoauth: passdb-cache - Verify credentials with worker when enabled
Aki Tuomi [Mon, 8 Jan 2018 13:08:10 +0000 (15:08 +0200)] 
auth: passdb-cache - Verify credentials with worker when enabled

7 years agoauth: Expose auth_request_verify_plain_callback_finish
Aki Tuomi [Mon, 8 Jan 2018 13:00:17 +0000 (15:00 +0200)] 
auth: Expose auth_request_verify_plain_callback_finish

7 years agoauth-worker: Support PASSW request
Aki Tuomi [Mon, 8 Jan 2018 13:09:28 +0000 (15:09 +0200)] 
auth-worker: Support PASSW request

This will attempt to verify given credentials.

7 years agoauth-worker: Add auth_worker_auth_request_new
Aki Tuomi [Mon, 8 Jan 2018 12:52:10 +0000 (14:52 +0200)] 
auth-worker: Add auth_worker_auth_request_new

Replaces worker_auth_request_new, moves in
check for username and service. Simplifies code.

7 years agoauth: passdb-blocking - Expose passdb_blocking_auth_worker_reply_parse
Aki Tuomi [Tue, 2 Jan 2018 10:33:50 +0000 (12:33 +0200)] 
auth: passdb-blocking - Expose passdb_blocking_auth_worker_reply_parse

Enables sharing code with passdb cache

7 years agoimapc: Fix imap_features=no-msn-updates to not fail on SELECT
Timo Sirainen [Tue, 16 Jan 2018 16:17:00 +0000 (18:17 +0200)] 
imapc: Fix imap_features=no-msn-updates to not fail on SELECT

The initial EXISTS reply shouldn't be ignored, only the following ones.

7 years agoimapc: Add imapc_features=no-msn-updates
Timo Sirainen [Mon, 25 Dec 2017 09:10:19 +0000 (11:10 +0200)] 
imapc: Add imapc_features=no-msn-updates

This is a stricter version of fetch-msn-workarounds. The MSNs aren't trusted
at all. This means any new untagged EXISTS and EXPUNGE replies are ignored,
as well as untagged FETCH replies that don't include UID.

A potential downside with this feature is that UID FETCH/STORE commands
sent to expunged messages will likely fail without the IMAP client being
notified of the EXPUNGEs. New mails are also not noticed, so this should
be used only when it's known that the clients don't keep the connection
open for long.

7 years agoimapc: Fix sending initial FETCH after reconnection SELECTs mailbox
Timo Sirainen [Mon, 25 Dec 2017 14:11:26 +0000 (16:11 +0200)] 
imapc: Fix sending initial FETCH after reconnection SELECTs mailbox

Move sending the FETCH when the SELECT returns tagged OK reply instead of
delaying it until mailbox is next synced. Most importantly this allows
sending the FETCH before any retried commands that are also sent after
SELECT receives tagged reply.

7 years agoimapc: gmail-migration: Fetch X-GM-MSGID for new mails as well
Timo Sirainen [Mon, 25 Dec 2017 20:48:00 +0000 (22:48 +0200)] 
imapc: gmail-migration: Fetch X-GM-MSGID for new mails as well

I'm not sure why it was originally restricted only for the initial FETCH.
Fetching GUIDs for new mails can be just as useful.

7 years agoimapc: Move imapc_mailbox_fetch_state*() to imapc-mailbox.c
Timo Sirainen [Mon, 25 Dec 2017 18:21:40 +0000 (20:21 +0200)] 
imapc: Move imapc_mailbox_fetch_state*() to imapc-mailbox.c

Mainly to make the next commit smaller.

7 years agoimapc: Handle untagged UIDVALIDITY immediately
Timo Sirainen [Mon, 25 Dec 2017 17:19:09 +0000 (19:19 +0200)] 
imapc: Handle untagged UIDVALIDITY immediately

This is part of the changes to fix mailbox resyncing after reconnect.

7 years agoimapc: If mailbox select fails, rollback any changes done to it
Timo Sirainen [Mon, 25 Dec 2017 17:34:31 +0000 (19:34 +0200)] 
imapc: If mailbox select fails, rollback any changes done to it

Required by the following changes that start adding changes immediately
after SELECT. If the initial syncing doesn't finish successfully, these
changes need to be reverted.

7 years agoimapc: Keep "selected" state TRUE only while mailbox is successfully SELECTed
Timo Sirainen [Mon, 25 Dec 2017 17:33:33 +0000 (19:33 +0200)] 
imapc: Keep "selected" state TRUE only while mailbox is successfully SELECTed

7 years agoimapc: Fix leaking mail_index_view on delayed expunge handling
Timo Sirainen [Wed, 17 Jan 2018 13:05:38 +0000 (15:05 +0200)] 
imapc: Fix leaking mail_index_view on delayed expunge handling

Fixes:
Panic: Leaked view for index (in-memory index): Opened in imapc-mailbox.c:47

7 years agolib-imap-client: Avoid "Unknown tag" errors for aborted commands
Timo Sirainen [Wed, 17 Jan 2018 13:03:06 +0000 (15:03 +0200)] 
lib-imap-client: Avoid "Unknown tag" errors for aborted commands

If mailbox is closed before all command replies were received, the commands
were aborted but they'll still receive the replies from server. Remember
the aborted commands' tag numbers so they can be ignored.