[pmg-devel] [PATCH pmg-log-tracker] fix SEntry print() with filter in before-queue case
Mira Limbeck
m.limbeck at proxmox.com
Wed Mar 4 15:15:18 CET 2020
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 at proxmox.com>
---
src/main.rs | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/src/main.rs b/src/main.rs
index 9cb96f0..d031fef 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -869,7 +869,7 @@ impl SEntry {
}
}
- // if either ;from' or 'to' are set, check if it matches, if not, set
+ // if either 'from' or 'to' are set, check if it matches, if not, set
// the status of the noqueue entry to Invalid
// if exclude_greylist or exclude_ndr are set, check if it matches
// and if so, set the status to Invalid so they are no longer included
@@ -896,8 +896,31 @@ impl SEntry {
found = true;
}
}
+ if let Some(fe) = &self.filter {
+ if let Some(fe) = fe.upgrade() {
+ let is_filtered =
+ !parser.options.from.is_empty() || !parser.options.to.is_empty();
+ if fe.borrow().is_bq && !fe.borrow().is_accepted {
+ for to in fe.borrow().to_entries.iter() {
+ if (!parser.options.from.is_empty()
+ && find_lowercase(&self.bq_from, parser.options.from.as_bytes())
+ .is_some())
+ || (!parser.options.to.is_empty()
+ && find_lowercase(&to.to, parser.options.to.as_bytes())
+ .is_some())
+ {
+ found = true;
+ break;
+ }
+ }
+ if !found && is_filtered {
+ return;
+ }
+ }
+ }
+ }
- if !found {
+ if !found && self.filter.is_none() {
return;
}
}
--
2.20.1
More information about the pmg-devel
mailing list