Using cleanup service to strip headers

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Using cleanup service to strip headers

John Regan
Hi,

I have postfix-3.5.2 on fedora and trying to strip internal submission headers using the cleanup service and can't get it working.

auth-cleanup   unix n       -       -       -       0       cleanup
   -o syslog_name=postfix/auth-cleanup
   -o header_checks=pcre:/etc/postfix/auth_header_checks.pcre

submission inet n       -       n       -       -       smtpd
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING
  -o receive_override_options=$submission_overrides
  -o syslog_name=postfix/submission
  -o cleanup_service_name=auth-cleanup

In /etc/postfix/auth_header_checks.pcre I've tried a number of different approaches. 
/^\s*(Received: from)[^\n]*(.*for <.*@(?!inside.mydomain.com).*)/ REPLACE $1 [127.0.0.1] (localhost [127.0.0.1])$2
/^Received:.*\(Authenticated sender:/ IGNORE
/^Received:.*/ IGNORE
/^Received:.*from sage/   IGNORE
/^Received:.*from juggernaut/   IGNORE
/^Received:.*from orion/   IGNORE
/^Received:.*from sage\.inside\.mydomain\.com \(sage\.inside\.mydomain\.com/ REPLACE
/^Received:\s+.*/ REPLACE hello
/^Received:.*\(Authenticated sender:/ IGNORE

The first one works when using postmap -q directly:
$ postmap -q "Received: from sage.inside.mydomain.com (sage.inside.mydomain.com [192.168.1.7])" pcre:/etc/postfix/auth_header_checks.pcre
REPLACE Received: from 127.0.0.1

Headers from a sample email:
Received: from sage.inside.mydomain.com (sage.inside.mydomain.com [192.168.1.7])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
	(Client did not present a certificate)
	(Authenticated sender: john)
	by orion.guardiandigital.com (Postfix) with ESMTPSA id 5B4DD8078BF4
	for <[hidden email]>; Sat,  1 Aug 2020 14:19:45 -0400 (EDT)
Entry from /var/log/maillog for the auth-cleanup service:
Aug  1 14:49:56 orion postfix/auth-cleanup/cleanup[4080207]: D14C08078BF4: message-id=<[hidden email]>

What am I doing wrong?







Reply | Threaded
Open this post in threaded view
|

Re: Using cleanup service to strip headers

Benny Pedersen-2
John Regan skrev den 2020-08-01 21:23:

> In master.cf [3]:
> auth-cleanup   unix n       -       -       -       0       cleanup
>    -o syslog_name=postfix/auth-cleanup
>    -o header_checks=pcre:/etc/postfix/auth_header_checks.pcre

header_checks is port 25 incomming, not outgoing

> What am I doing wrong?

outgoing is smtp_header_checks