OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Re: mysql maps+address rewirting problem

From: John Fawcett (johnmlmichaweb.net)
Date: Fri Jul 02 2004 - 05:37:42 CDT


From: "Andri Piik" <apiiktmk.ee>
> Hi some days ago I wrote here about the problem that postfix rewrites the
> outgoing adress wrong under certain circumstances. I use cyrus,mysql
> address maps and postfix. The problem occurs when I have a user whose
> username is bogus and e-mail address bogustest1.com and another user
> bogustest2.com with username bogg. When I send teh e-mail from
> bogustest2.com it's sender address gets written to bogustest1.com. I got
> advice to put teh -v flag to cleanup. I understand that adress rewriting
> runs for several times but why? Can anyone help me?

The following log entry shows that the mail is being sent from
boggtln.edu.ee
not from bogustest2.com.

> Jul 2 08:55:47 alpha postfix/pickup[13499]: 64EFD179560: uid=99
> from=<boggtln.edu.ee>

The requests to rewrite the addresses are done for both the envelope sender
and the From header (if I'm reading this correctly) and in both cases the
user
that sent the mail is not the one you think it is:

> Jul 2 08:55:47 alpha postfix/cleanup[13511]: initial envelope S
> boggtln.edu.ee
> Jul 2 08:55:47 alpha postfix/cleanup[13511]: send attr request = rewrite
> Jul 2 08:55:47 alpha postfix/cleanup[13511]: send attr rule =
canonicalize
> Jul 2 08:55:47 alpha postfix/cleanup[13511]: send attr address =
> boggtln.edu.ee

> Jul 2 08:55:47 alpha postfix/cleanup[13511]: rewrite_sender: From
> Jul 2 08:55:47 alpha postfix/cleanup[13511]: send attr request = rewrite
> Jul 2 08:55:47 alpha postfix/cleanup[13511]: send attr rule =
canonicalize
> Jul 2 08:55:47 alpha postfix/cleanup[13511]: send attr address =
> boggtln.edu.ee

From the queries executed (below), you can see that first of all cleanup
checks
whether boggtln.edu.ee should be rewritten, then as that isn't found
postfix checks the bear user name bogg. That is found.

So your canonical maps are set up to user bear user names without domains.
You are mapping bogg to bogustest2.com via canoncial maps.

> select alias from virtual where username = 'boggtln.edu.ee' and status =
'1' limit 1
> sender_canonical_maps: boggtln.edu.ee: not found

> select alias from virtual where username = 'bogg' and status = '1' limit 1
> sender_canonical_maps: mysql:/etc/postfix/mysql-canonical.cf(0,100): bogg
> = bogustest2.com

You have also set up your canonical maps so that they map the user
bogus to bogustest1.com.

> select alias from virtual where username = 'bogustest2.com' and status =
'1' limit 1
> sender_canonical_maps: bogustest2.com: not found

> select alias from virtual where username = 'bogus' and status = '1' limit
1
> sender_canonical_maps: mysql:/etc/postfix/mysql-canonical.cf(0,100): bogus
= bogustest1.com

> select alias from virtual where username = 'bogustest1.com' and status =
'1' limit 1
> sender_canonical_maps: bogustest1.com: not found

> select alias from virtual where username = 'bogus' and status = '1' limit
1
> sender_canonical_maps: mysql:/etc/postfix/mysql-canonical.cf(0,100): bogus
> = bogustest1.com

You may have to look at what you're trying to achieve with this
address rewriting. Instead of doing rewriting, why not set up your mail
client to give the correct information on outgoing mail? (or am I
missing something obvious?)

John