]> git.ipfire.org Git - thirdparty/dovecot/core.git/log
thirdparty/dovecot/core.git
4 years agolib-storage: Make lua methods and functions use the passed in lua_State * directly
Josef 'Jeff' Sipek [Tue, 12 Jan 2021 18:53:19 +0000 (13:53 -0500)] 
lib-storage: Make lua methods and functions use the passed in lua_State * directly

4 years agolib-storage: Make dlua_push_mail() take lua_State * directly
Josef 'Jeff' Sipek [Tue, 12 Jan 2021 19:27:31 +0000 (14:27 -0500)] 
lib-storage: Make dlua_push_mail() take lua_State * directly

4 years agolib-storage: Make dlua_push_mail_user() take lua_State * directly
Josef 'Jeff' Sipek [Tue, 12 Jan 2021 19:26:07 +0000 (14:26 -0500)] 
lib-storage: Make dlua_push_mail_user() take lua_State * directly

4 years agolib-storage: Make lua_storage_cmp() take lua_State * directly
Josef 'Jeff' Sipek [Tue, 12 Jan 2021 18:30:45 +0000 (13:30 -0500)] 
lib-storage: Make lua_storage_cmp() take lua_State * directly

4 years agolib-storage: Make lua_check_storage_mailbox() take lua_State * directly
Josef 'Jeff' Sipek [Tue, 12 Jan 2021 17:59:39 +0000 (12:59 -0500)] 
lib-storage: Make lua_check_storage_mailbox() take lua_State * directly

4 years agolib-storage: Make dlua_push_mailbox() take lua_State * directly
Josef 'Jeff' Sipek [Tue, 12 Jan 2021 17:02:05 +0000 (12:02 -0500)] 
lib-storage: Make dlua_push_mailbox() take lua_State * directly

4 years agomaster: Send instance_name setting to log process
Timo Sirainen [Thu, 7 Jan 2021 16:12:27 +0000 (18:12 +0200)] 
master: Send instance_name setting to log process

This way log process can use it for syslog ident

4 years agocassandra: Fix logging messages with LFs
Timo Sirainen [Mon, 7 Dec 2020 13:58:00 +0000 (15:58 +0200)] 
cassandra: Fix logging messages with LFs

At least some trace level messages had them.

4 years agom4: Fix configuration of libunwind on i386 (and probably other systems).
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.

4 years agolib-imap: imap_bodystructure_write() - Add asserts to check unexpected NULLs inside...
Timo Sirainen [Wed, 25 Mar 2020 14:20:08 +0000 (16:20 +0200)] 
lib-imap: imap_bodystructure_write() - Add asserts to check unexpected NULLs inside lists

This just changes the assert that already triggers into a bit clearer
assert.

4 years agolib-imap: Add unit test for invalid BODYSTRUCTUREs
Timo Sirainen [Wed, 25 Mar 2020 13:52:29 +0000 (15:52 +0200)] 
lib-imap: Add unit test for invalid BODYSTRUCTUREs

4 years agolib-imap: imap_arg_get/as_nstring() - fail if input is an atom
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

4 years agolib-imap: Don't wrongly accept NILs or atoms when parsing BODYSTRUCTURE
Timo Sirainen [Wed, 25 Mar 2020 13:49:37 +0000 (15:49 +0200)] 
lib-imap: Don't wrongly accept NILs or atoms when parsing BODYSTRUCTURE

Especially NILs could cause crashes later on when some internal field is
NULL when it's not expectedly to be.

Fixes a crash when parsing BODYSTRUCTURE and writing it out with
imap_bodystructure_write() when some of the parameter lists contained NILs.

4 years agolib-imap: imap_body_parse_from_bodystructure() - Write size field as atom
Timo Sirainen [Wed, 25 Mar 2020 13:47:51 +0000 (15:47 +0200)] 
lib-imap: imap_body_parse_from_bodystructure() - Write size field as atom

Following changes will break writing it as nstring.

4 years agoimap: SETMETADATA - Explicitly support using atoms for values
Timo Sirainen [Wed, 25 Mar 2020 14:00:08 +0000 (16:00 +0200)] 
imap: SETMETADATA - Explicitly support using atoms for values

Required to keep atoms working (and especially not assert-crashing) after
the following imap_arg_get_nstring() change.

4 years agolib: event-filter - Implement event_filter_merge() unit test
Josef 'Jeff' Sipek [Wed, 20 Jan 2021 16:15:18 +0000 (11:15 -0500)] 
lib: event-filter - Implement event_filter_merge() unit test

4 years agolib: event-filter - Use p_strdup() instead of p_strdup_empty() to avoid NULLs
Josef 'Jeff' Sipek [Tue, 12 Jan 2021 16:15:44 +0000 (11:15 -0500)] 
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.

4 years agolib: test-lib - Free event filters
Aki Tuomi [Thu, 21 Jan 2021 07:15:10 +0000 (09:15 +0200)] 
lib: test-lib - Free event filters

Fixes memory leak

Forgotten from 01ccf687d660331ca3e483c90582156757cebb7f

4 years agolib: event-filter - Implement filter boolean expression unit tests
Josef 'Jeff' Sipek [Tue, 19 Jan 2021 18:46:13 +0000 (13:46 -0500)] 
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).

4 years agolib: event-filter - Correct a comment referring to old filter syntax
Josef 'Jeff' Sipek [Tue, 19 Jan 2021 18:42:17 +0000 (13:42 -0500)] 
lib: event-filter - Correct a comment referring to old filter syntax

4 years agolib: event-filter - Add a helper function to get at the filter's boolean expression
Josef 'Jeff' Sipek [Tue, 19 Jan 2021 18:41:45 +0000 (13:41 -0500)] 
lib: event-filter - Add a helper function to get at the filter's boolean expression

This is necessary for the soon-to-be-implemented unit tests.

4 years agolib: event-filter - Expose internal functions to allow for unit testing
Josef 'Jeff' Sipek [Tue, 19 Jan 2021 18:40:17 +0000 (13:40 -0500)] 
lib: event-filter - Expose internal functions to allow for unit testing

We'll need these to avoid code duplication when unit testing the boolean
expression evaluation logic.

4 years agolib: event-filter - Make NOT operator right associative and higher precedence
Josef 'Jeff' Sipek [Mon, 4 Jan 2021 17:01:28 +0000 (12:01 -0500)] 
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'

4 years agolib-test: fuzzer - Don't crash in targets without ioloop
Philippe Antoine [Thu, 14 Jan 2021 19:31:18 +0000 (20:31 +0100)] 
lib-test: fuzzer - Don't crash in targets without ioloop

4 years agoauth: Makefile.am - Use $(LIBDOVECOT_LUA) instead of redefining it
Timo Sirainen [Mon, 18 Jan 2021 16:53:36 +0000 (17:53 +0100)] 
auth: Makefile.am - Use $(LIBDOVECOT_LUA) instead of redefining it

4 years agoauth: Fix building built-in lua
Timo Sirainen [Mon, 18 Jan 2021 16:53:07 +0000 (17:53 +0100)] 
auth: Fix building built-in lua

It was working only when building as plugin.

4 years agolib: test-buffer - Fix memory leak errors in fatal buffer tests
Timo Sirainen [Mon, 18 Jan 2021 12:46:55 +0000 (13:46 +0100)] 
lib: test-buffer - Fix memory leak errors in fatal buffer tests

4 years agolib-test: Add test_fatal_set_callback()
Timo Sirainen [Mon, 18 Jan 2021 12:46:46 +0000 (13:46 +0100)] 
lib-test: Add test_fatal_set_callback()

4 years agolib-master: test-event-stats - Add test for large event id
Aki Tuomi [Mon, 18 Jan 2021 09:38:04 +0000 (11:38 +0200)] 
lib-master: test-event-stats - Add test for large event id

Ensure UPDATE command syntax is correct when event id is over 1 million

4 years agoindexer: Remove worker-specific request queue
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.

4 years agoindexer: Cleanup idle_list from worker pool
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.

4 years agoindexer: Disconnect from indexer-worker after each request
Siavash Tavakoli [Mon, 14 Dec 2020 21:39:39 +0000 (21:39 +0000)] 
indexer: Disconnect from indexer-worker after each request

This allows indexer-worker to properly handle service configurations such as
service_count and idle_kill time.

4 years agolib: array - Make sure it assert-crashes if trying to add more than UINT_MAX elements
Timo Sirainen [Wed, 20 May 2020 08:18:48 +0000 (11:18 +0300)] 
lib: array - Make sure it assert-crashes if trying to add more than UINT_MAX elements

This is required, because array_count() returns unsigned int.

4 years agolib: Add buffer_create_dynamic_max()
Timo Sirainen [Wed, 20 May 2020 08:16:29 +0000 (11:16 +0300)] 
lib: Add buffer_create_dynamic_max()

4 years agolib: hash - Add assert to make sure hash table doesn't grow beyond UINT_MAX nodes
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.

4 years agoauth: db-lua - Deref script in auth_lua_call_userdb_iterate_init() only once
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 22:48:37 +0000 (17:48 -0500)] 
auth: db-lua - Deref script in auth_lua_call_userdb_iterate_init() only once

4 years agoauth: db-lua - Deref script in auth_lua_call_userdb_lookup() only once
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 22:47:57 +0000 (17:47 -0500)] 
auth: db-lua - Deref script in auth_lua_call_userdb_lookup() only once

4 years agoauth: db-lua - Deref script in auth_lua_call_passdb_lookup() only once
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 22:47:03 +0000 (17:47 -0500)] 
auth: db-lua - Deref script in auth_lua_call_passdb_lookup() only once

4 years agoauth: db-lua - Deref script in auth_lua_call_password_verify() only once
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 22:46:20 +0000 (17:46 -0500)] 
auth: db-lua - Deref script in auth_lua_call_password_verify() only once

4 years agoauth: db-lua - Make auth_lua_dovecot_auth_register() take lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 22:44:16 +0000 (17:44 -0500)] 
auth: db-lua - Make auth_lua_dovecot_auth_register() take lua_State * directly

4 years agoauth: db-lua - Make auth_lua_auth_request_register() take lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 22:43:36 +0000 (17:43 -0500)] 
auth: db-lua - Make auth_lua_auth_request_register() take lua_State * directly

4 years agoauth: db-lua - Make auth_lua_call_lookup_finish() take lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 22:39:24 +0000 (17:39 -0500)] 
auth: db-lua - Make auth_lua_call_lookup_finish() take lua_State * directly

4 years agoauth: db-lua - Make auth_lua_export_passdb_table() take lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 22:37:10 +0000 (17:37 -0500)] 
auth: db-lua - Make auth_lua_export_passdb_table() take lua_State * directly

4 years agoauth: db-lua - Make auth_lua_call_lookup() take lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 22:35:21 +0000 (17:35 -0500)] 
auth: db-lua - Make auth_lua_call_lookup() take lua_State * directly

4 years agoauth: db-lua - Make auth_lua_export_userdb_table() take lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 22:32:50 +0000 (17:32 -0500)] 
auth: db-lua - Make auth_lua_export_userdb_table() take lua_State * directly

4 years agoauth: db-lua - Make auth_lua_export_table() take lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 22:31:59 +0000 (17:31 -0500)] 
auth: db-lua - Make auth_lua_export_table() take lua_State * directly

4 years agoauth: db-lua - Make auth_lua_push_auth_request() take lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 22:30:38 +0000 (17:30 -0500)] 
auth: db-lua - Make auth_lua_push_auth_request() take lua_State * directly

4 years agoauth: db-lua - Make lua methods and functions use the passed in lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 21:53:08 +0000 (16:53 -0500)] 
auth: db-lua - Make lua methods and functions use the passed in lua_State * directly

4 years agoauth: db-lua - Make auth_lua_check_auth_request() take lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 21:50:50 +0000 (16:50 -0500)] 
auth: db-lua - Make auth_lua_check_auth_request() take lua_State * directly

4 years agolib-lua: Use dlua_register()
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 21:43:19 +0000 (16:43 -0500)] 
lib-lua: Use dlua_register()

4 years agolib-lua: Add dlua_register()
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 21:41:21 +0000 (16:41 -0500)] 
lib-lua: Add dlua_register()

4 years agolib-storage: Make lua methods and functions use the passed in lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 00:54:10 +0000 (19:54 -0500)] 
lib-storage: Make lua methods and functions use the passed in lua_State * directly

4 years agolib-storage: Make lua_storage_mail_user_set_metadata_unset() take lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 01:01:30 +0000 (20:01 -0500)] 
lib-storage: Make lua_storage_mail_user_set_metadata_unset() take lua_State * directly

4 years agolib-storage: Make lua_check_storage_mail_user() take lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 00:59:13 +0000 (19:59 -0500)] 
lib-storage: Make lua_check_storage_mail_user() take lua_State * directly

4 years agolib-storage: Make lua_check_storage_mail() take lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 00:51:57 +0000 (19:51 -0500)] 
lib-storage: Make lua_check_storage_mail() take lua_State * directly

4 years agolib-lua: Make dlua_dump_stack() take lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 18:07:52 +0000 (13:07 -0500)] 
lib-lua: Make dlua_dump_stack() take lua_State * directly

4 years agolib-lua: Move dlua_dump_stack() prototype to private header
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 18:06:57 +0000 (13:06 -0500)] 
lib-lua: Move dlua_dump_stack() prototype to private header

4 years agolib-lua: Make dlua_check_event() take lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 18:00:10 +0000 (13:00 -0500)] 
lib-lua: Make dlua_check_event() take lua_State * directly

4 years agolib-lua: Make dlua_push_event() take lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 18:00:00 +0000 (13:00 -0500)] 
lib-lua: Make dlua_push_event() take lua_State * directly

4 years agolib-lua: Move dlua_{check,push}_event() prototypes to private header
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 17:57:26 +0000 (12:57 -0500)] 
lib-lua: Move dlua_{check,push}_event() prototypes to private header

4 years agolib-lua: Make dlua_getdovecot() take lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 17:55:25 +0000 (12:55 -0500)] 
lib-lua: Make dlua_getdovecot() take lua_State * directly

4 years agolib-lua: Make dlua_setmembers() take lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 17:53:44 +0000 (12:53 -0500)] 
lib-lua: Make dlua_setmembers() take lua_State * directly

4 years agolib-lua: Make lua methods and functions use the passed in lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 00:23:13 +0000 (19:23 -0500)] 
lib-lua: Make lua methods and functions use the passed in lua_State * directly

4 years agolib-lua: Make dlua_push_event_passthrough() take lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 00:33:55 +0000 (19:33 -0500)] 
lib-lua: Make dlua_push_event_passthrough() take lua_State * directly

4 years agolib-lua: Make dlua_check_event_passthrough() take lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 00:32:19 +0000 (19:32 -0500)] 
lib-lua: Make dlua_check_event_passthrough() take lua_State * directly

4 years agolib-lua: Make dlua_event_log() take lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 00:18:33 +0000 (19:18 -0500)] 
lib-lua: Make dlua_event_log() take lua_State * directly

4 years agolib-lua: Make dlua_get_file_line() take lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 00:16:44 +0000 (19:16 -0500)] 
lib-lua: Make dlua_get_file_line() take lua_State * directly

4 years agolib-lua: Make DLUA_REQUIRE_ARGS*() take the lua_State * directly
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 00:05:04 +0000 (19:05 -0500)] 
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.

4 years agoimap: test-imap-client-hibernate - Remove dead assignment
Timo Sirainen [Wed, 13 Jan 2021 10:54:09 +0000 (12:54 +0200)] 
imap: test-imap-client-hibernate - Remove dead assignment

4 years agoutil: dovecot-sysreport: Use "uname -n" instead of "hostname" for portability
Geert Hendrickx [Fri, 9 Oct 2020 19:07:40 +0000 (21:07 +0200)] 
util: dovecot-sysreport: Use "uname -n" instead of "hostname" for portability

hostname is not defined by POSIX, so not guaranteed to work.

4 years agolib-mail: mail-html2text: HTML entity lookup must be case-sensitive
Siavash Tavakoli [Wed, 23 Dec 2020 12:50:33 +0000 (12:50 +0000)] 
lib-mail: mail-html2text: HTML entity lookup must be case-sensitive

HTML entities are case-sensitive.

4 years agolib-storage: Add unit test for mailbox-list error handling
Timo Sirainen [Thu, 30 Jan 2020 11:50:30 +0000 (13:50 +0200)] 
lib-storage: Add unit test for mailbox-list error handling

This is exactly the same test as what mail-storage has for its error
handling.

4 years agolib-storage: test-mail-storage - Split overlong lines
Timo Sirainen [Sat, 22 Feb 2020 10:01:45 +0000 (12:01 +0200)] 
lib-storage: test-mail-storage - Split overlong lines

4 years agolib-storage: Change mailbox_list_set_error/critical() to work the same as storage's
Timo Sirainen [Thu, 30 Jan 2020 11:48:26 +0000 (13:48 +0200)] 
lib-storage: Change mailbox_list_set_error/critical() to work the same as storage's

The storage ones had various fixes to different situations. Just make the
mailbox list ones exactly the same to get the same fixes.

4 years agolib-storage: mailbox_list_get_last_error() - Handle unexpected situations better
Timo Sirainen [Fri, 24 Jan 2020 11:50:50 +0000 (13:50 +0200)] 
lib-storage: mailbox_list_get_last_error() - Handle unexpected situations better

Change the logic to be similar as in mail_storage_get_last_error() if the
mail_error or error_string unexpectedly isn't set.

4 years agolib-storage: Detect corrupted mail size when calculating body size
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.

4 years agostats: openmetrics: Do not duplicate counter and duration metrics for histograms
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.

4 years agostats: Make exported metrics compliant with OpenMetrics standards
Manuel Rüger [Mon, 23 Nov 2020 18:22:22 +0000 (18:22 +0000)] 
stats: Make exported metrics compliant with OpenMetrics standards

Commit based on github PR: https://github.com/dovecot/core/pull/136

Fix issues raised by promtool and prometheus client library parser.
Cleanup and code fixes by Siavash Tavakoli.

4 years agoindexer, auth: Set indexer-worker and auth-worker services' type=worker
Timo Sirainen [Tue, 22 Dec 2020 11:23:45 +0000 (13:23 +0200)] 
indexer, auth: Set indexer-worker and auth-worker services' type=worker

4 years agolib-master, master: Add "worker" service type
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.

4 years agomaster: Split off service_log_drop_warning()
Timo Sirainen [Mon, 21 Dec 2020 19:23:32 +0000 (21:23 +0200)] 
master: Split off service_log_drop_warning()

4 years agomaster: Update comment to service_process.total_count
Timo Sirainen [Thu, 16 Jan 2020 13:03:28 +0000 (15:03 +0200)] 
master: Update comment to service_process.total_count

It's not an exact value. Making it exact would require changing the IPC
protocol to master, which isn't worth it just for this.

4 years agolib-master: Notify master immediately when process can accept more clients
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.

4 years agolib-mail: message-snippet: Fix expected number of leading non-whitespace chars
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.

4 years agoauth: Log failure before freeing up request
Aki Tuomi [Thu, 7 Jan 2021 12:57:23 +0000 (14:57 +0200)] 
auth: Log failure before freeing up request

The request got free'd before logging, causing use-after-free access.

Broken in cec5a9c92d094d639c49bb83eeb9383ebb231c6f

4 years agoimap: cmd-setmetadata: Do not open mailbox
Siavash Tavakoli [Wed, 9 Dec 2020 01:31:30 +0000 (01:31 +0000)] 
imap: cmd-setmetadata: Do not open mailbox

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.

4 years agoimap: cmd-getmetadata: Retrieve metadata values without opening the mailbox
Siavash Tavakoli [Tue, 1 Dec 2020 17:21:03 +0000 (17:21 +0000)] 
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"

4 years agoimap: cmd-getmetadata: Do not ignore NOTFOUND and PERM when handling errors
Siavash Tavakoli [Wed, 9 Dec 2020 01:08:30 +0000 (01:08 +0000)] 
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.

4 years agodoveadm mailbox metadata: Don't open mailbox for get and list commands
Siavash Tavakoli [Tue, 1 Dec 2020 17:23:31 +0000 (17:23 +0000)] 
doveadm mailbox metadata: Don't open mailbox for get and list commands

4 years agolib-storage: Move checking autocreated boxes to storage backends
Siavash Tavakoli [Wed, 16 Dec 2020 10:08:11 +0000 (10:08 +0000)] 
lib-storage: Move checking autocreated boxes to storage backends

This allows acl plugin to check ACLs for autocreated mailboxes as well.

4 years agolib-storage: index-attribute: Fix typo
Siavash Tavakoli [Wed, 9 Dec 2020 00:58:17 +0000 (00:58 +0000)] 
lib-storage: index-attribute: Fix typo

4 years agodoveadm: doveadm-mail-mailbox-metadata: Add flag for prefixes in metadata list
Siavash Tavakoli [Tue, 1 Dec 2020 10:11:40 +0000 (10:11 +0000)] 
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.

4 years agolib-mail: test-message-search - Avoid static analyzer warnings about NULL pointers
Timo Sirainen [Wed, 16 Dec 2020 14:50:43 +0000 (16:50 +0200)] 
lib-mail: test-message-search - Avoid static analyzer warnings about NULL pointers

4 years agodsync: Add assert to help static analyzers
Timo Sirainen [Wed, 16 Dec 2020 14:47:38 +0000 (16:47 +0200)] 
dsync: Add assert to help static analyzers

4 years agocassandra: Fix error handling on SSL initialization failure
Timo Sirainen [Wed, 16 Dec 2020 14:21:40 +0000 (16:21 +0200)] 
cassandra: Fix error handling on SSL initialization failure

4 years agolib: istream-file,ostream-file - Mark close failure as unlikely
Aki Tuomi [Mon, 11 Jan 2021 09:04:57 +0000 (11:04 +0200)] 
lib: istream-file,ostream-file - Mark close failure as unlikely

File descriptor close failure is unlikely to happen.

4 years agolib: istream-file,ostream-file - Ignore ECONNRESET
Aki Tuomi [Mon, 21 Dec 2020 09:51:36 +0000 (11:51 +0200)] 
lib: istream-file,ostream-file - Ignore ECONNRESET

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.

4 years agolib: fd-util - Ignore ECONNRESET when closing fd
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.

4 years agolib-lua: Log an error when lua deinit function failed
Josef 'Jeff' Sipek [Thu, 17 Dec 2020 14:21:38 +0000 (09:21 -0500)] 
lib-lua: Log an error when lua deinit function failed

4 years agolib-lua: Move init/deinit function invocation into helper functions
Josef 'Jeff' Sipek [Fri, 11 Dec 2020 19:43:17 +0000 (14:43 -0500)] 
lib-lua: Move init/deinit function invocation into helper functions

This moves them out of the way and keeps them close to each other.