Stephan Bosch [Sat, 18 Apr 2020 10:56:14 +0000 (12:56 +0200)]
m4: Fix configuration of libunwind on i386 (and probably other systems).
Use the standard libunwind-coredump instead of the system-dependent library.
This way, all can be configured using pkg-config, without relying on a failed
attempt to use the $build_cpu variable to find the system-dependent library.
This fails on i386 and probably other systems as well.
Timo Sirainen [Wed, 25 Mar 2020 13:52:02 +0000 (15:52 +0200)]
lib-imap: imap_arg_get/as_nstring() - fail if input is an atom
Atoms were wrongly allowed in these places.
These have been used in very few places, so this change should be pretty
safe to do. The only affected places are:
* SETMETADATA - Backwards compatibility preserved by earlier commit
* ID - It's not expected that any clients use atoms here
* imapc - Server replies are parsed more strictly now
lib: event-filter - Use p_strdup() instead of p_strdup_empty() to avoid NULLs
The code used p_strdup_empty() in an (incorrect) attempt to avoid NULLs
turning into empty strings (""). None of the strdup variants do this.
However, p_strdup_empty() converts empty strings to NULLs. This caused a
NULL pointer dereference later on.
lib: event-filter - Implement filter boolean expression unit tests
This is a exhaustive test of the boolean operators using field equality
comparisons. This test code focuses on the boolean operators (AND, OR,
NOT) and not on the comparison operators (=, <, >, <=, and >=) and their
arguments (event names, source locations, categories).
lib: event-filter - Make NOT operator right associative and higher precedence
For example, consider the filter:
event=* AND
NOT event=foo AND
NOT event=bar AND
NOT event=baz
The "NOT" operator is supposed to be bound to the comparisons to the
immediate right. That is, it supposed to be equivalent to:
event=* AND
(NOT event=foo) AND
(NOT event=bar) AND
(NOT event=baz)
Both of these should produce the following parse tree:
AND
AND
AND
EQ EVENT '*'
NOT
EQ EVENT 'foo'
NOT
EQ EVENT 'bar'
NOT
EQ EVENT 'baz'
Instead, before this commit, the NOTs were getting bound to the entire
sub-expression to the right. Therefore, the original filter expression
was being parsed as if it were:
event=* AND
NOT (event=foo AND
NOT (event=bar AND
NOT event=baz))
Which produced the following parse tree:
AND
EQ EVENT '*'
NOT
AND
EQ EVENT 'foo'
NOT
AND
EQ EVENT 'bar'
NOT
EQ EVENT 'baz'
Siavash Tavakoli [Mon, 21 Dec 2020 10:45:32 +0000 (10:45 +0000)]
indexer: Remove worker-specific request queue
- Each request is done in a single connection and indexer master disconnects
from worker after indexing job is complete.
- No need to keep a worker queue since it always have length of 1. Instead,
keep a pointer to indexer_request for each worker connection.
- If indexing is in progress for a user, don't try to use the same connection
when a new request arrives for the same user. Instead, move the request to the
back of the queue and wait for the in progress request to finish then
create a new connection and submit request to worker.
Siavash Tavakoli [Sun, 20 Dec 2020 19:45:09 +0000 (19:45 +0000)]
indexer: Cleanup idle_list from worker pool
- Indexer always disconnects from worker process, no need to keep a list
of idle processes.
- The callback already calls worker_pool_release_connection every time worker
updated percentage. Defer disconnecting from working to the callback.
It checks if the request is completed and destroys connection.
Timo Sirainen [Wed, 20 May 2020 10:42:22 +0000 (13:42 +0300)]
lib: hash - Add assert to make sure hash table doesn't grow beyond UINT_MAX nodes
hash_table_count() returns unsigned int, so the node count can't be larger.
It's internally also tracked as unsigned int currently. It should be large
enough for all practical use cases.
lib-lua: Make DLUA_REQUIRE_ARGS*() take the lua_State * directly
This is the first in a series of commits that convert a number of functions
to pass around the lua_State pointer directly and to use it instead of using
the lua_State pointed to by the struct dlua_script.
This change is needed to eventually support the 'yield' functionality and
"sequential looking, but async behind the scenes" lua scripts. To support
this, the C code needs to instantiate multiple lua_States and then operate
on the correct one - whichever one is passed back by the lua runtime. This
lays the ground work for that.
Timo Sirainen [Thu, 22 Oct 2020 19:49:56 +0000 (22:49 +0300)]
lib-storage: Detect corrupted mail size when calculating body size
When body size is calculated from message size - header size, make sure that
the message size is at least as large as the header size. Otherwise treat
the message size as corrupted.
Siavash Tavakoli [Sun, 22 Nov 2020 19:16:03 +0000 (19:16 +0000)]
stats: openmetrics: Do not duplicate counter and duration metrics for histograms
Histograms generate "_count" and "_sum" metrics either for each quantile or
for the whole distribution. This patch prevents creating a duplicate metric
with type counter which results in metric name collision.
Timo Sirainen [Mon, 21 Dec 2020 19:24:50 +0000 (21:24 +0200)]
lib-master, master: Add "worker" service type
The worker services are expected to reach their process_limit regularly.
There shouldn't be a warning logged about temporarily reaching the limit,
since it can happen due to race conditions.
Timo Sirainen [Thu, 16 Jan 2020 12:58:21 +0000 (14:58 +0200)]
lib-master: Notify master immediately when process can accept more clients
Instead of delaying it for 1 second. Otherwise the master might be
complaining about process/client limit being reached or creating more
processes unnecessarily.
Siavash Tavakoli [Mon, 28 Dec 2020 10:26:07 +0000 (10:26 +0000)]
lib-mail: message-snippet: Fix expected number of leading non-whitespace chars
If message body starts with a single char + space (e.g. "I am"), the
space is wrongly removed (i.e. snippet would be "Iam") because at least two
non-whitespace characters are expected. Fix the minimum to 1 to fix this.
Set metadata without actually opening the mailbox.
As a side-effect this changes SETMETADATA command response when ACL
rules are present and user only has lookup right. For non-existing
mailboxes, command fails with "Mailbox doesn't exist" message instead of
"Permission denied" error.
imap: cmd-getmetadata: Retrieve metadata values without opening the mailbox
No need to actually opening the mailbox, only check for its existence.
This also makes GETMETADATA command behave more in line with RFC 5464 when
acls are preset. Changes to command results for different cases:
- User with only "l" right:
- for non-existing mailbox command failure error changed from "Permission denied"
to "Mailbox doesn't exist"
- User with "l" right and one of "s", "w", "i", and "p" rights:
- for INBOX, command result changed from "Permission denied" failure to "OK"
- for existing mailboxes, command result changed from "Permission denied"
failure to "OK"
- for non-existing mailboxes, command failure error changed from "Permission denied"
to "Mailbox doesn't exist"
- for autocreated mailboxes, command result changed from "Permission denied"
failure to "OK"
- User with "l" right and one of "x", "c", "d", and "a" rights:
- for non-existing mailboxes, command failure error changed from "Permission denied"
to "Mailbox doesn't exist"
- User with only "r" right:
- for INBOX, command result changed from "OK" to "Mailbox doesn't exist"
- for existing mailboxes, command result changed from "OK" to "Mailbox doesn't exist"
- for autocreated mailboxes, command result changed from "OK" to "Mailbox doesn't exist"
imap: cmd-getmetadata: Do not ignore NOTFOUND and PERM when handling errors
Don't ignore MAIL_ERROR_NOTFOUND MAIL_ERROR_PERM in cmd_getmetadata_handle_error
and fail GETMETADATA command properly. This code was added in the initial
GETMETADATA implementation commit. It doesn't seem like it has ever done
anything useful.
doveadm: doveadm-mail-mailbox-metadata: Add flag for prefixes in metadata list
Add an optional "-p" flag for metadata list command. Keys should have been
listed with "/private" or "/shared" prefixes from the get-go but for the
sake of not breaking users' workflow put this behind a flag.
This happens e.g. on FreeBSD when closing a socket that has not been
fully flushed to client. Since we can't do anything about that,
we might as well just ignore it.
Aki Tuomi [Mon, 21 Dec 2020 09:50:51 +0000 (11:50 +0200)]
lib: fd-util - Ignore ECONNRESET when closing fd
This happens e.g. on FreeBSD when closing a socket that has not been
fully flushed to client. Since we can't do anything about that,
we might as well just ignore it.