Timo Sirainen [Mon, 13 Mar 2017 12:23:11 +0000 (14:23 +0200)]
auth: Auth workers shouldn't return username if it wasn't changed
This continues the previous fix where username was always added to
passdb/userdb cache, even if the username wasn't changed. That could have
resulted in wrongly changing usernames if the cache key didn't uniquely
identify the user.
Timo Sirainen [Mon, 13 Mar 2017 11:49:04 +0000 (13:49 +0200)]
auth: passdb/userdb lookups via auth-worker cached too much of the replies
Only the fields returned by the lookup itself were supposed to be cached.
This was especially problematic if the lookup via auth-worker didn't
uniquely identify the user. For example doing a passdb lookup for an
attribute shared by multiple users could have caused the reply to contain
the previous cached user's all extra fields.
Timo Sirainen [Wed, 15 Mar 2017 23:22:09 +0000 (01:22 +0200)]
lib-oauth2: Don't free oauth2_request too early.
Move the freeing explicitly to only after calling the callback. The
previous method of freeing it on when http_request was destroyed could
have happened too early when oauth2_parse_json() called i_stream_unref(),
which released the last reference to the http_request.
Timo Sirainen [Wed, 15 Mar 2017 22:51:15 +0000 (00:51 +0200)]
auth: oauth2 - make it easier to see where db_oauth2_callback() is called
Doesn't fix anything, but places the db_oauth2_callback() calls into the end
of _continue() calls so it's clearer that they're always being called
exactly once.
result->error is NULL only if result->success && !result->valid.
Also !result->success is the more important error handling case.
Write out these cases explicitly so it's easier to understand.
Stephan Bosch [Wed, 1 Mar 2017 23:42:13 +0000 (00:42 +0100)]
lib-smtp: lmtp-client: Fixed bug in timeout handling.
The timeout was erroneously stopped when lmtp_client_send() was invoked before a connection was established.
Once the connection finally got established, the timeout was removed.
This would cause the client to wait indefinitely.
Stephan Bosch [Wed, 1 Mar 2017 23:03:50 +0000 (00:03 +0100)]
lib-lda: smtp-client: Make sure only the first error determines the tempfail status.
The client is supposed to stop running the moment the first error occurs. However, there is a (very unlikely) possiblity that the encapsulated LMTP client issues both an RCPT and DATA error callback in sequence.
In that case, the second callback should not override the tempfail status of the first (the second likely is a tempfail).
If the server disconnects right after failing the last of at least two recipients, the lmtp-client would issue a DATA callback with a disconnection error.
The disconnect error would set the client->tempfail flag, which caused smtp_client_deinit*() to always return -1 in this scenario.
Timo Sirainen [Sun, 26 Feb 2017 12:32:44 +0000 (14:32 +0200)]
lazy-expunge: Use mailbox_move() instead of mailbox_copy()
This allows some optimizations to be performed that are only possible when
moving messages.
It's slightly strange now that mail_expunge() is triggered twice for the
same source mail, but lazy_expunge plugin is called very early so most
plugins won't see it called twice. Currently only acl plugin sees it, and
it doesn't care.
Stephan Bosch [Thu, 23 Feb 2017 18:38:31 +0000 (19:38 +0100)]
lib-http: client: Fixed i_unreached() failure occurring when a host's list of IPs changes while a connection is still pending.
In that case, the IP of the pending connection may no longer be associated with that host.
If the IP was not found anymore, the i_unreached() error occurred.
Aki Tuomi [Mon, 20 Feb 2017 07:32:15 +0000 (09:32 +0200)]
lib-ssl-iostream: Fix ambiguity with SSL settings
- lib-ssl-iostream as client: Use only allow_invalid_cert. If it's not set, verify the server cert.
- lib-ssl-iostream as server: If verify_client_cert=FALSE, don't ask for the client cert. Otherwise, ask for client cert but still allow it if allow_invalid_cert=TRUE.
Timo Sirainen [Wed, 22 Feb 2017 13:32:19 +0000 (15:32 +0200)]
lazy-expunge: Fix error handling for GUID lookups
If the mail is already expunged, the error should be ignored.
In other situations the original error string should be preserved as
part of the logged error message.
Timo Sirainen [Wed, 22 Feb 2017 11:28:43 +0000 (13:28 +0200)]
lib-storage: Use refcounting for mail_storage_service_user
doveadm import was freeing the user too early, which resulted
mail_user._service_user pointing to freed memory. More importantly,
after 34512eaad8b1b2f929e6d6e3a2f7252c29fba97b user->set was pointing
to already freed memory.
It's not very informative and we can't give a better error message without
changing the APIs. The real error should have been logged already anyway,
so this is just duplication of an error. I think originally this was added
because some backend forgot to log an error.
Timo Sirainen [Tue, 21 Feb 2017 10:38:10 +0000 (12:38 +0200)]
lib-lda: Fix delivery logging when Sieve performs multiple actions
Previous code assumed that it would work like:
- save/copy
- transaction commit
- mail_deliver_ctx_get_log_var_expand_table()
- repeat for transaction 2
So the cache needs to be stored per transaction. This code still wouldn't
work correctly if Sieve saved mails multiple times within the same
transaction, but that doesn't happen (at least currently).
lib-mail: Place input/output of message-date tests in one struct
Define both input and output of a message date test case in a single
struct so it is easier to follow and less error prone. Also add some
leap second tests.
Timo Sirainen [Tue, 21 Feb 2017 11:48:36 +0000 (13:48 +0200)]
lmtp: Fix lmtp_user_concurrency_limit when userdb changes the username
Anvil LOOKUP was done with the original username, while CONNECT/DISCONNECT
was done with the changed username. So LOOKUP always thought that there
were zero concurrent sessions for the user.