Timo Sirainen [Fri, 8 Apr 2022 12:59:59 +0000 (15:59 +0300)]
lib-index: Always write tail offset the same as head offset
The mail_index_write() must not be called unless this is safe to do.
This prevents unnecessarily reading through dovecot.index.log between
tail..head offsets, which can be expensive due to modseq calculation.
Timo Sirainen [Fri, 8 Apr 2022 12:10:53 +0000 (15:10 +0300)]
lib-index: Optimize modseq scanning by using the modseq header in index
View is very commonly set to start reading new changes since dovecot.index
was last written. When reading the newer records in dovecot.index.log, the
modseq of each change is needed to be known. However, the initial modseq
calculation was usually done inefficiently by reading the whole
dovecot.index.log from the beginning of the file. This change prevents
that by using instead the "modseq" header in dovecot.index to get the
initial modseq.
Timo Sirainen [Fri, 8 Apr 2022 10:42:55 +0000 (13:42 +0300)]
lib-index: Handle 0-sized dovecot.index.log record properly
The previous behavior was to just silently ignore it and have the next write
to the transaction log silently truncate away the trailing garbage.
Now if the log file isn't locked the issue is still ignored, since it's
possible that this is just a race condition. But if the log is locked,
it's handled as corruption.
Timo Sirainen [Wed, 2 Mar 2022 14:39:30 +0000 (09:39 -0500)]
dsync: Fix hierarchical mailbox name parts individually
For example with filesystem-based mailbox formats it's not allowed to create
"box/../child" mailbox. With previous code dsync just gave up and created
the mailbox name based on its GUID. This is now improved to instead try to
insert '_' character after each hierarchy separator so the newly fixed
mailbox name is "box/_../child".
Siavash Tavakoli [Mon, 25 Oct 2021 11:23:56 +0000 (12:23 +0100)]
lib-lua: Add a minimal interface to lib-http
Adds the ability to
- Creating http clients
- Creating http requests
- Adding arbitrary headers and payload to the http request
- Submitting the request to remote server and getting the response
Markus Valentin [Wed, 2 Feb 2022 15:58:24 +0000 (16:58 +0100)]
imapc: imapc_sync_handle_untagged_fetches() - Commit after adding the untagged fetch messages
The absence of the commit could have caused issues when
imapc_sync_finish() was not called as it left mbox->delayed_sync_trans
initialized but mbox->delayed_sync_view was NULL.
Markus Valentin [Mon, 17 Jan 2022 14:41:25 +0000 (15:41 +0100)]
imapc: imapc_untagged_fetch_handle() - Change return type to bool
When calling imapc_untagged_fetch_handle() also retrieve new_message_r
from it which allows imapc_mailbox_msgmap_update() to determine if the
message just handled was already in index or not.
Timo Sirainen [Mon, 21 Feb 2022 22:07:11 +0000 (23:07 +0100)]
dsync: If modseqs aren't permanent, assume HIGHESTMODSEQ=0
Otherwise the HIGHESTMODSEQ is just whatever happens to be in the in-memory
view of the index, which most likely isn't the true HIGHESTMODSEQ. Using 0
makes it clear that the HIGHESTMODSEQ isn't valid and can't be used.
Timo Sirainen [Mon, 21 Feb 2022 11:39:02 +0000 (12:39 +0100)]
lib: Fix losing log prefix or IP change when log process is busy
The fd for writing to log process is non-blocking. When sending options
to log process, it was done with write_full(), which stopped whenever
EAGAIN was returned. This error was simply ignored, and the logging code
thought that the prefix was successfully changed (or the IP was sent).
This mainly caused a problem when processes were reused and log process
was busy. The prefix update could have failed, and the following logging
would be using the previous session's log prefix, i.e. log lines could have
been logged for the wrong user/session.
Timo Sirainen [Mon, 25 Oct 2021 12:43:00 +0000 (15:43 +0300)]
lib-storage: Don't use cached message_parts while message is being parsed
Finish the parsing instead. Otherwise there can be some confusion about
parsed_bodystructure* fields, which indicate that data->parts have the
bodystructure info while in reality data->parts came from cached fields
and they have no bodystructure info.
Marco Bettini [Tue, 1 Feb 2022 13:22:31 +0000 (14:22 +0100)]
mail-crypt: Fix for mail being wrongly storing encrypted via LMTP
If 1st recipient has mail_crypt_save_version=2,
and 2nd recipient has mail_crypt_save_version=0,
the mail for 2nd recipient is wrongly stored encrypted.
Same happens if 2nd recipient has mail_crypt disabled
Timo Sirainen [Wed, 26 Jan 2022 14:00:45 +0000 (16:00 +0200)]
auth: ldap: If LDAP connection appears to be hanging, abort all old requests
Retrying the reconnect might fix them, but since this situation isn't
supposed to happen in the first place, it's safer to just remove them
entirely to guarantee that it's not trying to keep retrying them for
a long time.
Timo Sirainen [Wed, 26 Jan 2022 12:46:55 +0000 (14:46 +0200)]
auth: ldap: Reconnect to server if receiving unknown msgid
It's unclear why this happens. Is it a bug on server or client side?
Either way, this situation doesn't now fix itself automatically, so
reconnecting should help.
Timo Sirainen [Wed, 26 Jan 2022 12:43:01 +0000 (14:43 +0200)]
auth: ldap: Stop re-sending request after 3 disconnect+reconnects
This prevents retrying the same LDAP request forever in situations where the
request causes LDAP server to become disconnected. This might fix some real
issues, but it was mainly implemented because testing the following commit
caused infinite looping.
Timo Sirainen [Tue, 1 Feb 2022 13:57:16 +0000 (14:57 +0100)]
lmtp: proxy - Add per-connection counter to session_id
This way connections to two different backends don't try to use the same
session_id. Add 'P' letter before the counter to clarify that it's the
proxy connection counter.
Timo Sirainen [Tue, 1 Feb 2022 13:40:48 +0000 (14:40 +0100)]
lmtp: Simplify/clarify per-recipient session ID
The session ID is the transaction ID followed by an increasing recipient
count (number of RCPT commands) in the SMTP transaction. Clarify this by
adding 'R' letter before the counter. Also don't add the counter suffix at
all for the first recipient, since most transactions only have a single
recipient.
Timo Sirainen [Tue, 1 Feb 2022 13:35:05 +0000 (14:35 +0100)]
lib-smtp: server-transaction - Simplify/clarify transaction ID
The transaction ID is the session ID followed by an increasing transaction
count (number of MAIL commands) in the SMTP server connection. Clarify
this by adding 'T' letter before the counter. Also don't add the counter
suffix at all for the first session, since most sessions only have a
single transaction.