OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: Virtual domain aliases

From: Alan Batie (alanbatie.org)
Date: Mon Dec 03 2007 - 20:29:50 CST


OK, with a lot of help from mysql logging, I got this figured out, but...

mouss wrote:

> Now on to your request. To implement alias domains, you need two things:
> - declare the domain in virtual_alias_domains so that postfix accepts
> mail for this domain (thanks to reject_unauth_destination)

As near as I can tell, postfix is completely ignoring the
virtual_alias_domains config. This query is never getting executed,
according to the mysqld logs. Only the virtual_mailbox_domains is
getting called, and then not even for the target domain, only the alias
domain.

I experimented with addrmydom, addrmydom2, bogusmydom, bogusmydom2.
 If mydom2 isn't in virtual_mailbox_domains, it treats the address as a
relay and doesn't even look it up: accepting it if the peer is allowed
to relay and rejecting "relaying denied" if not. Instead, if it finds
the address in virtual_mailbox_maps (or virtual_alias_maps), then it's
happy with it and does the right thing.

> - declare the mappings for each user.

This is why I didn't think these instructions were what I was looking
for --- I didn't want to have to duplicate mappings for the alias
domain. On further study, figured out that you just use the right sql
queries to eliminate the duplication:

> [case 2] virtual_mailbox table contains a single column for the user.
>
> the query now becomes:
> select
> user
> from
> alias_domain, virtual_mailbox
> where
> %d = alias and user = concat('%u', '', target)

So I created two alias_maps and two mailbox_maps, and this works:

mysql_virtual_alias_maps.cf:query = SELECT goto FROM alias WHERE
address='%s' AND active = 1

mysql_virtual_ad_alias_maps.cf:query = SELECT goto FROM
alias,alias_domain WHERE alias_domain.alias_domain = '%d' and
alias.address=concat('%u', '', alias_domain.target_domain) AND
alias.active = 1

mysql_virtual_mailbox_maps.cf:query = SELECT maildir FROM mailbox WHERE
username='%s' AND active = 1

mysql_virtual_ad_mailbox_maps.cf:query = SELECT maildir FROM
mailbox,alias_domain WHERE alias_domain.alias_domain = '%d' and
mailbox.username=concat('%u', '', alias_domain.target_domain) AND
mailbox.active = 1

with main.cf (in fact I commented out the virtual_alias_domains to no
effect --- it still works fine):

#virtual_alias_domains =
proxy:mysql:/usr/local/etc/postfix/mysql_virtual_alias_domains.cf
virtual_alias_maps =
    proxy:mysql:/usr/local/etc/postfix/mysql_virtual_alias_maps.cf,
    proxy:mysql:/usr/local/etc/postfix/mysql_virtual_ad_alias_maps.cf

virtual_mailbox_domains =
proxy:mysql:/usr/local/etc/postfix/mysql_virtual_mailbox_domains.cf
virtual_mailbox_maps =
    proxy:mysql:/usr/local/etc/postfix/mysql_virtual_mailbox_maps.cf,
    proxy:mysql:/usr/local/etc/postfix/mysql_virtual_ad_mailbox_maps.cf

relay_domains =
proxy:mysql:/usr/local/etc/postfix/mysql_relay_domains_maps.cf