OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: Looking up relay IPs from a database

From: Andrew Koros (akoroske.uu.net)
Date: Fri Dec 07 2007 - 07:16:19 CST


Hello mouss,

Yes you are right, let me edit my postgresql function and make sure it
does not return the empty result.

Thanks.

mouss wrote:
> Andrew Koros wrote:
>
>>>>
>>> fix your query. why does "host.example.com" match anything in the
>>> queried table? if the table is used for something else, add an "AND"
>>> statement to ignore empty results.
>>>
>> No, "host.example.com" does not match anything in the queried table.
>> It returns
>> a NULL or empty result.
>
> It's all about this "empty result". you seem to consider an empty
> string as void, NULL, nothing, nihil. here is an example of an
> acceptable result:
>
>
> bardb# select foo from bar where blah blah;
> foo
> ------------
> (0 rows)
>
> see the "0 rows"? and there is no blank line between the '----...' and
> the '(0 rows)'.
>
>
>> In other words the SQL query only returns a value if the input was an
>> IP found
>> in the database otherwise it returns a empty result. for example:
>>
>> mydatabase=# SELECT get_relay_ips('192.168.0.12') AS ip;
>> ip
>> -------------------
>> 192.168.0.0/28
>> (1 row)
>>
>> But
>>
>> mydatabase=# SELECT get_relay_ips('192.168.0.20') AS ip;
>> ip
>> -------------------
>>
>> (1 row)
>>
>> becuase 192.168.0.20 is not part of the 192.168.0.0/28
>>
>> And quering for the hostnames will not succeed as expected:
>>
>> mydatabase=# SELECT get_relay_ips('host.example.com') AS ip;
>> ip
>> ----
>>
>> (1 row)
>>
>
> It returns an empty string, which is exactly what postfix is trying to
> tell you. This is actually documented.
>
>

--
Andrew Koros
Systems Developer

UUNET Kenya Ltd,
Your WiMAX future is now here

Tel: +254 (20)69 88 618/000
Fax: +254 (20)69 88 001
Email: akoros <at> ke.uu.net
http://www.ics.uunet.co.ke/

"The contents of this e-mail and any accompanying documentation
is confidential and any use thereof, in whatever form, by anyone
other than the addressee for whom it is intended, is strictly
prohibited."

|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| / / (_)__ __ ____ __ |
| / /__/ / _ \/ // /\ \/ / | Freedom to
| /____/_/_//_/\_,_/ /_/\_\ | Experiment
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~