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.
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.
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.
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.
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.
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.
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.
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).
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.
Stephan Bosch [Tue, 2 Jul 2019 18:50:07 +0000 (20:50 +0200)]
lib: event-log - Add support for inserting a prefix in event_logv().
The prefix is provided in the event_logv() call and not attached to the event
hierarchy. It is inserted at the position indicated by the base_event.
Different prefixes can be provided for the message appended to the string buffer
and the sent event message.
Stephan Bosch [Sun, 30 Jun 2019 09:45:16 +0000 (11:45 +0200)]
lib: event-log - Add support for appending part of the log message to a string buffer while sending the event.
The message appended to the string buffer includes prefixes and message callback
modifications by parent events up until a specified base event. The event is
otherwise sent as normal with the full prefixes and all modifications up to the
root event, so in that respect this new feature behaves just like event_log*().
This is primarily useful to mimic (part of) event logging in parallel logs that
are visible to users. It is also possible to inhibit sending the event and only
log to the string buffer.
Stephan Bosch [Mon, 1 Jul 2019 23:04:03 +0000 (19:04 -0400)]
lib-http: guard against hshared use-after-free
This fixes a race condition where the http_client_host_shared_idle_timeout()
function would get called with an already freed hshared argument.
Specifically, the situation arises from the hshared idle timeout calling
http_client_host_shared_free(), which removes the timeout and then proceeds to
free the client queue. The client queue freeing code indirectly calls
http_client_host_shared_check_idle(), which notices that there is no idle
timeout and allocates one.
The backtrace at the point of this new timeout allocation:
frame #3: 0x00007f0c775897f0 libdovecot.so.0`timeout_add_to(...) ioloop.c:280
frame #4: 0x00007f0c7751a45f libdovecot.so.0`http_client_host_shared_check_idle(hshared=<unavailable>) at http-client-host.c:69
frame #5: 0x00007f0c7750de89 libdovecot.so.0`http_client_request_error(_req=<unavailable>, status=9000, error="") at http-client-request.c:1525
frame #6: 0x00007f0c77517f38 libdovecot.so.0`http_client_queue_fail_full(queue=0x000055e13cff0e10, status=9000, error="", all=<unavailable>) at http-client-queue.c:183
frame #7: 0x00007f0c77518baa libdovecot.so.0`http_client_queue_free(queue=0x000055e13cff0e10) at http-client-queue.c:141
frame #8: 0x00007f0c7751a8bc libdovecot.so.0`http_client_host_free_shared(_host=<unavailable>) at http-client-host.c:391
frame #9: 0x00007f0c7751ab4c libdovecot.so.0`http_client_host_shared_free(_hshared=0x00007ffdac109e48) at http-client-host.c:294
frame #10: 0x00007f0c7751ace8 libdovecot.so.0`http_client_host_shared_idle_timeout(hshared=<unavailable>) at http-client-host.c:40
frame #11: 0x00007f0c7758a1a4 libdovecot.so.0`io_loop_handle_timeouts at ioloop.c:682
frame #12: 0x00007f0c7758a089 libdovecot.so.0`io_loop_handle_timeouts(ioloop=0x000055e13cfc8d80) at ioloop.c:696
frame #13: 0x00007f0c7758befc libdovecot.so.0`io_loop_handler_run_internal(ioloop=0x000055e13cfc8d80) at ioloop-select.c:126
frame #14: 0x00007f0c7758a56d libdovecot.so.0`io_loop_handler_run(ioloop=<unavailable>) at ioloop.c:767
frame #15: 0x00007f0c7758a798 libdovecot.so.0`io_loop_run(ioloop=0x000055e13cfc8d80) at ioloop.c:740
frame #16: 0x00007f0c774f61eb libdovecot.so.0`master_service_run(service=0x000055e13cfc8c10, callback=<unavailable>) at master-service.c:782
frame #17: 0x000055e13b48e3a5 stats`main(argc=<unavailable>, argv=<unavailable>) at main.c:99
frame #18: 0x00007f0c771092e1 libc.so.6`__libc_start_main + 241
frame #19: 0x000055e13b48e41a stats`_start + 42
Timo Sirainen [Mon, 8 Jul 2019 15:59:21 +0000 (18:59 +0300)]
lib-index: Fix using old map when checking for unexpected changes during log rotate
This shouldn't normally be possible. The log is locked, so other processes
shouldn't be able to write anything to it. This was mainly found by the
earlier bug.
Timo Sirainen [Mon, 8 Jul 2019 15:56:12 +0000 (18:56 +0300)]
lib-index: After recreating cache, make sure offsets are immediately updated to map
They were most likely refreshed anyway before the next cache usage, but this
caused an assert-crash if the dovecot.index was also recreated in the same
sync.