postfix-users November 2011 archive
Main Archive Page > Month Archives  > postfix-users archives
postfix-users: sanitizing mysql queries

sanitizing mysql queries

From: Simon Brereton <simon.brereton_at_nospam>
Date: Mon Nov 21 2011 - 22:26:46 GMT
To: postfix users <postfix-users@postfix.org>

Hi

When I set postfix many moons ago, I wasn't at all sure of what I was
doing and I followed a number of different howtos. The result is that
I inherited other peoples ideas of how things should be done and
lately I've seen advice and bells and whistles that make me think I
should go back and streamline things. One thing I'm not at all sure
on is how mysql queries are handled. For example, I have in main.cf

772 virtual_alias_maps = proxy:mysql:/etc/postfix/Mail-Alias.cf,
hash:/etc/postfix/virtual_user_aliases
774 virtual_mailbox_maps = mysql:/etc/postfix/Mail-Mailbox.cf

Now, that's two different ways of doing things right there. Testing
on the commandline with:

mail:~# postmap -q "simon@example.net" mysql:/etc/postfix/Mail-Alias.cf

returns:
simon@example.net

But http://www.postfix.org/proxymap.8.html recommends I should use
proxy: to consolidate connections - so really I should have proxy: in
front of the virtual_mailbox_maps as well since this will take the
most hammering, yes?

Second question...

If I want to use mysql:/path/to/file in smtpd_recipient_restrictions
should I be using proxy in there too? I'm using postfix 2.7.1 from
debian repositories - should I be a query = SELECT forw_addr FROM
mxaliases WHERE alias='%s' AND active='1' format or a list of name
value pairs? I.e.
user = someone
password = some_password
dbname = customer_database
table = mxaliases
select_field = forw_addr
where_field = alias
additional_conditions = AND active = '1'

What I'm trying to do is follow advice from /dev/rob0 a few weeks ago
about moving the check for disabled users to announce the proper
reject and that's when I realised that'd I'd so blindly followed a
guide I had no idea of how this really works.

Thanks.

Simon