]> git.ipfire.org Git - thirdparty/dovecot/core.git/log
thirdparty/dovecot/core.git
7 years agolib-storage: Replace "if(mail_debug){i_debug}" "e_debug"
Sergey Kitov [Tue, 20 Mar 2018 09:05:13 +0000 (11:05 +0200)] 
lib-storage: Replace "if(mail_debug){i_debug}" "e_debug"

7 years agolib-storage: Force mail_storage_service_user event debug when mail_debug=yes
Sergey Kitov [Thu, 24 May 2018 12:18:30 +0000 (15:18 +0300)] 
lib-storage: Force mail_storage_service_user event debug when mail_debug=yes

7 years agolda & lib-lda: "if(mail_debug){i_debug}" with "e_debug"
Sergey Kitov [Tue, 20 Mar 2018 08:51:21 +0000 (10:51 +0200)] 
lda & lib-lda: "if(mail_debug){i_debug}" with "e_debug"

7 years agoindexer: Replace "if(mail_debug){i_debug}" with "e_debug"
Sergey Kitov [Tue, 20 Mar 2018 08:49:08 +0000 (10:49 +0200)] 
indexer: Replace "if(mail_debug){i_debug}" with "e_debug"

7 years agoimap: Replace "if(mail_debug){i_debug}" with "e_debug"
Sergey Kitov [Tue, 20 Mar 2018 08:46:19 +0000 (10:46 +0200)] 
imap: Replace "if(mail_debug){i_debug}" with "e_debug"

7 years agolib-imap-urlauth & imap-urlauth: replace "if(mail_debug){i_debug}" with "e_debug...
Sergey Kitov [Tue, 20 Mar 2018 08:17:27 +0000 (10:17 +0200)] 
lib-imap-urlauth & imap-urlauth: replace "if(mail_debug){i_debug}" with "e_debug(client->event)"

7 years agoimap-urlauth: Add event with "imap-urlauth" category to struct client of imap-urlauth
Sergey Kitov [Tue, 20 Mar 2018 07:52:38 +0000 (09:52 +0200)] 
imap-urlauth: Add event with "imap-urlauth" category to struct client of imap-urlauth

7 years agoglobal: Replace check for auth_debug with event_want_debug_log in doveadm-auth::auth_...
Sergey Kitov [Tue, 20 Mar 2018 07:05:26 +0000 (09:05 +0200)] 
global: Replace check for auth_debug with event_want_debug_log in doveadm-auth::auth_connected()

These functions will create event with "auth" category and unref it in
the end.

7 years agoglobal: Replace "if(auth_debug){i_debug(...)}" with e_debug(event, ...)
Sergey Kitov [Mon, 19 Mar 2018 14:10:49 +0000 (16:10 +0200)] 
global: Replace "if(auth_debug){i_debug(...)}" with e_debug(event, ...)

event is one of: global auth::auth_event,
auth_client_connection->event, auth_request->event,
login-common::event_auth. These event have category "auth".

7 years agoglobal: Remove unnecessary checks for mail_debug and auth_request->debug
Sergey Kitov [Mon, 19 Mar 2018 12:50:31 +0000 (14:50 +0200)] 
global: Remove unnecessary checks for mail_debug and auth_request->debug

These checks are performed before calling auth_request_log_debug() and
push_notification_driver_debug(), while the same checks are performed
inside of these functions, and they return without doing anything.

7 years agoauth: Add event with category "auth" to struct auth_request.
Sergey Kitov [Mon, 19 Mar 2018 11:53:33 +0000 (13:53 +0200)] 
auth: Add event with category "auth" to struct auth_request.

7 years agoauth: Add event with category "auth" to struct auth_client_connection.
Sergey Kitov [Mon, 19 Mar 2018 10:16:23 +0000 (12:16 +0200)] 
auth: Add event with category "auth" to struct auth_client_connection.

7 years agologin-common: Add global event_auth with "auth" category.
Sergey Kitov [Mon, 19 Mar 2018 09:44:59 +0000 (11:44 +0200)] 
login-common: Add global event_auth with "auth" category.

7 years agolib: Add event_want_debug and event_want_debug_log macros
Sergey Kitov [Mon, 19 Mar 2018 09:20:58 +0000 (11:20 +0200)] 
lib: Add event_want_debug and event_want_debug_log macros

7 years agoauth: Add global auth_event with category "auth".
Sergey Kitov [Mon, 19 Mar 2018 09:14:22 +0000 (11:14 +0200)] 
auth: Add global auth_event with category "auth".

7 years agopush-notification: Add SSL support for OX driver
Michael Slusarz [Fri, 25 May 2018 03:43:42 +0000 (21:43 -0600)] 
push-notification: Add SSL support for OX driver

7 years agoconfig: generation of clean config should copy sensitive data
Michael M Slusarz [Tue, 31 Jul 2018 22:32:48 +0000 (16:32 -0600)] 
config: generation of clean config should copy sensitive data

Add -P parameter to the CLI warning doveconf example

7 years agolib: bits - macros to simplify expressions when using -Wstrict-bool
Phil Carmody [Fri, 11 May 2018 06:19:21 +0000 (09:19 +0300)] 
lib: bits - macros to simplify expressions when using -Wstrict-bool

To be strict-bool compliant, your expressions need to be a bit verbose,
these might simplify things.

There are presently over 400 instances matching HAS_NO_BITS(), and nearly
1300 instances matching HAS_ANY_BITS(), so it's a very common pattern.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
7 years agolib-storage: Harden check for imapdir list name
Josef 'Jeff' Sipek [Fri, 11 May 2018 14:53:46 +0000 (10:53 -0400)] 
lib-storage: Harden check for imapdir list name

Comparing char pointers to determine string equality is asking for trouble.
Use strcmp() instead.

7 years agoauth: Use PRIuUOFF_t to print process VSZ limit
Josef 'Jeff' Sipek [Fri, 11 May 2018 14:41:01 +0000 (10:41 -0400)] 
auth: Use PRIuUOFF_t to print process VSZ limit

This doesn't change the behavior, but it makes it more obviously correct.

7 years agoauth: Avoid comparison of ints of different signs on FreeBSD
Josef 'Jeff' Sipek [Fri, 11 May 2018 14:38:32 +0000 (10:38 -0400)] 
auth: Avoid comparison of ints of different signs on FreeBSD

For legacy reasons, rlim_t on FreeBSD is defined as int64_t.

7 years agolib-storage: Return correct root path for PATH_TYPE_ALT_MAILBOX
Josef 'Jeff' Sipek [Fri, 11 May 2018 14:50:16 +0000 (10:50 -0400)] 
lib-storage: Return correct root path for PATH_TYPE_ALT_MAILBOX

mailbox_list_set_get_root_path(..., MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX, ...)
must return one of three values:

1. if there is no alt storage, return NULL
2. if there is alt storage and MAILBOXDIR is set,
return ${alt_dir}/${mailbox_dir_name}
3. if there is alt storage but MAILBOXDIR is not set, return ${alt_dir}

Case number 3 was broken, and it mistakenly returned ${root_dir} - in other
words, it behaved as MAILBOX_LIST_PATH_TYPE_MAILBOX.

This correction changes the behavior, but this shouldn't cause
incompatibilities since:

1. it affects only storages that support alternate storage
2. it affects only configurations that use empty MAILBOXDIR

The only storage that supports alternate storage setting is dbox but dbox
defaults to MAILBOXDIR=mailboxes.  Additionally, it appears to be impossible
to override it to an empty string (setting it to an empty strings causes
dbox to override it with the default - "mailboxes").  Therefore, nobody
should be affected by this change.

7 years agodoveadm stats dump: Add stddev field
Timo Sirainen [Tue, 24 Apr 2018 14:22:00 +0000 (17:22 +0300)] 
doveadm stats dump: Add stddev field

Include it in default output as well.

7 years agodoveadm stats dump: Add -f <fields> parameter
Timo Sirainen [Tue, 24 Apr 2018 13:29:49 +0000 (16:29 +0300)] 
doveadm stats dump: Add -f <fields> parameter

This allows specifying which fields are wanted to be dumped.

7 years agostats: Support dumping any given percentile
Timo Sirainen [Tue, 24 Apr 2018 14:32:21 +0000 (17:32 +0300)] 
stats: Support dumping any given percentile

7 years agostats: Support dumping variance
Timo Sirainen [Tue, 24 Apr 2018 06:52:32 +0000 (09:52 +0300)] 
stats: Support dumping variance

7 years agolib: Add test for rng
Aki Tuomi [Sun, 25 Mar 2018 16:54:48 +0000 (19:54 +0300)] 
lib: Add test for rng

7 years agolib: stats-dist - Add accessor for samples
Aki Tuomi [Sun, 25 Mar 2018 18:04:49 +0000 (21:04 +0300)] 
lib: stats-dist - Add accessor for samples

7 years agolib: stats-dist - Add variance
Aki Tuomi [Sun, 25 Mar 2018 16:59:15 +0000 (19:59 +0300)] 
lib: stats-dist - Add variance

7 years agolib: rand - Fix potential modulo bias
Aki Tuomi [Sun, 25 Mar 2018 16:49:13 +0000 (19:49 +0300)] 
lib: rand - Fix potential modulo bias

7 years agoexample-config: Add log_debug and log_core_filter
Timo Sirainen [Thu, 26 Apr 2018 18:35:15 +0000 (21:35 +0300)] 
example-config: Add log_debug and log_core_filter

7 years agolib-master: Add improved log filter parsing
Timo Sirainen [Mon, 16 Apr 2018 12:00:27 +0000 (15:00 +0300)] 
lib-master: Add improved log filter parsing

It now supports parenthesis to perform ANDs within a query. For example:
"(ruleA1 ruleA2) ruleB (ruleC1 ruleC2 ruleC3)" has 3 ORed rules.

Rules can contain:

 - event:<name>
 - source:<filename>[:<line number>]
 - field:<key>=<value> can be used multiple times
 - cat[egory]:<value> can be used multiple times

For example:

event:http_request_finished (cat:error cat:storage)

This matches either the "http_request_finished" named event, or
alternatively any error event that belongs to "storage" category.

7 years agolib: Event filter - Source line number 0 now means "any"
Timo Sirainen [Thu, 26 Apr 2018 18:29:23 +0000 (21:29 +0300)] 
lib: Event filter - Source line number 0 now means "any"

7 years agolib: Event filter - Support wildcards in event names
Timo Sirainen [Thu, 26 Apr 2018 18:21:40 +0000 (21:21 +0300)] 
lib: Event filter - Support wildcards in event names

This allows for example log_debug=event:*

7 years agolib-master: Move const char *error declaration inside ifdef HAVE_SSL
Martti Rannanjärvi [Thu, 24 May 2018 11:55:59 +0000 (14:55 +0300)] 
lib-master: Move const char *error declaration inside ifdef HAVE_SSL

This is so you can compile dovecot without ssl.

7 years agolib-master: Add own boolean for SSL module loading
Aki Tuomi [Wed, 11 Apr 2018 12:27:42 +0000 (15:27 +0300)] 
lib-master: Add own boolean for SSL module loading

want_ssl_settings isn't reliable enough.

7 years agolib-master: Do not attempt to load SSL module if no SSL support is compiled in
Aki Tuomi [Tue, 10 Apr 2018 13:00:38 +0000 (16:00 +0300)] 
lib-master: Do not attempt to load SSL module if no SSL support is compiled in

Fixes imap-login: Error: imap-login(init): Fatal: Cannot load SSL module: SSL support not compiled in

Broken in 754896551f0422cda5d78500b26700eec5343c5b

Found by bjornar

7 years agolib-http: client: Fix request statistics text to properly report send attempts.
Stephan Bosch [Tue, 27 Feb 2018 09:45:26 +0000 (10:45 +0100)] 
lib-http: client: Fix request statistics text to properly report send attempts.

If the request was first sent in the same ioloop cycle in which the text is
generated, the text would claim it was not sent at all yet.

With this commit the text now explicitly makes the distinction between request
attempts and actual send attempts. The number of attempts is increased at each
retry, while the send attempts are increased each time the request is actually
being sent to a server.

7 years agoconfigure: Add spectre variant 2 mitigations
codarrenvelvindron [Sat, 17 Feb 2018 19:28:48 +0000 (14:28 -0500)] 
configure: Add spectre variant 2 mitigations

--enable-hardening adds -mfunction-return=thunk and -mindirect-branch=thunk
compiler options if supported.

7 years agoimapc: Avoid duplicate FETCH BODY.PEEK[] when mail is already expunged
Timo Sirainen [Thu, 22 Feb 2018 13:55:20 +0000 (15:55 +0200)] 
imapc: Avoid duplicate FETCH BODY.PEEK[] when mail is already expunged

When the first FETCH (e.g. as part of mail_prefetch()) indicated that the
mail is already expunged, there's no need to do it again.

7 years agolib: Fix usec comparison in timeout_update_next
Aki Tuomi [Tue, 13 Feb 2018 07:14:37 +0000 (09:14 +0200)] 
lib: Fix usec comparison in timeout_update_next

When tv_usec is exactly 1000000, call to kevent() will fail
because tv_sec does not get incremented.

Found by Adrian Gonzalez <adrianglz@globalpc.net>

7 years agolib: Fix ioloop-poll and ioloop-select to work with io_add_istream()
Timo Sirainen [Sun, 20 May 2018 22:42:27 +0000 (01:42 +0300)] 
lib: Fix ioloop-poll and ioloop-select to work with io_add_istream()

7 years agolib-storage: Add mail_storage.event and use it wherever possible
Timo Sirainen [Mon, 16 Apr 2018 12:22:41 +0000 (15:22 +0300)] 
lib-storage: Add mail_storage.event and use it wherever possible

7 years agoauth: Fix assert-crash if auth client sends 0 as ID
Timo Sirainen [Sun, 20 May 2018 18:32:12 +0000 (21:32 +0300)] 
auth: Fix assert-crash if auth client sends 0 as ID

This could be triggered by anyone having (local) write access to the auth
socket.

7 years agolib-imap: Remove content_subtype==NULL checks
Timo Sirainen [Tue, 24 Jul 2018 12:00:19 +0000 (15:00 +0300)] 
lib-imap: Remove content_subtype==NULL checks

This can never happen after the previous commit. This also changes the
BODYSTRUCTURE output for invalid Content-Types, but since they're invalid
anyway it doesn't really matter what the output is.

7 years agolib-mail: If message_part_data.content_type is set, make sure content_subtype isn...
Timo Sirainen [Tue, 24 Jul 2018 11:55:25 +0000 (14:55 +0300)] 
lib-mail: If message_part_data.content_type is set, make sure content_subtype isn't NULL

This fixes a crash in index_mail_find_first_text_mime_part() where snippet
generation assumed that content_subtype isn't NULL.

7 years agolib-storage: Fix bodystructure parsing crash if header is parsed twice
Timo Sirainen [Wed, 25 Jul 2018 10:17:45 +0000 (13:17 +0300)] 
lib-storage: Fix bodystructure parsing crash if header is parsed twice

The second parsing will recreate the parser_ctx, discarding the old parsed
message_part.data for the header. On the second parsing
save_bodystructure_header=FALSE so the message_part.data isn't filled for
the header. Later on the bodystructure parsing assumes the data is set,
and crashes.

This only happened with mail_attachment_detection_options=add-flags-on-save
and Sieve script that first accessed a non-cached header and then used the
"body" extension.

Fixes segfault and also:
Panic: file imap-bodystructure.c: line 116 (part_write_body_multipart): assertion failed: (part->data != NULL)

7 years agolib-mail: Add asserts to message_part_*() to make sure part->data isn't NULL
Timo Sirainen [Wed, 25 Jul 2018 10:17:05 +0000 (13:17 +0300)] 
lib-mail: Add asserts to message_part_*() to make sure part->data isn't NULL

This makes it easier to debug the crashes than just having a segfault.

7 years agolib-ssl-iostream: Enable partial writes and moving buffers
Aki Tuomi [Wed, 20 Jun 2018 05:52:52 +0000 (08:52 +0300)] 
lib-ssl-iostream: Enable partial writes and moving buffers

Dovecot is able to provide same content to SSL_write, and
can also take care of consuming written data from the buffer.

Fixes SSL_write failed:error:1409F07F:SSL routines:SSL3_WRITE_PENDING:bad write retry

7 years agoquota-clone: Fix assert-crash at deinit if quota_clone update fails
Timo Sirainen [Tue, 26 Jun 2018 19:33:33 +0000 (22:33 +0300)] 
quota-clone: Fix assert-crash at deinit if quota_clone update fails

The timeout isn't removed on failure, so it crashed with:
Panic: file quota-clone-plugin.c: line 257 (quota_clone_mail_user_deinit_pre): assertion failed: (quser->to_quota_flush == NULL)

7 years agoquota-clone: Send quota clone data to dict asynchronously
Timo Sirainen [Tue, 19 Jun 2018 12:46:41 +0000 (15:46 +0300)] 
quota-clone: Send quota clone data to dict asynchronously

Based on patch by Michael Slusarz

7 years agoquota-clone: Move state tracking to user context
Timo Sirainen [Tue, 19 Jun 2018 12:00:02 +0000 (15:00 +0300)] 
quota-clone: Move state tracking to user context

This way there's no need to do multiple flushes when e.g. multiple
mailboxes change.

The flush had to be removed from close(), because the code path recurses:

 * mailbox_transaction_commit() when mail is saved
 * quota_count() starts counting the quota, which opens and closes mailbox
 * quota_clone_mailbox_close() attempts to flush quota, which again recurses
into quota_count(), which returns 0 for the quota value.

Based on patch by Michael Slusarz

7 years agoquota: Add quota_root_iter_init_user()
Timo Sirainen [Tue, 19 Jun 2018 11:12:45 +0000 (14:12 +0300)] 
quota: Add quota_root_iter_init_user()

7 years agoquota-clone: Fix CONTEXT_REQUIRE use
Aki Tuomi [Mon, 28 May 2018 09:57:03 +0000 (12:57 +0300)] 
quota-clone: Fix CONTEXT_REQUIRE use

Fixes Panic: Module context quota_clone_user_module missing

Broken in 7f7e7c16d956de8e92376a0633ca6e4cb85e8d84

7 years agovirtual: Clamp backend uids to available uids in virtual_get_virtual_uids
Aki Tuomi [Mon, 25 Jun 2018 10:13:43 +0000 (13:13 +0300)] 
virtual: Clamp backend uids to available uids in virtual_get_virtual_uids

7 years agoacl: Fix return value of acl_attribute_get_acl
Aki Tuomi [Thu, 24 May 2018 12:48:58 +0000 (12:48 +0000)] 
acl: Fix return value of acl_attribute_get_acl

If matching acl entry is not found, it must return 0
and not 1 because it did not find anything.

Fixes dsync: Panic: file mailbox-attribute.c: line 362 (mailbox_attribute_get_stream): assertion failed: (value_r->value != NULL || value_r->value_stream != NULL)

Broken in 37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3a

Found by @dl8bh

7 years agoman: doveadm-search-query.7 - Add sequence-set and update UID
Timo Sirainen [Tue, 29 May 2018 21:38:45 +0000 (00:38 +0300)] 
man: doveadm-search-query.7 - Add sequence-set and update UID

7 years agolast-login: Remove superfluous semicolon
Michael Slusarz [Mon, 16 Apr 2018 16:38:21 +0000 (10:38 -0600)] 
last-login: Remove superfluous semicolon

7 years agolast-login: Username is already output as part of log prefix
Michael Slusarz [Mon, 16 Apr 2018 16:37:32 +0000 (10:37 -0600)] 
last-login: Username is already output as part of log prefix

7 years agodirector: Make sure host's last_updown_change never shrinks.
Timo Sirainen [Sun, 20 May 2018 15:20:47 +0000 (18:20 +0300)] 
director: Make sure host's last_updown_change never shrinks.

Otherwise the ring might get into a loop where two HOST updates keep
fighting each others. This could probably happen if one update comes at
"desynced" state and other one in non-desynced state.

I'm not entirely sure if this is fixing such a loop or not, but it at least
shouldn't hurt.

7 years agolib: event-filter - Increase initial allocation
Aki Tuomi [Mon, 25 Jun 2018 11:04:31 +0000 (14:04 +0300)] 
lib: event-filter - Increase initial allocation

Reduces reallocations on startup.

7 years agolib-http: Add/fix default value comments in http_client_settings
Timo Sirainen [Tue, 26 Jun 2018 10:45:54 +0000 (13:45 +0300)] 
lib-http: Add/fix default value comments in http_client_settings

7 years agolib-http: server: Properly handle corrupt payload while finishing a request.
Stephan Bosch [Tue, 20 Mar 2018 17:14:39 +0000 (18:14 +0100)] 
lib-http: server: Properly handle corrupt payload while finishing a request.

The HTTP_REQUEST_PARSE_ERROR_BROKEN_REQUEST was not handled, causing an
assertion panic. This situation occurred when the chunked transfer encoding was
invalid.

7 years agolib-http: server: Properly handle payload stream errors while finishing a request.
Stephan Bosch [Tue, 20 Mar 2018 17:10:42 +0000 (18:10 +0100)] 
lib-http: server: Properly handle payload stream errors while finishing a request.

Errors from the (chunked) payload stream would cause assertion panics at that point.

7 years agolib-http: server: Allow resubmitting a response, as long as it is not sent yet.
Stephan Bosch [Tue, 20 Mar 2018 17:04:36 +0000 (18:04 +0100)] 
lib-http: server: Allow resubmitting a response, as long as it is not sent yet.

7 years agolib-master: If stats process wants no events, send nothing to it
Timo Sirainen [Wed, 23 May 2018 12:14:50 +0000 (15:14 +0300)] 
lib-master: If stats process wants no events, send nothing to it

Instead of sending everything to it..

7 years agolib: istream-try - Don't assert-crash with empty parent istream
Timo Sirainen [Fri, 8 Jun 2018 20:17:04 +0000 (23:17 +0300)] 
lib: istream-try - Don't assert-crash with empty parent istream

Fixes:
Panic: file istream.c: line 327 (i_stream_read_memarea): assertion failed: (stream->eof)

7 years agodovecot.service: Update LimitNOFILE=65535
Hannu Ylitalo [Tue, 29 May 2018 07:29:50 +0000 (10:29 +0300)] 
dovecot.service: Update LimitNOFILE=65535

Current value of 8192 is too low for most production setups and it needs
to be changed every time something is deployed. Setting the default to
65535 is enough for most production environments so this would be one
task less when deploying a production platform.

7 years agodoveadm save: Fix using <file without panic
Timo Sirainen [Mon, 23 Apr 2018 12:05:06 +0000 (15:05 +0300)] 
doveadm save: Fix using <file without panic

When getting input with <file with Linux/epoll, it crashed with:

Panic: epoll_ctl(add, 0) failed: Operation not permitted (fd doesn't support epoll - instead of '<file', try 'cat file|')

7 years agodsync: Set brain->failed to TRUE when UIDVALIDITY changes
Aki Tuomi [Tue, 2 Jan 2018 11:57:45 +0000 (13:57 +0200)] 
dsync: Set brain->failed to TRUE when UIDVALIDITY changes

This happens if UIDVALIDITY changes during stateful sync.

Fixes Panic: doveadm: file dsync-brain-mailbox.c: line 377 (dsync_brain_sync_mailbox_deinit): assertion failed: (brain->failed)

7 years agolib-compression: Fix assert-crash in test suite on 32bit systems
Paul Howarth [Mon, 2 Jul 2018 10:52:14 +0000 (11:52 +0100)] 
lib-compression: Fix assert-crash in test suite on 32bit systems

Fix compilation warnings in test-compression.c due to mismatches
between size_t and uoff_t, which then manifests in assert-crashes
running the test suite on 32bit systems.

7 years agolib-ssl-iostream: Shutdown connection cleanly whenever i/ostream is destroyed
Timo Sirainen [Fri, 6 Jul 2018 08:25:07 +0000 (11:25 +0300)] 
lib-ssl-iostream: Shutdown connection cleanly whenever i/ostream is destroyed

Do this while both istream and ostream still exist. Fixes crash where
openssl_iostream_destroy() attempts to flush the shutdown, but ssl_input
is NULL and it crashes.

7 years agolib-ssl-iostream: Split code to openssl_iostream_shutdown()
Timo Sirainen [Fri, 6 Jul 2018 08:24:41 +0000 (11:24 +0300)] 
lib-ssl-iostream: Split code to openssl_iostream_shutdown()

7 years agolib-storage: Fix memory leak when mail_storage_service_next() is called multiple...
Timo Sirainen [Tue, 12 Jun 2018 13:07:25 +0000 (16:07 +0300)] 
lib-storage: Fix memory leak when mail_storage_service_next() is called multiple times

dsync uses it twice for the same mail_storage_service_user.

7 years agolib-imap-client: Fix crash when ostream output blocks before connection finishes
Timo Sirainen [Mon, 18 Jun 2018 10:15:55 +0000 (13:15 +0300)] 
lib-imap-client: Fix crash when ostream output blocks before connection finishes

It's possible that ostream tries to add IO_WRITE callback before
imapc_connection_connected() callback is called.

Fixes:
Panic: io_add(0x2) called twice fd=15, callback=0x... -> 0x...

7 years agoimapc: Don't trust mail stream to have correct CRLFs
Timo Sirainen [Mon, 18 Jun 2018 16:13:30 +0000 (19:13 +0300)] 
imapc: Don't trust mail stream to have correct CRLFs

It's not that expensive to just recalculate them. If they're not correct in
the stream, it can result in e.g. truncated emails due to wrong virtual_size
being used in body_size calculation. The wrong CRLFs can especially happen
if plugins modify the stream in istream_opened() hook.

7 years agolib-imap-client: Remove assert from imapc_client_mailbox_reconnect
Timo Sirainen [Sat, 16 Jun 2018 16:58:57 +0000 (19:58 +0300)] 
lib-imap-client: Remove assert from imapc_client_mailbox_reconnect

It's possible for the assert to trigger if there are multiple reconnections.
imapc_connection_can_reconnect() checks a bit later whether the reconnection
can still be done.

7 years agoimapc: Fix assert-crash if syncing adds delayed expunges, but fails afterwards
Timo Sirainen [Sat, 16 Jun 2018 16:40:34 +0000 (19:40 +0300)] 
imapc: Fix assert-crash if syncing adds delayed expunges, but fails afterwards

Fixes:
Panic: file imapc-sync.c: line 328 (imapc_initial_sync_check): assertion failed: (mail_index_is_expunged(view, lseq) || seq_range_exists(&ctx->mbox->delayed_expunged_uids, luid))

7 years agoimapc: Fix potential assert-crash when reconnecting during syncing
Timo Sirainen [Sat, 16 Jun 2018 16:37:27 +0000 (19:37 +0300)] 
imapc: Fix potential assert-crash when reconnecting during syncing

Fixes:
Panic: file imapc-sync.c: line 328 (imapc_initial_sync_check): assertion failed: (mail_index_is_expunged(view, lseq) || seq_range_exists(&ctx->mbox->delayed_expunged_uids, luid))

7 years agoimapc: Fix assert-crash when reconnecting during initial FETCH finds expunges
Timo Sirainen [Sat, 16 Jun 2018 12:56:26 +0000 (15:56 +0300)] 
imapc: Fix assert-crash when reconnecting during initial FETCH finds expunges

The initial FETCH is automatically retried on failure, but the FETCH state
wasn't reset during the reconnection.

Fixes:
Panic: file imapc-sync.c: line 328 (imapc_initial_sync_check): assertion failed: (mail_index_is_expunged(view, lseq) || seq_range_exists(&ctx->mbox->delayed_expunged_uids, luid))

7 years agoimapc: Fix assert-crash when reconnecting expunges newly added messages
Timo Sirainen [Sat, 16 Jun 2018 12:09:53 +0000 (15:09 +0300)] 
imapc: Fix assert-crash when reconnecting expunges newly added messages

The initial FETCH 1:* during reconnection may notice some messages that are
missing and tries to expunge them. But those messages could still be in
delayed_sync_trans, and currently lib-index doesn't support expunging anything
but the latest mail from a transaction.

Fixes:
Panic: file mail-index-transaction-update.c: line 337 (mail_index_expunge_last_append): assertion failed: (seq == t->last_new_seq)

7 years agoimapc: Move expunging from index to imapc_mailbox_index_expunge()
Timo Sirainen [Sat, 16 Jun 2018 12:08:26 +0000 (15:08 +0300)] 
imapc: Move expunging from index to imapc_mailbox_index_expunge()

7 years agolib-storage: Set index_mail_data.body_size if it can be calculated easily
Timo Sirainen [Mon, 4 Jun 2018 16:16:04 +0000 (19:16 +0300)] 
lib-storage: Set index_mail_data.body_size if it can be calculated easily

Probably doesn't help with anything currently, but makes the code more
consistent in how it works.

7 years agoimapc: Don't use RFC822.SIZE values for message body size calculation
Timo Sirainen [Thu, 31 May 2018 13:52:54 +0000 (16:52 +0300)] 
imapc: Don't use RFC822.SIZE values for message body size calculation

If the RFC822.SIZE doesn't match the exact stream size, the body size
calculation will become wrong. The only downside to this patch is that
now the body size will need to be calculated by parsing the stream, but
there shouldn't be any need to do that unless the body was already
FETCHed, so it shouldn't cause any extra IMAP traffic.

7 years agolib-storage: Move code to index_mail_try_set_body_size()
Timo Sirainen [Mon, 4 Jun 2018 16:03:20 +0000 (19:03 +0300)] 
lib-storage: Move code to index_mail_try_set_body_size()

This also adds a check to make sure virtual_size is set. With the current
caller it was already guaranteed to be set.

7 years agolib-storage: Don't set virtual_size from index record if it's already set
Timo Sirainen [Thu, 31 May 2018 13:49:34 +0000 (16:49 +0300)] 
lib-storage: Don't set virtual_size from index record if it's already set

The existing virtual_size may be a correct one, while the one in the index
may be wrong. This will be an especially important fix with the next
commit, because it would make the existing inexact_total_sizes=FALSE wrong.

7 years agolib-storage: Don't enforce creation of vsize header.
Timo Sirainen [Mon, 4 Jun 2018 16:37:15 +0000 (19:37 +0300)] 
lib-storage: Don't enforce creation of vsize header.

It's useful for caching quota=count and for STATUS (X-SIZE). If neither is
used the header shouldn't be created and kept up-to-date. If the header is
enabled, it also triggers creation of per-email vsize records.

7 years agoimapc: Fix handling UIDVALIDITY changes
Timo Sirainen [Tue, 19 Jun 2018 09:33:49 +0000 (12:33 +0300)] 
imapc: Fix handling UIDVALIDITY changes

Index was being correctly reset, but the transaction was rolled back.

7 years agolib-index: Make sure error is set on sync & commit failures
Timo Sirainen [Tue, 19 Jun 2018 09:31:43 +0000 (12:31 +0300)] 
lib-index: Make sure error is set on sync & commit failures

This avoids "BUG: Unknown internal index error" after view is marked
inconsistent or after index is deleted.

7 years agolib: When log writing keeps returning EAGAIN, change process title only once
Timo Sirainen [Mon, 18 Jun 2018 14:03:01 +0000 (17:03 +0300)] 
lib: When log writing keeps returning EAGAIN, change process title only once

Otherwise each call will use up data stack memory.

7 years agolib: If log write returns EAGAIN, use poll() instead of ioloop for waiting
Timo Sirainen [Mon, 18 Jun 2018 13:19:55 +0000 (16:19 +0300)] 
lib: If log write returns EAGAIN, use poll() instead of ioloop for waiting

As explained in 861d40b9aebabccae7d48e49a18cbc631ab1fefe commit message,
ioloop can call various callbacks and it can also recurse back to error
logging. Using poll() directly is safer.

7 years agolib: Revert earlier "log write is blocking" handling change
Timo Sirainen [Mon, 18 Jun 2018 13:07:30 +0000 (16:07 +0300)] 
lib: Revert earlier "log write is blocking" handling change

1) It was buggy, because it set O_NONBLOCK rather than removing it.

2) fd flags are shared across all the processes using the fd. We can't
reliably implement the process title update, because some processes are
blocking on the log write() before they change the process title.

Reverts 861d40b9aebabccae7d48e49a18cbc631ab1fefe

7 years agofs-posix: mkdir missing directory if it's changed by FS_METADATA_WRITE_FNAME
Timo Sirainen [Thu, 3 May 2018 12:22:09 +0000 (15:22 +0300)] 
fs-posix: mkdir missing directory if it's changed by FS_METADATA_WRITE_FNAME

The temp file is created to the initial directory. If the directory is
changed by FS_METADATA_WRITE_FNAME, the new destination directory didn't
necessarily exist. If the link() or rename() fails with ENOENT, try to
mkdir the missing directories.

7 years agolib: iostream-pump: Make iostream_pump_unref() implementation match other similar...
Stephan Bosch [Sun, 25 Feb 2018 18:13:18 +0000 (19:13 +0100)] 
lib: iostream-pump: Make iostream_pump_unref() implementation match other similar code.

This also means that iostream_pump_unref(NULL) is now a no-op.

7 years agolib-fs: fs_unlock(NULL) should be a no-op
Josef 'Jeff' Sipek [Fri, 25 May 2018 15:07:38 +0000 (11:07 -0400)] 
lib-fs: fs_unlock(NULL) should be a no-op

7 years agoglobal: start relying on fs_iter_deinit(NULL) being a no-op
Josef 'Jeff' Sipek [Fri, 25 May 2018 15:03:25 +0000 (11:03 -0400)] 
global: start relying on fs_iter_deinit(NULL) being a no-op

7 years agolib-fs: fs_iter_deinit(NULL) should be a no-op
Josef 'Jeff' Sipek [Fri, 25 May 2018 15:02:56 +0000 (11:02 -0400)] 
lib-fs: fs_iter_deinit(NULL) should be a no-op

7 years agoglobal: start relying on fs_deinit(NULL) and fs_unref(NULL) being no-ops
Josef 'Jeff' Sipek [Fri, 25 May 2018 14:53:54 +0000 (10:53 -0400)] 
global: start relying on fs_deinit(NULL) and fs_unref(NULL) being no-ops

Cleanup performed with the following semantic patch:

@@
expression E;
@@

- if (E != NULL) {
-  fs_unref(&E);
- }
+ fs_unref(&E);

@@
expression E;
@@

- if (E != NULL) {
-  fs_deinit(&E);
- }
+ fs_deinit(&E);

7 years agolib-fs: fs_unref(NULL) should be a no-op
Josef 'Jeff' Sipek [Fri, 25 May 2018 14:48:29 +0000 (10:48 -0400)] 
lib-fs: fs_unref(NULL) should be a no-op

7 years agoglobal: start relying on fs_file_close(NULL) being a no-op
Josef 'Jeff' Sipek [Fri, 25 May 2018 14:38:36 +0000 (10:38 -0400)] 
global: start relying on fs_file_close(NULL) being a no-op

Cleanup performed with the following semantic patch:

@@
expression E;
@@

- if (E != NULL) {
-  fs_file_close(E);
- }
+ fs_file_close(E);