Commit Graph

82 Commits

Author SHA1 Message Date
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
Mira Limbeck
bf16debe3f fix from entries being shown even with a from filter
When a 'from' and 'to' filter were set, we used a 'from || to' test to
see if we should print it or not. This patch changes this to a 'from &&
to' test. This gets rid of entries from unrelated senders ('from') when
a 'from filter did not match but the 'to' filter matched.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2020-04-24 17:56:16 +02:00
Thomas Lamprecht
a27c3b076b bump version to 2.1.3-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-04-24 12:27:11 +02:00
Dominik Csapak
4d1bf8f928 before-queue: set 'B' status for rule-system blocked mails
we want to show mails that were blocked by the rule-system as 'Blocked'
in the ui, so we have to use the dstatus of the to entry, and not
'NOQUEUE'

mails rejected by postscreen, etc. still show 'rejected'

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-04-24 11:57:13 +02:00
Wolfgang Bumiller
670f064019 set dist to buster in upload target
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-04-06 12:23:15 +02:00
Wolfgang Bumiller
c8729e63db use -X in upload
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-04-06 12:16:46 +02:00
Wolfgang Bumiller
75acc91506 bump version to 2.1.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-04-06 12:08:10 +02:00
Mira Limbeck
093033c8cd add a test case for recipient filtering
Add a before queue test case to test recipient filtering. Previously
all SEntry filter entries were printed because filtering failed. Now
test that it only prints the specified ones.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2020-04-06 11:57:25 +02:00
Mira Limbeck
20141d5863 fix wrong order of arguments
This fixes the output in the case of a failed assert. Exptected and
Command were swapped.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2020-04-06 11:57:22 +02:00
Mira Limbeck
c29ff56429 fix filter_matches() if condition
We need to check the filter entries when either the 'from' or 'to'
options are set. Also remove the && is_filtered as it is superfluous.

The !is_filtered check lead to all filter entries being printed all the
time.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2020-04-06 11:57:19 +02:00
Thomas Lamprecht
bccbe8d894 bump version to 2.1.1-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-24 12:37:55 +01:00
Mira Limbeck
85fdd484ed add test for the exclude_greylist fix
This tests the before queue case with both '-g' and 'n' options set.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2020-03-24 11:40:19 +01:00
Mira Limbeck
5dc82f8ed2 fix SEntry filter in before-queue case
With before-queue filtering if we don't accept the mail (e.g.
quarantine), we don't have a queue which means we don't have a QEntry,
so the SEntry has to handle the filter entries (ToEntrys).

This means we can't just return from print() when either a 'from' or 'to'
filter is set or we exclude greylist entries or NDRs and no Noqueue entries
exist or no entry matches any of the filters.

So continue printing if there is no filter parameter set, but an FEntry
reference in the SEntry. If there's an FEntry reference, compare all ToEntrys
to the filter parameter and return if there is no match at all.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2020-03-24 11:40:15 +01:00
Mira Limbeck
00b849aeb0 add filter() and qentry() helper methods
This simplifies access to the structs by cloning and then upgrading them
if possible and returning an Option<Rc<>> instead of an Option<Weak<>>.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2020-03-24 11:40:07 +01:00
Thomas Lamprecht
813c465711 buildsys: clean more
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-09 14:20:21 +01:00
Thomas Lamprecht
5c49ce005f buildsys: drop writing rust-toolchain into build dir
breaks source package generation

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-09 14:14:14 +01:00
Thomas Lamprecht
0594496c8e buildsys: add rust- prefix to dsc name
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-09 14:13:24 +01:00
Wolfgang Bumiller
21dac5056e 2.1.0-1 build commit
The actual package was built after the packaging cleanup.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-02-28 12:51:04 +01:00
Fabian Grünbichler
abd7fe2d82 packaging cleanup
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-02-28 11:58:09 +01:00
Wolfgang Bumiller
0fff9ce39f bump version to 2.1.0-1
note that the source package now has a rust- prefix

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-02-28 09:44:21 +01:00
Wolfgang Bumiller
e029c60dff switch to using debcargo
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-02-28 09:44:21 +01:00
Wolfgang Bumiller
d06ac89c35 Cargo.toml: add license, description, homepage and excludes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-02-28 09:43:15 +01:00
Wolfgang Bumiller
cb622ca252 add .cargo/config and rustfmt.toml
.cargo/config since we build with debian packages as
dependencies by default

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-02-28 09:22:16 +01:00
Mira Limbeck
aee1def7c3 add tests
Add tests for some command line options. Not all have a test yet, but at
least most of the ones used by the GUI (-s, -e, -q, -x). '-g' and '-n' are
currently still missing.

The tests will only be valid until end of January 31st 2021 because of
missing year info in the syslog.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-02-21 09:47:37 +01:00
Mira Limbeck
f41b809a8e add before queue filter support
Initial before queue filter support. Requires a patch to pmg-api to add
the pmg-smtp-filter ID to the replies on a reject to correctly match the
pmg-smtp-filter to the smtpd.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-02-21 09:47:35 +01:00
Mira Limbeck
04fc98b88e remove C source code
Remove src/pmg-log-tracker.c and src/Makefile as they are no longer
required.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-02-21 09:47:33 +01:00
Mira Limbeck
457d833549 rewrite in rust
pmg-log-tracker has been rewritten in Rust. Functionality is the same.
Output sometimes has a different order than the pmg-log-tracker in C.
This only happens when the time of the entries match.

There's one change regarding the interface. In addition to the short
versions of arguments also long versions exist.

The implementation uses Rc<>, Weak<> and RefCell<> to make holding mutable
cross-references possible, without having to change the original logic
completely. This allowed for easier translation from C to Rust.

The file debian/cargo-checksum.json is required by dh-cargo, otherwise
it won't compile. The cargo-checksum.json should contain the upstream
.crate file which does not exist in this case, so we just create an
empty one with the required keys. (see 'Library package structure' in
https://wiki.debian.org/Teams/RustPackaging/Policy)

The change to the minimum version of debhelper required was done
according to other rust packages (rust-clap, rust-bindgen, rust-ripgrep).

Adds a README that provides an overview of the stages a mail passes
through and what we can use to match those together for a single mail.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-02-21 09:47:30 +01:00
Thomas Lamprecht
490b6e739a bump version to 2.0-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-07-22 15:30:48 +02:00
Thomas Lamprecht
d5128fc797 bump version to 1.0-2
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-07-22 08:34:32 +02:00
Thomas Lamprecht
e5f30e2ed8 rework build and packaging, add debian source package
diffoscope shows that the only real changes is the new SOURCE file we
ship in docs, like other packages.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-07-22 08:30:30 +02:00
Dominik Csapak
ee33f65005 fix trailing whitespace
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-02-22 13:13:38 +01:00
Dominik Csapak
48eebf537f replace static const int with #define
using a static const int as array size is technically a
variable length array, so we should not use it that way

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-02-22 13:13:27 +01:00
Dominik Csapak
516305b73a remove unused parameters
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-02-22 13:12:55 +01:00
Dominik Csapak
325abffb96 minor type fixes
log->linenr is an unsigned long, we want to log it as a whole
mygzgetc returns a char anyway so change it to reflect that

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-02-22 13:12:23 +01:00
Dominik Csapak
e3b39992d4 use less magic numbers
use #defines or characters instead

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-02-22 13:12:09 +01:00