OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Address Rewriting Problem

From: Tim Calvert (calvertmarshall.edu)
Date: Tue Feb 20 2007 - 15:50:24 CST


I've inherited a Postfix system and had no prior experience with
Postfix. (I come from a VMS - PMDF background.) I'm having a problem
that I can't seem to work out. I've read HOW-TOs and READMEs, the
archive for this list, The Definitive Guide, The Book of Postfix, and
done numerous searches and still can't seem to make it do what I want to
do. So I'm turning to the experts.

Background:
We allow users to have what we call a vanity address (in the form of
firstname.lastname) if they want to. In order to rewrite the headers of
incoming email from firstname.lastnamemarshall.edu to
usernamemarshall.edu, the guy who designed, installed and configured
the Postfix system used a virtual alias database. Unfortunately, he
neglected to provide a means for the From headers to be rewritten on
outgoing email from usernamemarshall.edu to
firstname.lastnamemarshall.edu. That's the problem I'm trying to fix.

What I did:
After some reading, I came to the conclusion that this task is generally
performed by a canonical database. I first set it up with LHS=username
and RHS=firstname.lastname, as the example showed in the Address
Rewriting Readme, and added canonical_maps = hash:/etc/postfix/canonical
to main.cf. That didn't work at all. After some more reading, I stumbled
across something (and I have no idea now where it was) that indicated
the RHS needed to be an address. So I changed it to
firstname.lastnamemarshall.edu. That sort of worked.

 From the messages I've sent to my own Yahoo address to test this, the
Return-path is getting rewritten, which I think is the Envelope from,
but the message From header is not being rewritten. This would seem to
contradict the Address Rewriting Readme which says the default behavior
is to rewrite all headers unless the canonical_classes parameter is
specified - which it isn't. And when I try to Reply to the message, the
address it fills in is usernamemarshall.edu rather than
firstname.lastnamemarshall.edu.

I'm sending these test messages via Thunderbird connected to the Postfix
server. We also have an Exchange server here that sends and receives
through the Postfix server. When a colleague who has a vanity address
set up sends email to my Yahoo address from Exchange, the Message From
*is* rewritten to firstname.lastnamemarshall.edu, and replies go to
that address. However, when I send from my Exchange mailbox, I get the
same results as when I send via Thunderbird. The difference (as we
finally discovered) is that his Exchange profile had the vanity address
as the primary and mine didn't. When he changed his profile to specify
his usernamemarshall.edu address as the primary, that's what I got as
the Message From when his email got to Yahoo.

So apparently, the Message From header isn't being modified by Postfix
at all. I can't figure out why not. Any help would be greatly appreciated.

Just in case I've mis-interpreted (or incorrectly described) something,
here are the headers from one of my tests:

X-Apparently-To: tim_calvertyahoo.com via 206.190.39.127; Tue, 20 Feb
2007 08:07:09 -0800
X-Originating-IP: [206.212.0.193]
Return-Path: <tim.calvertmarshall.edu>
Authentication-Results: mta496.mail.mud.yahoo.com from=marshall.edu;
domainkeys=neutral (no sig)
Received: from 206.212.0.193 (EHLO mumail01.marshall.edu)
(206.212.0.193) by mta496.mail.mud.yahoo.com with SMTP; Tue, 20 Feb 2007
08:07:09 -0800
Received: from [10.102.180.21] (name removed for security
[10.102.180.21]) by mumail01.marshall.edu (Postfix) with ESMTP id
DE5F0443F3 for <tim_calvertyahoo.com>; Tue, 20 Feb 2007 11:02:08 -0500
(EST)
Message-ID: <45DB1B79.1080901marshall.edu>
Date: Tue, 20 Feb 2007 11:02:01 -0500
From: "Tim Calvert" <calvertmarshall.edu>
User-Agent: Thunderbird 1.5.0.9 (Windows/20061207)
MIME-Version: 1.0
To: tim_calvertyahoo.com
Subject: Test Rewrite - With Domain in File
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

And here's the output from postfinger:

postfinger - postfix configuration on Tue Feb 20 16:42:12 EST 2007
version: 1.30

Warning: postfinger output may show private configuration information,
such as ip addresses and/or domain names which you do not want to show
to the public. If this is the case it is your responsibility to modify
the output to hide this private information. [Remove this warning with
the --nowarn option.]

--System Parameters--
mail_version = 2.2.10
hostname = mumail01.marshall.edu
uname = Linux mumail01.marshall.edu 2.6.9-34.0.1.ELsmp #1 SMP Wed May 17
16:59:36 EDT 2006 x86_64 x86_64 x86_64 GNU/Linux

--Packaging information--
looks like this postfix comes from RPM package: postfix-2.2.10-1.RHEL4.2

--main.cf non-default parameters--
alias_database = hash:/etc/postfix/aliases
alias_maps = hash:/etc/postfix/aliases
bounce_queue_lifetime = 2h
broken_sasl_auth_clients = yes
canonical_maps = hash:/etc/postfix/canonical
lmtp_sasl_auth_enable = yes
lmtp_sasl_password_maps = hash:/etc/postfix/lmtp_passwd
lmtp_sasl_security_options = noanonymous
local_recipient_maps =
mailbox_transport = lmtp:unix:/var/lib/imap/socket/lmtp
manpage_directory = /usr/share/man
message_size_limit = 15000000
mydestination = $mydomain, mumail.marshall.edu
mynetworks = 127.0.0.0/8, 10.0.0.0/8
myorigin = $mydomain
readme_directory = /usr/share/doc/postfix-2.2.10/README_FILES
sample_directory = /usr/share/doc/postfix-2.2.10/samples
smtpd_hard_error_limit = 10
smtpd_helo_required = yes
smtpd_recipient_restrictions = reject_non_fqdn_recipient
reject_unknown_recipient_domain permit_sasl_authenticated
permit_mynetworks reject_unauth_destination reject_non_fqdn_sender
reject_unknown_sender_domain check_recipient_access
hash:/etc/postfix/roleaccount_exceptions reject_non_fqdn_hostname
reject_invalid_hostname permit
smtpd_sasl_auth_enable = yes
smtpd_sasl_exceptions_networks = $mynetworks
smtpd_soft_error_limit = 5
transport_maps = hash:/etc/postfix/transport,
regexp:/etc/postfix/transport_regex
virtual_alias_maps = hash:/etc/postfix/virtual

--master.cf--
smtp inet n - n - - smtpd
submission inet n - n - - smtpd
  -o smtpd_sasl_auth_enable=yes
  -o relay_domains=
inforeply unix - n n - - pipe
  flags= user=autorepuser argv=/usr/local/bin/inforeply.pl ${sender}
${recipient}
pickup fifo n - n 60 1 pickup
cleanup unix n - n - 0 cleanup
qmgr fifo n - n 300 1 qmgr
rewrite unix - - n - - trivial-rewrite
bounce unix - - n - 0 bounce
defer unix - - n - 0 bounce
trace unix - - n - 0 bounce
verify unix - - n - 1 verify
flush unix n - n 1000? 0 flush
proxymap unix - - n - - proxymap
smtp unix - - n - - smtp
relay unix - - n - - smtp
showq unix n - n - - showq
error unix - - n - - error
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - n - - lmtp
anvil unix - - n - 1 anvil
maildrop unix - n n - - pipe
  flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}
old-cyrus unix - n n - - pipe
  flags=R user=cyrus argv=/usr/lib/cyrus-imapd/deliver -e -m
${extension} ${user}
cyrus unix - n n - - pipe
  user=cyrus argv=/usr/lib/cyrus-imapd/deliver -e -r ${sender} -m
${extension} ${user}
uucp unix - n n - - pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail
($recipient)
ifmail unix - n n - - pipe
  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp unix - n n - - pipe
  flags=Fq. user=foo argv=/usr/local/sbin/bsmtp -f $sender $nexthop
$recipient
scache unix - - n - 1 scache
discard unix - - n - - discard
tlsmgr unix - - n 1000? 1 tlsmgr

-- end of postfinger output --

Thanks.

Tim Calvert
Marshall University
calvertmarshall.edu