[pmg-devel] [PATCH pmg-api v2] fix #1653: parse ipv6 xforward correctly

Dominik Csapak d.csapak at proxmox.com
Wed Jan 22 14:26:29 CET 2020


postfix prepends an ipv6 address in the xforward message with 'IPv6:'
we did not remove it and our later checks in who objects fail silently.

we now check if the addr is prefixed with this and remove it to
allow the who objects to work.

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
changes from v1:
* fix subject
* move prefix removal to 'from_match'
  since we actually need the xfoward field to keep that format for
  the postfix server that sends the email to the recipient
  we do not need to do this anyplace else, since 'to_match' does
  not get an ip anyway and there is no other place where we check who
  matches

 src/PMG/RuleCache.pm | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/PMG/RuleCache.pm b/src/PMG/RuleCache.pm
index 0b97839..9b18e7e 100644
--- a/src/PMG/RuleCache.pm
+++ b/src/PMG/RuleCache.pm
@@ -239,6 +239,11 @@ sub from_match {
 
     return 1 if !defined ($from);
 
+    # postfix prefixes ipv6 addresses with IPv6:
+    if ($ip =~ /^IPv6:(.*)/) {
+	$ip = $1;
+    }
+
     foreach my $obj (@$from) {
 	return 1 if $obj->who_match($addr, $ip, $ldap);
     }
-- 
2.20.1




More information about the pmg-devel mailing list