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 forward to remote mta

From: Mike Everest (mikeviewbankrise.net.au)
Date: Sun Oct 03 2004 - 04:32:56 CDT


Thanks Magnus,

> -----Original Message-----
> On Sunday, October 03, 2004 at 09:21 CEST,
> Mike Everest <sendersenderdomain.com> wrote:
> > I use virtual_alias_maps to rewrite the address, yet according to the
> > verbose logging, the message is still handed to virtual, and virtual
> > tries to find the mailbox path for "personremotedomain.com" and
> > (expectedly) bounces the mail with "unknown user"

> Since you haven't provided any logs or configuration (hint hint), I have
> to guess here. Are you storing the names of the virtual mailbox domains
> in a RDBMS or in LDAP, and use an incorrect query to find out if a
> domain is a virtual mailbox domain? Specifically, do you have a query
> like "SELECT * FROM domains" or filter like (domain=*)?

Some logs and configs - of course :-}

Ok, well I am doing this all by postgersql, my main.cf is quite simple to
start with:

mydestination = $myhostname
                localhost

local_destination_concurrency_limit = 1

mailbox_size_limit = 0
recipient_delimiter = +
local_transport = local

maildrop_destination_recipient_limit = 1

virtual_mailbox_domains = pgsql:/etc/postfix/pgsql_virtual_domains.cf
        # select domain from domains where mailHost = '$myhostname'
        # eg virtualdomain.com

virtual_mailbox_base = /
virtual_mailbox_maps = pgsql:/etc/postfix/pgsql_virt_mailbox.cf
        # select maildir from email where id = '%s' and maildir <> 'none'
        # eg virtualuservirtualdomain.com ->
/var/spool/mail/virtualuser/dir/

virtual_alias_maps = pgsql:/etc/postfix/pgsql_virt_alias.cf
        # select alias from email where id = '%s' and alias <> ''
        # eg uservirtualdomain.com -> personremotedomain.com

                             pgsql:/etc/postfix/pgsql_virtual_email2email.cf
        # select id from email where id = '%s'
        # eg uservirtualdomain.com -> uservirtualdomain.com
        # overcome catch-all effect

virtual_minimum_uid = 100
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000

all the relevant queries check out and seem to return data in the expected
format as per examples (eg) above.

The log output is very big because I have -v turned on just about
everything, but these excerpts are probably the most telling (forgive me if
o leave out important stuff!):

..
Up to here everything looks good (to me)
..
Oct 3 12:14:14 debian postfix/trivial-rewrite[5165]: match_hostname:
remotedomain.com ~? myhostname.virtualdomain.com
Oct 3 12:14:14 debian postfix/trivial-rewrite[5165]: match_hostname:
remotedomain.com ~? localhost
Oct 3 12:14:14 debian postfix/trivial-rewrite[5165]: match_list_match:
remotedomain.com: no match
Oct 3 12:14:14 debian postfix/trivial-rewrite[5165]:
personremotedomain.com -> (`virtual' `remotedomain.com'
`personremotedomain.com' `1024')
Oct 3 12:14:14 debian postfix/trivial-rewrite[5165]: send attr transport =
virtual
Oct 3 12:14:14 debian postfix/trivial-rewrite[5165]: send attr nexthop =
remotedomain.com
Oct 3 12:14:14 debian postfix/trivial-rewrite[5165]: send attr recipient =
personremotedomain.com
Oct 3 12:14:14 debian postfix/trivial-rewrite[5165]: send attr flags = 1024
Oct 3 12:14:14 debian postfix/trivial-rewrite[5165]: master_notify: status
1
Oct 3 12:14:14 debian postfix/trivial-rewrite[5165]: watchdog_start:
0x8059a68
..
Still makes sense to here
..
Oct 3 12:14:14 debian postfix/virtual[5167]: input attribute name: size
Oct 3 12:14:14 debian postfix/virtual[5167]: input attribute value: 844
Oct 3 12:14:14 debian postfix/virtual[5167]: virtual socket: wanted
attribute: nexthop
Oct 3 12:14:14 debian postfix/virtual[5167]: input attribute name: nexthop
Oct 3 12:14:14 debian postfix/virtual[5167]: input attribute value:
remotedomain.com
Oct 3 12:14:14 debian postfix/virtual[5167]: virtual socket: wanted
attribute: encoding
Oct 3 12:14:14 debian postfix/virtual[5167]: input attribute name: encoding
Oct 3 12:14:14 debian postfix/virtual[5167]: input attribute value: (end)
Oct 3 12:14:14 debian postfix/virtual[5167]: virtual socket: wanted
attribute: sender
Oct 3 12:14:14 debian postfix/virtual[5167]: input attribute name: sender
Oct 3 12:14:14 debian postfix/virtual[5167]: input attribute value:
sendersenderdomain.com
Oct 3 12:14:14 debian postfix/virtual[5167]: virtual socket: wanted
attribute: errors-to
Oct 3 12:14:14 debian postfix/virtual[5167]: input attribute name:
errors-to
Oct 3 12:14:14 debian postfix/virtual[5167]: input attribute value:
sendersenderdomain.com
Oct 3 12:14:14 debian postfix/virtual[5167]: virtual socket: wanted
attribute: return-receipt
Oct 3 12:14:14 debian postfix/virtual[5167]: input attribute name:
return-receipt
Oct 3 12:14:14 debian postfix/virtual[5167]: input attribute value: (end)
..
Then it all seems to go wrong..
..
Oct 3 12:14:14 debian postfix/virtual[5167]: sender:
sendersenderdomain.com
Oct 3 12:14:14 debian postfix/virtual[5167]: recipient:
personremotedomain.com
Oct 3 12:14:14 debian postfix/virtual[5167]: user: personremotedomain.com
Oct 3 12:14:14 debian postfix/virtual[5167]: delivered:
personremotedomain.com
Oct 3 12:14:14 debian postfix/virtual[5167]: relay: virtual
Oct 3 12:14:14 debian postfix/virtual[5167]: deliver_mailbox[2]: recip
personremotedomain.com deliver personremotedomain.com
Oct 3 12:14:14 debian postfix/virtual[5167]: dict_pgsql_lookup using sql
query: select maildir from email where id = 'personremotedomain.com' and
maildir <> 'none'
Oct 3 12:14:14 debian postfix/virtual[5167]: dict_pgsql_get_active:
attempting to connect to host dbhost.virtualdomain.com
Oct 3 12:14:14 debian postfix/virtual[5167]: dict_pgsql: successful
connection to host dbhost.virtualdomain.com
Oct 3 12:14:14 debian postfix/virtual[5167]: dict_pgsql: successful query
from host dbhost.virtualdomain.com
Oct 3 12:14:14 debian postfix/virtual[5167]: dict_pgsql_lookup: retrieved 0
rows
Oct 3 12:14:14 debian postfix/virtual[5167]: maps_find:
virtual_mailbox_maps: personremotedomain.com: not found
Oct 3 12:14:14 debian postfix/virtual[5167]: match_string: remotedomain.com
~? myhostname.virtualdomain.com
Oct 3 12:14:14 debian postfix/virtual[5167]: match_string: remotedomain.com
~? localhost
Oct 3 12:14:14 debian postfix/virtual[5167]: match_list_match:
remotedomain.com: no match
Oct 3 12:14:14 debian postfix/virtual[5167]: dict_pgsql_lookup using sql
query: select maildir from email where id = 'remotedomain.com' and maildir
<> 'none'
Oct 3 12:14:14 debian postfix/virtual[5167]: dict_pgsql_get_active: found
active connection to host dbhost.virtualdomain.com
Oct 3 12:14:14 debian postfix/virtual[5167]: dict_pgsql: successful query
from host dbhost.virtualdomain.com
Oct 3 12:14:14 debian postfix/virtual[5167]: dict_pgsql_lookup: retrieved 0
rows
Oct 3 12:14:14 debian postfix/virtual[5167]: maps_find:
virtual_mailbox_maps: remotedomain.com: not found
Oct 3 12:14:14 debian postfix/virtual[5167]: mail_addr_find:
personremotedomain.com -> (not found)
Oct 3 12:14:14 debian postfix/virtual[5167]: deliver_unknown[2]: recip
personremotedomain.com deliver personremotedomain.com
Oct 3 12:14:14 debian postfix/virtual[5167]: connect to subsystem
private/bounce
Oct 3 12:14:14 debian postfix/virtual[5167]: send attr nrequest = 0
Oct 3 12:14:14 debian postfix/virtual[5167]: send attr flags = 0
Oct 3 12:14:14 debian postfix/virtual[5167]: send attr queue_id =
04122FB8F3
Oct 3 12:14:14 debian postfix/virtual[5167]: send attr original_recipient =
uservirtualdomain.com
Oct 3 12:14:14 debian postfix/virtual[5167]: send attr recipient =
personremotedomain.com
Oct 3 12:14:14 debian postfix/virtual[5167]: send attr offset = 307
Oct 3 12:14:14 debian postfix/virtual[5167]: send attr status = 5.0.0
Oct 3 12:14:14 debian postfix/virtual[5167]: send attr action = failed
Oct 3 12:14:14 debian postfix/virtual[5167]: send attr reason = unknown
user: "personremotedomain.com"
Oct 3 12:14:14 debian postfix/virtual[5167]: private/bounce socket: wanted
attribute: status
Oct 3 12:14:14 debian postfix/virtual[5167]: input attribute name: status
Oct 3 12:14:14 debian postfix/virtual[5167]: input attribute value: 0
Oct 3 12:14:14 debian postfix/virtual[5167]: private/bounce socket: wanted
attribute: (list terminator)
Oct 3 12:14:14 debian postfix/virtual[5167]: input attribute name: (end)
Oct 3 12:14:14 debian postfix/virtual[5167]: 04122FB8F3:
to=<personremotedomain.com>, orig_to=<uservirtualdomain.com>,
relay=virtual, delay=6, status=bounced (unknown user:
"personremotedomain.com")

Hope that all makes sense.

Regards, Mike.