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.
Timo Sirainen [Thu, 20 Jan 2022 13:13:48 +0000 (14:13 +0100)]
lib: ostream-multiplex - Call flush callbacks also when stream has failed
It may be important for the flush callbacks to know when ostream has been
closed. This is a partial fix to prevent doveadm-server hanging when it's
printing lots of output and doveadm client disconnects.
Markus Valentin [Wed, 22 Dec 2021 11:12:51 +0000 (12:12 +0100)]
imapc: Fix doveadm copy with imapc
When copying to a mailbox with imapc it does not sync the destination
mailbox when opening. This created "Error: Syncing mailbox '$mailboxname'
failed: Internal error occurred." Prevent this error by checking for the
MAILBOX_FLAG_SAVEONLY flag which is used by doveadm to create the
destination mailbox. If that flag is set ignore that there was no initial
fetching done.
Stephan Bosch [Mon, 9 Nov 2020 01:29:04 +0000 (02:29 +0100)]
lib-smtp: smtp-server-cmd-rset - Stop processing pipeline until RSET is complete.
A subsequent MAIL command could get reset in the middle otherwise. Before, it
only blocked input until a reply was submitted, but the transaction isn't reset
until the RSET command is complete (just before actually sending the reply)
which can cause issues when the subsequent MAIL command is already being
processed.
Stephan Bosch [Sun, 8 Nov 2020 23:02:51 +0000 (00:02 +0100)]
lib-smtp: smtp-server-cmd-helo - Stop processing pipeline until HELO/EHLO is complete.
A subsequent MAIL command could get reset in the middle otherwise. Before, it
only blocked input until a reply was submitted, but the transaction isn't reset
until the EHLO/HELO command is complete (just before actually sending the reply)
which can cause issues when the subsequent MAIL command is already
being processed.
Timo Sirainen [Thu, 20 Jan 2022 10:42:57 +0000 (12:42 +0200)]
lib-storage: Don't delay setting mail event's log prefix
This caused crashes if the mail event was kept referenced and used for
logging after struct mail was already freed. With the delayed mail event
creation the log prefix shouldn't be much of a performance problem, so just
set the prefix immediately.
Stephan Bosch [Mon, 13 Dec 2021 03:08:32 +0000 (04:08 +0100)]
submssion: submission-backend-relay - Avoid logging two errors about a connection problem.
Earlier commit changed lib-smtp to consistently log an error for connection
problems, which causes a second error to occur for submission relay backend.
This is undesirable.
Timo Sirainen [Tue, 28 Dec 2021 07:37:42 +0000 (09:37 +0200)]
lib-storage: Remove most reason_code=mail:*
Event reasons create events internally. This is rather expensive if it's
done for operations that access all emails in a large folder, e.g. SORT.
The per-mail reason_codes also didn't seem to be hugely helpful, so best
to just remove them.
Some of the mail:* reasons were left where they are causing mail stream to
be opened anyway. In these cases the extra CPU used by event reasons is
relatively little.
Timo Sirainen [Thu, 9 Dec 2021 17:06:11 +0000 (18:06 +0100)]
lib-fts: Reuse textcat handle between sessions
textcat initialization is rather CPU intensive. Its configuration is
normally always the same between sessions, so we can keep the latest textcat
handle cached.