Siavash Tavakoli [Sun, 21 Mar 2021 22:15:48 +0000 (22:15 +0000)]
lib-ssl-iostream: Use OpenSSL's X509_check_host and X509_check_ip_asc if available
Make use of "X509_check_host()" and "X509_check_ip_asc()" if OpenSSL version
used has support for these functions. Revert back to previous custom
implementation in case either is not available.
Hosts are checked with partial wildcards (e.g. foo*.example.com) disabled.
If host name check fails, check against IP addresses in the certificate.
Stephan Bosch [Fri, 26 Feb 2021 23:04:54 +0000 (00:04 +0100)]
login-common: sasl-server - Remove data transfered to post-login service from input stream.
This prevents duplicating input when SSL is involved, causing commands pipelined
after authenticate commands from being duplicated. This issue emerged when login
proxy was changed to use the iostream pump/proxy. This means that the proxy uses
streams rather than raw FDs, which means that data buffered in input stream
before proxy is inherently forwarded to the post-login service... a second time.
Timo Sirainen [Wed, 15 Jan 2020 16:09:14 +0000 (18:09 +0200)]
lib-master: Add a delay to calling avail_overflow_callback with client_limit=1
Without the delay all (or many/most) processes will call the callback,
because the OS notifies all of the processes of the incoming connection.
This results in all of the connections being killed instead of only a few
of them.
Timo Sirainen [Wed, 15 Jan 2020 14:30:34 +0000 (16:30 +0200)]
lib-master: Fix calling avail_overflow_callback with service_count=1
This is used by login processes to kill the oldest connection when all of
the clients and processes for the service are taken. This wasn't working
when service_count=1 because the listeners were closed already.
It's not really useful anymore to even do this kind of a listener closing.
It was originally added in 9217d2426b4f8ece47441357f35d8bb34d97c4eb to
prevent restart problems with long-running login processes. However,
nowadays listeners can be closed via SIGQUIT so this isn't necessary.
Siavash Tavakoli [Fri, 26 Feb 2021 12:28:03 +0000 (12:28 +0000)]
lib-storage: Correct escaping for list index lookups
- Escape storage name when listing mailbox from index and unescape mailbox name
when looking for sibling nodes.
- Unescape when adding node to list index.
- List index iteration is performed with storage name where separators must be
escaped with storage_name_escape_char. Index lookup is done with storage_name
which is escaped with storage_name_escape_char but node names are unescaped.
Siavash Tavakoli [Mon, 22 Feb 2021 15:29:30 +0000 (15:29 +0000)]
lib-storage: mailbox-list: Add default storage name escaping for index layout
Add a default value for "storage_name_escape_char" when "LAYOUT=index".
Needed for situations where mailbox name contains separator char (e.g.
after migration to new separator) and listescape plugin is not active.
Timo Sirainen [Mon, 15 Mar 2021 16:18:07 +0000 (18:18 +0200)]
lib: cpu-limit - Redesign the API
The new API no longer has a signal callback, just a cpu_limit_exceeded()
function that needs to be periodically called to check if the limit has
exceeded. The callback could be added back if really necessary, but it's
just too easy to use signal handlers unsafely.
The new API also supports separating limits for user and system CPU usage.
It also attempts to guard against any unexpected kernel behavior resulting
from unclear behavior on how exactly the getrlimit(), setrlimit() and XCPU
signals interact.
Timo Sirainen [Mon, 15 Mar 2021 13:37:55 +0000 (15:37 +0200)]
lib: cpu-time - Use the original struct rusage as the initial_usage
This will allow separation of user and system CPU usage tracking.
They could have been tracked with two separate struct timevals, but
the extra memory usage is small and it might be nice to have all the
available data for debugging.
Timo Sirainen [Wed, 10 Mar 2021 15:40:47 +0000 (17:40 +0200)]
lib-imap: Fix assert-crash if parsing invalid BODYSTRUCTURE with empty Content-Language list
If there's no Content-Language, it should be NIL in the bodystructure.
So if the value is (), it is invalid.
This could in theory have happened when parsing corrupted
dovecot.index.cache or receiving it from a broken remote IMAP server with
imapc. The bug was found by fuzzing though.
It is possible that the system has several different versions of Lua
installed. This change allows one to force a specific version of Lua during
./configure. For example:
Timo Sirainen [Tue, 9 Mar 2021 16:42:38 +0000 (18:42 +0200)]
lib-storage: Don't trust last-rename-stamp that is too far into the future
If the timestamp is in the future, autoexpunging stops working until the
future time is passed. If this happened due to corruption, it could take
a long time before the timestamp is reached.