Stephan Bosch [Fri, 11 Sep 2020 19:08:03 +0000 (21:08 +0200)]
lib-smtp: smtp-server-cmd-helo - Fix panic occurring for default HELO reply.
This only fails for the HELO command; the EHLO command is unaffected. The
default reply routine is not actually used at the moment, but it is used by the
fuzzer.
Stephan Bosch [Tue, 23 Mar 2021 09:27:23 +0000 (10:27 +0100)]
lib-smtp: smtp-server-cmd-data - Fix crash occurring when BDAT is the last in a too long sequence of bad commands.
When smtp_server_reply() detects that too many replies were sent regarding
syntax errors, it will terminate the connection. Most commands will just stop
processing and exit when a reply is submitted, so no crash occurs for those.
However, BDAT will try to skip the data block, so that it will not be
interpreted as a large set of input commands, which subsequentely crashes
because the command parser is already gone after terminating the connection.
Markus Valentin [Wed, 24 Mar 2021 08:43:17 +0000 (09:43 +0100)]
imapc: imapc_list_get_fs() - Set index_pvt_dir for mailbox_list_settings
To allow using private indexes with imapc storage the index_pvt_dir must
be set when listing the mailbox. Previously this did not happen because
the index_pvt_dir was simply NULL, now the value is copied from the
imapc_mailbox_list.
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.