On 12-01-13 17:39, LEVAI Daniel wrote:
> On szo, jan 12, 2013 at 14:11:12 +0100, Bastian Blank wrote:
>> On Sat, Jan 12, 2013 at 01:51:26PM +0100, LEVAI Daniel wrote:
>>> How should I put this... My question is not in regards to how to store
>>> IP networks (w/ CIDR postfix) in PostgreSQL; this is somewhat given.
>>
>> PostgreSQL handles CIDR with some special functions and operators. See
>> http://www.postgresql.org/docs/9.2/interactive/functions-net.html
> 
> The type in PostgreSQL is irrelevant. Ignore it. That is not part of the
> question. It is just a string that Postfix queries. For example
> currently (when querying single IP addresses for check_client_access)
> the column in question is a varchar...
> 

It is relevant. client_client_access is an access table. Postfix does
not query the table for an ip adress, it wants an OK reply for the
queried IP address. Read http://www.postfix.org/access.5.html

If you configure postfix with a query that checks if the ip address is
in the cidr mask in the database, you're done:

SELECT 'OK' FROM client_access_table WHERE inet '%s' << inet
client_access_column

I'm not sure if you can cast a varchar column to inet type at query
time. If not, you need to do some more database tricks.

--
Tom

Reply via email to