Timo Sirainen [Mon, 27 Mar 2017 10:44:13 +0000 (13:44 +0300)]
cassandra: Fallback consistency fix - it wasn't used permanently
Because the "do I want to retry using primary consistency?" check was done
using the first failure timestamp, after 60 seconds that check always
returned TRUE. We should instead be checking the last timestamp for a
query that was sent with the primary consistency.
Timo Sirainen [Sun, 19 Mar 2017 13:32:53 +0000 (15:32 +0200)]
imapc: Fail user creation if login to imapc_host fails.
This causes imapc to actually wait for the login to succeed or fail.
Such a wait was already done by the imap code, which will be removed by
the next patch.
Timo Sirainen [Fri, 24 Mar 2017 12:46:05 +0000 (14:46 +0200)]
lib-mail: Fix read overflow / crash in message_header_decode()
If the input string was "=?charset?Q|B?text?", the code attempted to look up
the character after it. And if it was "=", the callback was called with
size=-1, which ends up in a crash.
Timo Sirainen [Thu, 23 Mar 2017 12:19:42 +0000 (14:19 +0200)]
lmtp: Trigger autoexpunging only for the last RCPT TO.
Otherwise if the autoexpunging takes a long time, the LMTP client could
disconnect due to a timeout. The mails would still eventually get delivered
though, so it would result in duplicate mails being delivered.
An alternative to this would be to keep all the mail_users referenced until
the delivery is finished and then autoexpunge all of them at the end. It
increases memory usage though and complicates the code, so at least for now
it's not implemented.
Stephan Bosch [Fri, 17 Mar 2017 22:39:33 +0000 (23:39 +0100)]
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
If the provided HTTP URL is invalid, the callback with the error is called some time later from the ioloop.
This change also amends the test-http-client-errors test suite with a new test for this new feature.
Stephan Bosch [Fri, 17 Mar 2017 22:35:55 +0000 (23:35 +0100)]
lib-http: client: Restructured the handling of delayed errors.
The req->delayed_error* fields are cleared before the callback is called and before the request is dereferenced.
This way, freeing the request never removes it from the delayed request list when the list is being processed.
It also makes it possible to resubmit the request from the callback (mainly for future use).
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 [Thu, 16 Mar 2017 16:46:28 +0000 (18:46 +0200)]
lib-storage: Don't reset \Recent flags when rebuilding index
The recent flags are tracked with first_recent_uid in the header. If the
first_recent_uid is valid in the old index, preserve it. This way all
mails don't show as having \Recent flag.
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.
Aki Tuomi [Sat, 11 Mar 2017 17:20:30 +0000 (19:20 +0200)]
doveadm: Do not crash doveadm-server if input file missing
save commands expects valid input file for it to work,
if we are not running for cli, and input file is not
provided, provide EINVAL error to caller via i_stream_error.
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.