Commit Graph

116 Commits

Author SHA1 Message Date
Thomas Lamprecht
ddaa372402 tree wide cargo fmt
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-07-13 11:30:26 +02:00
Wolfgang Bumiller
8f1719eebe drop 'time' dependency
We're using a very old version of it and the functions we
actually use are available in glibc anyway.

The only difference I found was that the result of
glibc's `strptime()`'s `%s` does *not* want an additional
`.to_local()` call anymore...

... which was weird anyway.

As a minor optimization I pass the format string as `&CStr`
to avoid the memcpy.

(The CString::new() call in `strptime()` only happens during
parameter parsing)

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Reviewed-By: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-By: Stoiko Ivanov <s.ivanov@proxmox.com>
[dropped left-over and fixed FIXME]
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2022-02-14 19:05:47 +01:00
Stoiko Ivanov
a4d769405c add tests for DST change and year change
based on our outbound production logs but anonymized

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2022-02-14 14:43:55 +01:00
Thomas Lamprecht
cc80c54de8 buildsys: fix reference to DBG_DEB
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-02-01 14:06:28 +01:00
Thomas Lamprecht
71e42fc1f8 buildsys: use only one parenthesis style
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-02-01 14:06:11 +01:00
Thomas Lamprecht
4b388f8d40 bump version to 2.3.1-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-02-01 13:32:06 +01:00
Stoiko Ivanov
17ec304fea fix logfile counting in months != january
the changes introduced in 1cdbebe57b

changed the date handling to have current_month and current_year
represent the month and year at time of invocation.
This change was not carried over to the logfile collecting, which set
the current month to january.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-by: Aaron Lauterer <a.lauterer@proxmox.com>
Reviewed-by: Mira Limbeck <m.limbeck@proxmox.com>
2022-02-01 13:29:26 +01:00
Wolfgang Bumiller
b24a352a5d bump d/control
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-01-04 16:02:18 +01:00
Wolfgang Bumiller
daec25d33f bump version to 2.3.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-01-04 15:55:53 +01:00
Wolfgang Bumiller
2fbb2ab3c6 stick to time_t for time
especially those u32 conversions are simply completely wrong

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Reviewed-by: Stoiko Ivanov <s.ivanov@proxmox.com>
[rebased]
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2022-01-04 14:07:23 +01:00
Stoiko Ivanov
1cdbebe57b do not assume constant year based on file index
rather start with the current time at invocation and if the month in
the log is larger assume a year-wrap happened between logwriting and
invocation.

the old logic is flawed (but that can be said about parsing
traditional syslog timestamps (w/o year) in general) - it got worse
with the change in bullseye of rotating syslog weekly by default -
resulting in users losing one week of logs per day in the new year as
reported in https://forum.proxmox.com/threads/.102322/

Reviewed-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2022-01-04 13:55:49 +01:00
Wolfgang Bumiller
6d693ce164 add .gitignore file
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-01-03 14:56:17 +01:00
Wolfgang Bumiller
821c09bd9f bump edition to 2021
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-01-03 13:22:16 +01:00
Wolfgang Bumiller
f9d4bdda8b switch to anyhow, don't use old style imports
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-01-03 13:21:18 +01:00
Wolfgang Bumiller
6e63fa58ee clippy fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-01-03 11:46:13 +01:00
Stoiko Ivanov
b87d0b0583 add test for empty to (dnsbl reject)
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2021-12-01 19:02:30 +01:00
Mira Limbeck
cab179a921 fix #3758: fix to filter with empty NoqueueEntry to field
We only compared the filter `to` with the Noqueue `to` when both were
not empty, and in turn set the nq.dstatus to DStatus::Invalid when they
didn't match.
But in the case of an empty Noqueue `to`, we have to skip it as well if
the filter `to` is not empty.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2021-12-01 18:57:15 +01:00
Thomas Lamprecht
40d978e67b debcargo: track updates
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-06-28 17:04:06 +02:00
Thomas Lamprecht
3f12c7fed7 buildsys: upload to bullseye
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-06-28 17:00:36 +02:00
Thomas Lamprecht
8eeab2adf0 bump version to 2.2.0-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-05-11 16:01:50 +02:00
Mira Limbeck
2912583794 fix mutable borrow panic on duplicate msgid
Because of the relay before lmtp issue we now add and remove QEntrys
based on their message-id. But if the cleanup line containing the
message-id appears twice in the log for the same QEntry it keeps a weak
reference to itself which leads to a panic because of a mutable borrow
while it is already mutably borrowed in the 'finalize' function.

To circumvent this we check after the lookup if it is the same QEntry
and if so, insert it again with that message-id in the lookup table and
don't add the weak reference.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
Tested-By: Aaron Lauterer <a.lauterer@proxmox.com>
2021-05-11 15:48:57 +02:00
Thomas Lamprecht
0908781e80 cargo: more flexible versioned dependencies
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-03-24 12:15:03 +01:00
Thomas Lamprecht
5bdc6f7b81 d/cargo: use HTTPs for homepage
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-03-24 12:14:32 +01:00
Thomas Lamprecht
5af4c03d8c bump version to 2.1.9-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-03-24 12:08:23 +01:00
Stoiko Ivanov
3c5da57b8a bump version to 2.1.9-1
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2021-03-24 11:49:58 +01:00
Mira Limbeck
f6cbaf2f48 add test case for relay removed before lmtp
Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2021-03-23 15:40:19 +01:00
Mira Limbeck
1ee56e8e78 after-queue: fix wrong DStatus if relay is 'removed' before 'lmtp' line
We only match a QEntry with the relay Qentry in the after-queue case
when we get to the 'lmtp' line. This is because it contains a reference
from the first QEntry to the filter, and the filter contains a reference
to the relay QEntry.

If the relay log entries are finished before the 'lmtp' line, there's no
way to match the relay to the first QEntry and we still assume it is
before-queue filtered.

To fix this we try to match the QEntries via message-id and add weak
references to each other. Then we wait with finalizing either until the
other is also 'removed' (finished).

The message-id matching might break if the same message-id is used for
different entries, so this is rather a 'hack' than a nice solution, but
there's no other info in the logs we could use to match both QEntries.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2021-03-23 15:40:19 +01:00
Mira Limbeck
48485c2bb2 close #2106: show outgoing TLS connection in tracking center
This is a best effort try to add the outgoing TLS connection information
to the output of pmg-log-tracker. The only thing we can match on is the
PID of the 'smtp' process. In the code we asumme that the TLS log entry
always happens before the actual smtp send entry that has a QID. This means
we save the TLS log entry in a map with the PID as key and then, once the
send entry happens, we look it up and add the log entry to the QEntry's
logs.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2021-03-23 14:05:18 +01:00
Mira Limbeck
ef4e4370a3 change tests to use faketime
We only have the month, day, hours, minutes and seconds available to us,
but not the year. Because of this we assume the logs are always relative
to the current year. This means when running the log tracker the CTIME
is calculated based on the current year and once a new year starts, all
old tests have to be updated to match the new year.

To work around this issue, use 'faketime' to set the time to 2020-12-31
23:59:59 as all tests assume 2020 as the year.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2021-03-22 16:20:32 +01:00
Fabian Grünbichler
77b430e04a debcargo: fix maintainer directive
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2021-02-01 11:29:02 +01:00
Fabian Grünbichler
ea087800bf build: track d/control
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-12-02 13:18:52 +01:00
Thomas Lamprecht
8d0d075975 bump version to 2.1.8-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-11-18 19:29:27 +01:00
Mira Limbeck
c409629f80 change case sensitive string match to case insensitive
With the rewrite from C to Rust the search string match was changed to
be case sensitive by accident. Fix this by comparing the lowercase values
of both the input and the search string.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
Reviewed-By: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-By: Stoiko Ivanov <s.ivanov@proxmox.com>
2020-11-17 08:18:21 +01:00
Thomas Lamprecht
5c363ec815 bump version to 2.1.7-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-09-03 17:50:45 +02:00
Mira Limbeck
dbab0bf5db add output for proxy-reject with 'Syntax:' message
Messages like the following
'proxy-reject: END-OF-MESSAGE: 501 5.5.2 Syntax: MAIL FROM: <address>;'
can happen if an EHLO keyword is announced which is not handled by
pmg-smtp-filter (see #2795). This patch adds output to the log tracker
so this mail shows up as 'rejected' in the GUI instead of silently
ignoring it.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
Tested-By: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-By: Stoiko Ivanov <s.ivanov@proxmox.com>
2020-09-03 17:15:23 +02:00
Fabian Grünbichler
d3f20a0a10 parse_number: prevent panic on empty input
if data is empty or the caller requested 0 digits, we can return early.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-06-17 09:25:27 +02:00
Fabian Grünbichler
18c8f6b9cd parse_time: prevent panic on truncated input
'advancing' a slice by one is only a good idea if there is more data.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-06-17 09:25:27 +02:00
Thomas Lamprecht
b0b36cefa9 bump version to 2.1.6-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-05-19 18:05:02 +02:00
Mira Limbeck
ff635f99db add testcase for mixed '-t' and '-x' options in before-queue filtering
Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2020-05-19 16:33:53 +02:00
Mira Limbeck
90e195ecc1 fix ToEntrys in FEntrys not being considered for 'to' filtering
When a 'to' filter is specified and a mail has multiple 'to's with at
least one being accepted, the others blocked or quarantined and the
'to' for the accepted mail does not match, the entries in the filter
will be ignored even if one of them would match.
To fix it the filter ToEntrys are now considered in the 'to' check.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2020-05-19 16:33:53 +02:00
Mira Limbeck
c6d8a71609 fix before-queue filter string_match check
In before-queue filtering a filter can be set on the SEntry. When a
search-string is set, we have to check both the SEntry and the attached
filter for a match, not just the SEntry. Otherwise some entries are not shown.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2020-05-19 16:33:53 +02:00
Mira Limbeck
5cce7a774a add testcase for accepted/blocked/quarantined mail
The testcase contains a mail that is accepted for one address, blocked
for another and quarantined for a third address.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2020-05-18 14:24:54 +02:00
Mira Limbeck
5ab03bbbee print blocked/quarantined entries if accepted mail exists
In the case of before-queue filtering we have the separation 'QEntry'
for accepted mails, as those are the only ones with a queue. And
'SEntry' for blocked and quarantined mails. But if a mail is accepted
for one address, but at the same time blocked or quarantined for another
address we previously discarded those entries. To fix it we now print it
in the 'QEntry' if the attached filter contains blocked and/or
quarantined mails.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2020-05-18 14:24:54 +02:00
Mira Limbeck
dd76914d00 make QID parsing more robust
As a user had the problem that 'fa' of 'fatal' matched for a QID,
increase the number of characters that have to match. The QID always has
at least 5 characters for the microseconds, so increase it to 5.

See http://www.postfix.org/postconf.5.html#enable_long_queue_ids

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2020-05-18 14:24:54 +02:00
Thomas Lamprecht
0a16b4d6fd bump version to 2.1.5-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-05-14 17:34:02 +02:00
Thomas Lamprecht
a7369a68e5 debcargo: add vcs links
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-05-13 13:42:44 +02:00
Mira Limbeck
54a122d957 add test case for 'from' and 'to' together
Updates the other test outputs' line numbers so the tests don't fail
because of an addition in between.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2020-05-06 13:20:58 +02:00
Stoiko Ivanov
d1dde9d3e1 add test for before queue dstatus
Reviewed-By: Mira Limbeck <m.limbeck@proxmox.com>
Tested-By: Mira Limbeck <m.limbeck@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2020-05-06 13:12:13 +02:00
Stoiko Ivanov
397577454a Introduce before queue dstatus
Currently the status of a before queue filtered mail is the status of the
downstream delivery in case the downstream rejects or defers a mail.

This information is too little to distinguish between a mail which went
through the rule-system, and a locally generated one
(e.g. bounce or spamreport).

By introducing 3 new distinct dstatus values we can use the information to
correctly display the status of a mail in the GUI.

Reviewed-By: Mira Limbeck <m.limbeck@proxmox.com>
Tested-By: Mira Limbeck <m.limbeck@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2020-05-06 13:12:13 +02:00
Thomas Lamprecht
2f182bc7c9 bump version to 2.1.4-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-04-24 19:35:20 +02:00