]> git.ipfire.org Git - thirdparty/dovecot/core.git/log
thirdparty/dovecot/core.git
6 years agolib: base64 - Simplify MAX_BASE64_ENCODED_SIZE() calculation
Josef 'Jeff' Sipek [Thu, 28 Mar 2019 09:25:41 +0000 (11:25 +0200)] 
lib: base64 - Simplify MAX_BASE64_ENCODED_SIZE() calculation

Rely on (X + (Y - 1)) / Y being the same as ceil(X / Y) when operating on
integers.

This has a couple of benefits over the previous expression:

 1) the size argument is evaluated only once
 2) the generated code is simpler (no conditional instructions)
 3) the generated code is smaller

The generated code shrinks in terms of both bytes and instruction count.
The following table lists the number of bytes (B) and instructions (I) used
by the code before and after this change on an assortment of architectures
when the input is not known at compile time.  Unless otherwise noted, the
results are based clang 6.0.1 output.

         | before  | after  |    delta
---------+---------+--------+-------------
aarch64  | 32B  8I | 24B 6I | -25%B -25%I
amd64    | 38B 10I | 25B 5I | -34%B -50%I
amd64 [1]| 43B 10I | 31B 6I | -28%B -40%I
armv7    | 36B  9I | 24B 6I | -33%B -33%I
i386     | 32B 12I | 20B 6I | -38%B -50%I
i386 [1] | 35B 11I | 25B 7I | -29%B -36%I
ppc32    | 44B 11I | 20B 5I | -55%B -55%I
ppc64    | 52B 13I | 32B 8I | -38%B -38%I
s390x    | 74B 16I | 26B 5I | -65%B -69%I
sparcv9  | 36B  9I | 12B 3I | -66%B -66%I

[1] gcc 8.2.0

6 years agolib-dcrypt: Implement dcrypt_key_get_curve_public using openssl
Aki Tuomi [Wed, 21 Aug 2019 10:26:29 +0000 (13:26 +0300)] 
lib-dcrypt: Implement dcrypt_key_get_curve_public using openssl

6 years agolib-dcrypt: Add dcrypt_key_get_curve_public
Aki Tuomi [Wed, 21 Aug 2019 10:25:33 +0000 (13:25 +0300)] 
lib-dcrypt: Add dcrypt_key_get_curve_public

Returns name of the curve of public key

6 years agolib-dcrypt: Add tests for raw keys
Aki Tuomi [Mon, 19 Aug 2019 19:40:02 +0000 (22:40 +0300)] 
lib-dcrypt: Add tests for raw keys

6 years agolib-dcrypt: Implement raw key API using OpenSSL
Aki Tuomi [Mon, 19 Aug 2019 11:39:05 +0000 (14:39 +0300)] 
lib-dcrypt: Implement raw key API using OpenSSL

6 years agolib-dcrypt: Add API for dealing with raw keys
Aki Tuomi [Mon, 19 Aug 2019 11:20:47 +0000 (14:20 +0300)] 
lib-dcrypt: Add API for dealing with raw keys

6 years agolib-dcrypt: Fix i2d_ASN1_OBJECT usage
Aki Tuomi [Fri, 23 Aug 2019 16:39:16 +0000 (19:39 +0300)] 
lib-dcrypt: Fix i2d_ASN1_OBJECT usage

i2d_ASN1_OBJECT tells how much memory we need.

6 years agolib-dcrypt: Symbolize maximum OID length
Aki Tuomi [Fri, 23 Aug 2019 10:48:03 +0000 (13:48 +0300)] 
lib-dcrypt: Symbolize maximum OID length

6 years agolib-dcrypt: Use len instead of ln
Aki Tuomi [Fri, 23 Aug 2019 10:46:33 +0000 (13:46 +0300)] 
lib-dcrypt: Use len instead of ln

6 years agolib-http: Make http_client_request_delay_from_response() public
Timo Sirainen [Mon, 19 Aug 2019 09:11:59 +0000 (12:11 +0300)] 
lib-http: Make http_client_request_delay_from_response() public

6 years agolib: Fix updating timeouts after time moves backwards
Timo Sirainen [Sat, 17 Aug 2019 10:44:53 +0000 (13:44 +0300)] 
lib: Fix updating timeouts after time moves backwards

Broken by b258137d0e0618ae792e3606071a1715d26f107b

Fixes:
Panic: file ioloop.c: line 479 (timeout_get_wait_time): assertion failed: (ret > 0 && tv_r->tv_sec >= 0 && tv_r->tv_usec >= 0)

6 years agolib: timeval_add/sub_usecs() - Add assert to make sure negative values aren't used
Timo Sirainen [Sat, 17 Aug 2019 10:43:21 +0000 (13:43 +0300)] 
lib: timeval_add/sub_usecs() - Add assert to make sure negative values aren't used

The current code doesn't work correctly if negative values are used.
The code could of course be changed to handle them, but maybe assert is
better to catch bugs.

6 years agolib, lib-dcrypt: Fix unit tests to check i_stream_read() return value
Timo Sirainen [Sun, 18 Aug 2019 14:44:33 +0000 (17:44 +0300)] 
lib, lib-dcrypt: Fix unit tests to check i_stream_read() return value

6 years agoindex: Pass index sync flags to index view sync for pvt
Aki Tuomi [Tue, 2 Jul 2019 16:33:59 +0000 (19:33 +0300)] 
index: Pass index sync flags to index view sync for pvt

When recovering from inconsistent view, this needs to
passed for pvt indexes too. Fixes

Error: dovecot.index.pvt reset, view is now inconsistent

6 years agopush-notification: Allow easy access to Message-ID header
Timo Sirainen [Fri, 16 Aug 2019 19:07:51 +0000 (22:07 +0300)] 
push-notification: Allow easy access to Message-ID header

6 years agocassandra: Fix crash due to race condition with threads
Timo Sirainen [Fri, 9 Aug 2019 09:19:17 +0000 (12:19 +0300)] 
cassandra: Fix crash due to race condition with threads

Broken by changes in 0a5a2b81c266c11c34ab36b20816909dc3e715ac

The crash could happen because driver_cassandra_future_callback() can be
called any time, even before returning from driver_cassandra_set_callback().
This could result in both cb->id and cb->to being set and using the cb
after it's already freed.

6 years agocassandra: Cleanup - Move code to cassandra_callback_detach()
Timo Sirainen [Fri, 9 Aug 2019 09:18:04 +0000 (12:18 +0300)] 
cassandra: Cleanup - Move code to cassandra_callback_detach()

6 years agoauth: Drop postfix socketmap support
Aki Tuomi [Mon, 19 Nov 2018 11:22:05 +0000 (13:22 +0200)] 
auth: Drop postfix socketmap support

It no longer works with recent postfix versions, and it's too much work to fix
it.

6 years agolib-storage: Add mailbox_attribute_internal.iter()
Timo Sirainen [Wed, 14 Aug 2019 16:18:20 +0000 (19:18 +0300)] 
lib-storage: Add mailbox_attribute_internal.iter()

This mainly allows internal attributes with children to actually be able to
list the childrens' keys.

6 years agosubmission: Deny anonymous access to significant commands by default.
Stephan Bosch [Mon, 13 May 2019 22:33:28 +0000 (00:33 +0200)] 
submission: Deny anonymous access to significant commands by default.

The transaction and individual recipients can be opened for allowed anonymous
access by flagging these as such.

6 years agosubmission: submission-client - Immediately terminate connection when it is an anonym...
Stephan Bosch [Fri, 9 Aug 2019 21:13:43 +0000 (23:13 +0200)] 
submission: submission-client - Immediately terminate connection when it is an anonymous login.

Unless a plugin flags the client for allowed anonymous login.

6 years agolib-smtp: smtp-server-connection: Add smtp_server_connection_abort().
Stephan Bosch [Fri, 9 Aug 2019 21:10:59 +0000 (23:10 +0200)] 
lib-smtp: smtp-server-connection: Add smtp_server_connection_abort().

Provides a clean method to abort the connection before it is even started.

6 years agologin-common: Deny anonymous login by default.
Stephan Bosch [Mon, 12 Aug 2019 20:10:24 +0000 (22:10 +0200)] 
login-common: Deny anonymous login by default.

Only services that explicitly enable anonymous logins will permit them. Plugins
can also mask anonymous logins by dropping the anonymous reply flag in the
sasl_check_login() client vfunc.

6 years agologin-common: sasl-server - Make sasl_server_auth_cancel() suitable for cancelling...
Stephan Bosch [Mon, 12 Aug 2019 23:18:57 +0000 (01:18 +0200)] 
login-common: sasl-server - Make sasl_server_auth_cancel() suitable for cancelling requests in login phase.

6 years agologin-common: client-common - Add sasl_check_login() vfunc.
Stephan Bosch [Mon, 12 Aug 2019 21:33:11 +0000 (23:33 +0200)] 
login-common: client-common - Add sasl_check_login() vfunc.

This allows checking the auth service success reply before commencing the actual
login.

6 years agologin-common: sasl-server - Make private authentication mechanisms unavailable for...
Stephan Bosch [Fri, 9 Aug 2019 21:44:39 +0000 (23:44 +0200)] 
login-common: sasl-server - Make private authentication mechanisms unavailable for normal authentication.

These mechanisms can only be used when the authentication is explicitly marked
as private.

6 years agologin-common: sasl-server - Add means to filter the available SASL mechanisms.
Stephan Bosch [Wed, 7 Aug 2019 23:56:17 +0000 (01:56 +0200)] 
login-common: sasl-server - Add means to filter the available SASL mechanisms.

This is accessible as a new client vfunc, so it can be used by protocol login
services and their plugins.

6 years agopop3-login: client - Use sasl_server_find_available_mech() instead of auth_client_fin...
Stephan Bosch [Fri, 9 Aug 2019 21:27:21 +0000 (23:27 +0200)] 
pop3-login: client - Use sasl_server_find_available_mech() instead of auth_client_find_mech().

6 years agoimap-login: imap-login-client - Use sasl_server_find_available_mech() instead of...
Stephan Bosch [Fri, 9 Aug 2019 21:26:54 +0000 (23:26 +0200)] 
imap-login: imap-login-client - Use sasl_server_find_available_mech() instead of auth_client_find_mech().

6 years agologin-common: sasl-server - Add sasl_server_find_available_mech().
Stephan Bosch [Fri, 9 Aug 2019 21:22:01 +0000 (23:22 +0200)] 
login-common: sasl-server - Add sasl_server_find_available_mech().

This is a wrapper for auth_client_find_mech(). This will be extended with
filtering in next commits.

6 years agosubmission-login: client.c - Use designated initializer for struct client_vfuncs.
Stephan Bosch [Wed, 7 Aug 2019 23:55:26 +0000 (01:55 +0200)] 
submission-login: client.c - Use designated initializer for struct client_vfuncs.

6 years agopop3-login: client.c - Use designated initializer for struct client_vfuncs.
Stephan Bosch [Wed, 7 Aug 2019 23:55:09 +0000 (01:55 +0200)] 
pop3-login: client.c - Use designated initializer for struct client_vfuncs.

6 years agoimap-urlauth: imap-urlauth-login.c - Use designated initializer for struct client_vfuncs.
Stephan Bosch [Wed, 7 Aug 2019 23:54:26 +0000 (01:54 +0200)] 
imap-urlauth: imap-urlauth-login.c - Use designated initializer for struct client_vfuncs.

6 years agoimap-login: imap-login-client.c - Use designated initializer for struct client_vfuncs.
Stephan Bosch [Wed, 7 Aug 2019 23:53:52 +0000 (01:53 +0200)] 
imap-login: imap-login-client.c - Use designated initializer for struct client_vfuncs.

6 years agolib-storage: mail-user - Add auth_mech field to struct mail_user.
Stephan Bosch [Tue, 6 Aug 2019 20:09:53 +0000 (22:09 +0200)] 
lib-storage: mail-user - Add auth_mech field to struct mail_user.

6 years agolib-storage: mail-storage-service - Parse "auth_mech" field from userdb extra fields.
Stephan Bosch [Tue, 6 Aug 2019 20:08:54 +0000 (22:08 +0200)] 
lib-storage: mail-storage-service - Parse "auth_mech" field from userdb extra fields.

6 years agologin-common: sasl-server - Parse "anonymous" field in AUTH reply.
Stephan Bosch [Mon, 12 Aug 2019 21:12:01 +0000 (23:12 +0200)] 
login-common: sasl-server - Parse "anonymous" field in AUTH reply.

6 years agoauth: auth-request-handler - Return "auth_mech" field in master REQUEST reply.
Stephan Bosch [Tue, 6 Aug 2019 19:52:23 +0000 (21:52 +0200)] 
auth: auth-request-handler - Return "auth_mech" field in master REQUEST reply.

It contains the name of the mechanism used in the authentication.

6 years agoauth: auth-request-handler - Return "anonymous" field for AUTH command that yields...
Stephan Bosch [Mon, 12 Aug 2019 19:06:51 +0000 (21:06 +0200)] 
auth: auth-request-handler - Return "anonymous" field for AUTH command that yields anonymous user.

6 years agologin-common: Fix sending locally-generated authentication error reason to client.
Stephan Bosch [Fri, 9 Aug 2019 22:33:21 +0000 (00:33 +0200)] 
login-common: Fix sending locally-generated authentication error reason to client.

This is about authentication errors that emerge at the login service rather than
the auth service. The error reason was always substituted with an unhelpful
"Authentication failed", while e.g. an error like "Unsupported authentication
mechanism" was supposed to be sent instead.

6 years agoimap: Only send NIL on GETMETADATA when query depth is 0
Martti Rannanjärvi [Fri, 9 Aug 2019 11:07:58 +0000 (14:07 +0300)] 
imap: Only send NIL on GETMETADATA when query depth is 0

6 years agoimap: GETMETADATA: Ignore MAIL_ERROR_NOTPOSSIBLE errors when using DEPTH parameter
Timo Sirainen [Wed, 7 Aug 2019 12:46:39 +0000 (15:46 +0300)] 
imap: GETMETADATA: Ignore MAIL_ERROR_NOTPOSSIBLE errors when using DEPTH parameter

This most likely means that imap_metadata=no, but the client still wants to
fetch recursively validated metadata entries. This should return in OK
instead of NO reply.

6 years agoauth: Do not unref policy payload too early
Aki Tuomi [Tue, 6 Aug 2019 05:44:18 +0000 (08:44 +0300)] 
auth: Do not unref policy payload too early

This can cause the context to be free'd too early leading
to crashes.

6 years agolib-imap-metadata: setting metadata literal value does not delete it
Markus Valentin [Fri, 2 Aug 2019 13:57:09 +0000 (15:57 +0200)] 
lib-imap-metadata: setting metadata literal value does not delete it

Only if value and value_stream are NULL the metadata can be unset.

6 years agorun-test-valgrind.supp: Add libunwind supression
Timo Sirainen [Wed, 17 Jul 2019 08:53:39 +0000 (11:53 +0300)] 
run-test-valgrind.supp: Add libunwind supression

6 years agolib-smtp: Fix encoding quoted localparts that end with "."
Timo Sirainen [Tue, 30 Jul 2019 11:15:11 +0000 (14:15 +0300)] 
lib-smtp: Fix encoding quoted localparts that end with "."

For example "user..@example.com" or "user..test.@example.com" resulted
in an extra '"' prefix.

6 years agodoc: example-config: Add lmtp_add_received_header
Siavash Tavakoli [Mon, 29 Jul 2019 10:28:29 +0000 (13:28 +0300)] 
doc: example-config: Add lmtp_add_received_header

6 years agolib-storage: Mark /private/specialuse attribute to be validated
Timo Sirainen [Mon, 29 Jul 2019 07:30:05 +0000 (10:30 +0300)] 
lib-storage: Mark /private/specialuse attribute to be validated

6 years agoimap: GETMETADATA: Send the last error as tagged reply
Timo Sirainen [Wed, 24 Jul 2019 12:39:37 +0000 (15:39 +0300)] 
imap: GETMETADATA: Send the last error as tagged reply

This way if there's only a single error, the error is in the tagged reply
with the [resp-code]. Clients can handle this better than untagged NO
replies.

6 years agoimap: GETMETADATA: If i_stream_get_size() fails, send client an internal error line
Timo Sirainen [Wed, 24 Jul 2019 12:36:03 +0000 (15:36 +0300)] 
imap: GETMETADATA: If i_stream_get_size() fails, send client an internal error line

Previously the client didn't get any kind of an explanation why the
GETMETADATA failed.

6 years agoimap: GETMETADATA: Move error handling to a common function
Timo Sirainen [Wed, 24 Jul 2019 12:31:20 +0000 (15:31 +0300)] 
imap: GETMETADATA: Move error handling to a common function

6 years agoimap: GETMETADATA: Replace failed boolean with last_error code
Timo Sirainen [Wed, 24 Jul 2019 12:26:08 +0000 (15:26 +0300)] 
imap: GETMETADATA: Replace failed boolean with last_error code

6 years agoimap: Allow SET/GETMETADATA to access validated attributes with imap_metadata=no
Timo Sirainen [Wed, 24 Jul 2019 12:05:27 +0000 (15:05 +0300)] 
imap: Allow SET/GETMETADATA to access validated attributes with imap_metadata=no

Some IMAP extensions use these commands to set/get their internal state.
This should be allowed even if full METADATA isn't enabled.

The initial plan was to restrict this in the lib-imap-storage layer, so it
would apply to everything using the imap-metadata API. This would have
affected for example accessing metadata in Sieve scripts, which could be
either good or bad. It might not be wanted to give users read access to
some metadata either, but admins really should be given the ability to
write Sieve scripts that access the metadata. However there's just no good
way to differentiate between admin-written (or tool-written) Sieve script
and user-written Sieve script.

Another issue is using metadata to configure virtual mailboxes. Currently
they're all admin-written and should be allowed to access metadata, but in
the future we might want to allow user-written virtual mailbox rules as
well.

So the end result at least for now is to just prevent IMAP GETMETADATA and
SETMETADATA specifically from accessing the non-validated attributes. Most
of the time there aren't any secrets in the metadata. In case there is,
users need to be prevented from accessing metadata via Sieve, and in such
systems users rarely have direct Sieve access anyway.

6 years agolib-imap-metadata: Add imap_metadata_transaction_validated_only()
Timo Sirainen [Tue, 30 Jul 2019 08:04:44 +0000 (11:04 +0300)] 
lib-imap-metadata: Add imap_metadata_transaction_validated_only()

6 years agolib-storage: Add support for "validated attributes"
Timo Sirainen [Wed, 24 Jul 2019 11:42:21 +0000 (14:42 +0300)] 
lib-storage: Add support for "validated attributes"

If an attribute is marked with MAIL_ATTRIBUTE_INTERNAL_FLAG_VALIDATED, it's
assumed to be "validated". This means that it has a set() callback that
validates the value, which at minimum means that its size isn't excessively
large.

MAIL_ATTRIBUTE_TYPE_FLAG_VALIDATED can be used with set/get/iterate to allow
access only to these validated attributes. Trying to access non-validated
attributes will result in error.

6 years agolib-storage: Prepare attribute API for having flags in the type
Timo Sirainen [Tue, 23 Jul 2019 11:42:45 +0000 (12:42 +0100)] 
lib-storage: Prepare attribute API for having flags in the type

6 years agolib-ssl-iostream: Support TLSv1.3 ciphersuites
Aki Tuomi [Mon, 29 Jul 2019 13:08:07 +0000 (16:08 +0300)] 
lib-ssl-iostream: Support TLSv1.3 ciphersuites

6 years agolib-ssl-iostream: test-iostream-ssl - Wait until both sides have handshaked
Aki Tuomi [Mon, 29 Jul 2019 13:17:27 +0000 (16:17 +0300)] 
lib-ssl-iostream: test-iostream-ssl - Wait until both sides have handshaked

Produces consistent result with different TLS flavors

6 years agolib-ssl-iostream: test-iostream-ssl - Plug memory leak
Aki Tuomi [Mon, 29 Jul 2019 13:24:49 +0000 (16:24 +0300)] 
lib-ssl-iostream: test-iostream-ssl - Plug memory leak

If either endpoint fails to initialize it needs to be deinitialized too.

6 years agolib-ssl-iostream: test-iostream-ssl - Always fail on error
Aki Tuomi [Mon, 29 Jul 2019 12:39:20 +0000 (15:39 +0300)] 
lib-ssl-iostream: test-iostream-ssl - Always fail on error

Consistently fail the real function if something goes wrong.
Needed for TLSv1.3 support.

6 years agolib-ssl-iostream: test-iostream-ssl - Explicitly increment idx
Aki Tuomi [Mon, 29 Jul 2019 12:36:21 +0000 (15:36 +0300)] 
lib-ssl-iostream: test-iostream-ssl - Explicitly increment idx

The test_assert macro does not evaluate the idx increment
if the test succeeds.

6 years agostats: event exporters - Support https
Aki Tuomi [Mon, 29 Jul 2019 08:11:11 +0000 (11:11 +0300)] 
stats: event exporters - Support https

6 years agostats: event-exporter - Use DNS for http
Aki Tuomi [Mon, 29 Jul 2019 07:56:52 +0000 (10:56 +0300)] 
stats: event-exporter - Use DNS for http

6 years agostats: Disable chroot to make event exporters work
Aki Tuomi [Mon, 29 Jul 2019 08:20:48 +0000 (11:20 +0300)] 
stats: Disable chroot to make event exporters work

This is mostly needed for dns-client unix socket and
accessing ssl CA certificates.

6 years agodns-client: Make dns client available in login chroot
Aki Tuomi [Mon, 29 Jul 2019 07:56:20 +0000 (10:56 +0300)] 
dns-client: Make dns client available in login chroot

Otherwise it's not possible to use it for login processes.

6 years agolmtp: lmtp-local - Drop LMTP server log prefixes for event used for mail delivery.
Stephan Bosch [Fri, 26 Jul 2019 00:14:11 +0000 (02:14 +0200)] 
lmtp: lmtp-local - Drop LMTP server log prefixes for event used for mail delivery.

6 years agolib: lib-event - Add support for dropping log prefixes introduced by parent events.
Stephan Bosch [Thu, 25 Jul 2019 23:57:44 +0000 (01:57 +0200)] 
lib: lib-event - Add support for dropping log prefixes introduced by parent events.

This allows dropping a specific number prefixes from parents when this event is
used for logging. This does not affect the parent events. This only counts
actual prefixes and not  parents. If the count is higher than the actual number
of prefixes added by parents, all will be dropped.

6 years agomail-crypt: test-mail-key - Skip test before allocating test_pool
Siavash Tavakoli [Fri, 26 Jul 2019 08:55:11 +0000 (11:55 +0300)] 
mail-crypt: test-mail-key - Skip test before allocating test_pool

Fixes a memory leak if test is skipped.

6 years agolib-smtp: test-smtp-payload - exclude ssl cases if ssl not supported
Siavash Tavakoli [Fri, 26 Jul 2019 08:55:05 +0000 (11:55 +0300)] 
lib-smtp: test-smtp-payload - exclude ssl cases if ssl not supported

6 years agolib-http: test-http-payload - Include test_echo_ssl only if ssl is supported
Siavash Tavakoli [Fri, 26 Jul 2019 08:54:47 +0000 (11:54 +0300)] 
lib-http: test-http-payload - Include test_echo_ssl only if ssl is supported

6 years agolib: Allow event filtering with wildcarded integers
Josef 'Jeff' Sipek [Thu, 18 Jul 2019 15:45:28 +0000 (11:45 -0400)] 
lib: Allow event filtering with wildcarded integers

6 years agolib-ssl-iostream: Don't build test-iostream-ssl if building without ssl
Timo Sirainen [Mon, 22 Jul 2019 15:35:05 +0000 (18:35 +0300)] 
lib-ssl-iostream: Don't build test-iostream-ssl if building without ssl

Fixes compiling when building without ssl.

6 years agolib-storage: Namespace prefix shouldn't be included in all mailbox name validity...
Timo Sirainen [Mon, 22 Jul 2019 11:57:34 +0000 (14:57 +0300)] 
lib-storage: Namespace prefix shouldn't be included in all mailbox name validity checks

Broken by 90c2995737cc1f3fe042993beb7b0b32e5375795

6 years agolib: Correct comment typo (UIID -> UUID)
Josef 'Jeff' Sipek [Wed, 6 Feb 2019 16:33:11 +0000 (11:33 -0500)] 
lib: Correct comment typo (UIID -> UUID)

6 years agolib-smtp: smtp-params - Assume all capabilities are supported when adding parameter...
Stephan Bosch [Mon, 15 Jul 2019 19:50:11 +0000 (21:50 +0200)] 
lib-smtp: smtp-params - Assume all capabilities are supported when adding parameter event fields.

The actual capabilities are not really needed, since any assigned field is
relevent for event processing, whether the remote end will accept it or not.

This also fixes an assert failure occuring for proxied connections. Since the
server and client (proxy) connections can have different capabilities and since
the client connection does not have a proper capability list available in the
beginning of the handshake, the event created for a client transaction would
cause an assert failure when parameters were assigned that did not match the
capabilities (none).

6 years agolib: ostream-file: Don't log any errors when setting TCP_NODELAY
Timo Sirainen [Mon, 15 Jul 2019 07:14:23 +0000 (10:14 +0300)] 
lib: ostream-file: Don't log any errors when setting TCP_NODELAY

It's likely never useful to log the error, and it seems more and more
unexpected errors just keep popping up.

6 years agolib: test-ostream-multiplex - Check flush return value
Aki Tuomi [Fri, 12 Jul 2019 07:29:00 +0000 (10:29 +0300)] 
lib: test-ostream-multiplex - Check flush return value

Fixes coverity nit

6 years agoconfig: Cache converted ssl-parameters.dat result
Timo Sirainen [Fri, 12 Jul 2019 07:22:01 +0000 (10:22 +0300)] 
config: Cache converted ssl-parameters.dat result

This way the ssl-parameters.dat is read only once by the config process
instead of for every config request.

6 years agoconfig: Fix memory leaks when failing to convert ssl-parameters.dat
Timo Sirainen [Fri, 12 Jul 2019 07:16:26 +0000 (10:16 +0300)] 
config: Fix memory leaks when failing to convert ssl-parameters.dat

If ssl_dh setting isn't set and ssl-parameters.dat isn't found or there's
some error reading it, memory is leaked for every config request. This
eventually results in config process dying due to reaching vsz_limit.

6 years agolib-storage: Fix setting \Noinferiors flag for detached INBOX
Timo Sirainen [Thu, 11 Jul 2019 12:08:10 +0000 (15:08 +0300)] 
lib-storage: Fix setting \Noinferiors flag for detached INBOX

The "" namespace is nowadays automatically created, so we can't just check
if mail_namespace_find_prefix() returns NULL.

I left the NULL check there for now at least, just in case there's some
reason I couldn't think of when it could be NULL.

6 years agodict: Exit early to work around various errors and crashes at shutdown
Timo Sirainen [Thu, 11 Jul 2019 11:43:13 +0000 (14:43 +0300)] 
dict: Exit early to work around various errors and crashes at shutdown

This is just a kludge until the dict process cleanup can be done cleanly.

6 years agolib: test-ostream-multiplex - Test corking
Aki Tuomi [Tue, 21 May 2019 09:14:35 +0000 (12:14 +0300)] 
lib: test-ostream-multiplex - Test corking

6 years agolib: ostream-multiplex - Fix last_sent
Aki Tuomi [Wed, 10 Jul 2019 08:25:14 +0000 (11:25 +0300)] 
lib: ostream-multiplex - Fix last_sent

The intention was to choose oldest channel. The old code however
always chose last channel to send, which was not really the point.

Using unix timestamp is also problematic due to sub-second granularity.

6 years agolib: ostream-multiplex - Optimize writing
Aki Tuomi [Tue, 21 May 2019 09:43:46 +0000 (12:43 +0300)] 
lib: ostream-multiplex - Optimize writing

6 years agolib: ostream-multiplex - Implement cork support
Aki Tuomi [Tue, 21 May 2019 08:45:57 +0000 (11:45 +0300)] 
lib: ostream-multiplex - Implement cork support

Support corking for multiplex channels

6 years agolib: ostream-multiplex - Fix code format issue
Aki Tuomi [Wed, 10 Jul 2019 08:16:03 +0000 (11:16 +0300)] 
lib: ostream-multiplex - Fix code format issue

6 years agolib-ssl-iostream: Add unit test
Aki Tuomi [Tue, 21 May 2019 10:34:57 +0000 (13:34 +0300)] 
lib-ssl-iostream: Add unit test

6 years agolib-ssl-iostream: ostream-openssl - Prevent segfault o_stream_get_buffer_*_size(...
Aki Tuomi [Tue, 21 May 2019 10:32:14 +0000 (13:32 +0300)] 
lib-ssl-iostream: ostream-openssl - Prevent segfault o_stream_get_buffer_*_size() when buffer is not allocated yet.

6 years agom4: Substitute variables in modules.m4
Aki Tuomi [Tue, 21 May 2019 10:31:08 +0000 (13:31 +0300)] 
m4: Substitute variables in modules.m4

Otherwise they do not work in Makefiles

6 years agolib-storage: Add mailbox_list_index_get_index()
Timo Sirainen [Tue, 9 Jul 2019 15:36:14 +0000 (18:36 +0300)] 
lib-storage: Add mailbox_list_index_get_index()

6 years agolib-storage: mailbox_list_index_view_open() - Don't crash if list indexes are disabled
Timo Sirainen [Tue, 9 Jul 2019 15:35:24 +0000 (18:35 +0300)] 
lib-storage: mailbox_list_index_view_open() - Don't crash if list indexes are disabled

This allows callers to call it without knowing if mailbox_list_index=yes

6 years agolib-storage: Move mailbox_list_index_view_open() to mailbox-list-index.c
Timo Sirainen [Tue, 9 Jul 2019 14:16:33 +0000 (17:16 +0300)] 
lib-storage: Move mailbox_list_index_view_open() to mailbox-list-index.c

It's a bit more appropriate location for it now that it's not strictly used
by only the STATUS caching code.

6 years agolib-storage: Make mailbox_list_index_view_open() public
Timo Sirainen [Tue, 9 Jul 2019 14:16:00 +0000 (17:16 +0300)] 
lib-storage: Make mailbox_list_index_view_open() public

6 years agolib-storage: Rename index_list_open_view() to mailbox_list_index_view_open()
Timo Sirainen [Tue, 9 Jul 2019 14:12:28 +0000 (17:12 +0300)] 
lib-storage: Rename index_list_open_view() to mailbox_list_index_view_open()

In preparation for making the function public.

6 years agolib-storage: index_list_open_view() - Rename status_check to require_refreshed
Timo Sirainen [Tue, 9 Jul 2019 14:11:16 +0000 (17:11 +0300)] 
lib-storage: index_list_open_view() - Rename status_check to require_refreshed

This describes the parameter's behavior better.

6 years agolib-storage: Move MAILBOX_IS_NEVER_IN_INDEX() to mailbox-list-index.h
Timo Sirainen [Tue, 9 Jul 2019 14:07:18 +0000 (17:07 +0300)] 
lib-storage: Move MAILBOX_IS_NEVER_IN_INDEX() to mailbox-list-index.h

6 years agouserdb-passwd: Fix getpwent errno handling
Aki Tuomi [Fri, 5 Oct 2018 07:18:35 +0000 (10:18 +0300)] 
userdb-passwd: Fix getpwent errno handling

In https://bugs.gentoo.org/667118 Reuben Farrelly
noticed that running
    # doveadm user '*'
causes auth daemon to generate errors like:
    auth-worker(3585): Error: getpwent() failed: Invalid argument

This happens because on successful call getpwent()
now sets errno=EINVAL starting from glibc-2.28.
See https://sourceware.org/PR16004 for details.

The fix is to reset 'errno' before 'getpwent()' is called.

Reported-by: Reuben Farrelly
Bug: https://bugs.gentoo.org/667118
Bug: https://sourceware.org/PR16004
Original-Author: Sergei Trofimovich <slyfox@gentoo.org>

6 years agolib-dns: Log "Disconnect" event before calling DNS callbacks and freeing lookups
Timo Sirainen [Tue, 9 Jul 2019 23:09:12 +0000 (02:09 +0300)] 
lib-dns: Log "Disconnect" event before calling DNS callbacks and freeing lookups

dns_lookup_free() could be freeing the dns_client, which causes a segfault
in the e_debug() log call.

Broken by fc8c54c48fec6a89d9cda755756c233191c62af1

6 years agolib: test-event-log - Add unit tests for calling event_log*() with params->base_...
Stephan Bosch [Sat, 6 Jul 2019 17:38:21 +0000 (19:38 +0200)] 
lib: test-event-log - Add unit tests for calling event_log*() with params->base_*_prefix assigned.

6 years agolib: test-event-log - Add unit tests for calling event_log*() with params->no_send...
Stephan Bosch [Sat, 6 Jul 2019 17:42:39 +0000 (19:42 +0200)] 
lib: test-event-log - Add unit tests for calling event_log*() with params->no_send = TRUE.