|
I found the easiest way to test this solution was from the command line. I placed the above
expression in one file, and the mail headers in another file. Then I ran this command:
cat msg | postmap -q - pcre:obscure_smtp_auth
Where the file msg contains the headers.
Return-Path: <dan&example.org>
X-Original-To: dan&localhost.example.org
Delivered-To: dan&localhost.example.org
Received: from localhost (localhost [127.0.0.1])
by nyi.example.org (Postfix) with ESMTP id CAEED5092B
for <dan&localhost.example.org>; Sun, 30 Nov 2008 18:26:27 +0000 (GMT)
X-Virus-Scanned: amavisd-new at example.org
Received: from nyi.example.org ([127.0.0.1])
by localhost (nyi.example.org [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id lbf0iH03joEZ for <dan&localhost.example.org>;
Sun, 30 Nov 2008 18:26:27 +0000 (GMT)
Received: from laptop.example.org (c-10.123.45.67.bigcompany.example.net [10.123.45.67])
(Authenticated sender: dan)
by nyi.example.org (Postfix) with ESMTPSA id 36F83508B4
for <dan&example.org>; Sun, 30 Nov 2008 18:26:27 +0000 (GMT)
Message-ID: <4932DA89.4030604&example.org>
Date: Sun, 30 Nov 2008 13:25:13 -0500
From: Dan Langille <dan&example.org>
Organization: The FreeBSD Diary
User-Agent: Thunderbird 2.0.0.18 (X11/20081124)
MIME-Version: 1.0
To: dan&example.org
Subject: testing
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NOTE: when running the test, I had to collapse the relevant Received: header into
one line, so it looked like this:
Received: from laptop.example.org (c-10.123.45.67.bigcompany.example.net [10.123.45.67]) (Authenticated sender: dan) by nyi.example.org (Postfix) with ESMTPSA id 36F83508B4 for <dan&example.org>; Sun, 30 Nov 2008 18:26:27 +0000 (GMT)
Postfix does this [logically] when applying the regex, so there's no sense trying to get
all fancy with the testing.
When running the test, the output looked like this:
$ cat msg | postmap -q - pcre:obscure_smtp_auth
Received: from laptop.example.org (c-10.123.45.67.bigcompany.example.net [10.123.45.67]) (Authenticated sender: dan) by nyi.example.org (Postfix) with ESMTPSA id 36F83508B4 for <dan&example.org>; Sun, 30 Nov 2008 18:26:27 +0000 (GMT) REPLACE Received: from smtp-auth.example.org (smtp-auth.example.org [10.4.7.7]) (Authenticated sender: hidden) by nyi.example.org (Postfix) with ESMTPSA id 36F83508B4 for <dan&example.org>; Sun, 30 Nov 2008 18:26:27 +0000 (GMT)
Please note: I have copied and pasted from various sources when writing this up.
Message IDs, IP addresses, etc, may not be consistent.
When viewed as part of an email, it resembles this:
Received: from nyi.example.org ([127.0.0.1])
by localhost (nyi.example.org [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id vgaz2Db58gXj for <pat&example.net>;
Mon, 1 Dec 2008 04:10:40 +0000 (GMT)
Received: from smtp-auth.example.org (smtp-auth.example.org [10.4.7.7])
(Authenticated sender: hidden)
by nyi.example.org (Postfix) with ESMTPSA id A96EE5082E
for <pat&example.net>; Mon, 1 Dec 2008 04:10:40 +0000 (GMT)
You will note the following:
- The message originated with smtp-auth.example.org at 10.4.7.7
- The Authenticated sender field is no longer displayed
Note that the mail log file will contain something like this:
Dec 1 04:10:40 nyi postfix/cleanup[78496]: A96EE5082E: replace: header Received: from laptop.example.org (bast.example.org [10.123.45.67])??(Authenticated sender: me)??by nyi.example.org (Postfix) with ESMTPSA id A96EE5082E??for <pat&example.net>; Mon, 1 Dec 2 from bast.example.org[72.94.192.80]; from=<dand&example.org> to=<pat&example.net> proto=ESMTP helo=<laptop.example.org>: Received: from smtp-auth.example.org (smtp-auth.example.org [10.4.7.7])??(Authenticated sender: hidden)??by nyi.example.org (Postfix) with ESMTPSA id A96EE5082E ??for <pat&example.net>; Mon, 1 Dec 2008 04:10:40 +0000 (GMT)
The original mail header has been logged, as well as the transformation.
|