OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
RE: A problem with pcre

From: MacShane, Tracy (Tracy.MacshaneAirservicesAustralia.com)
Date: Thu Nov 01 2007 - 22:43:36 CDT


 

> -----Original Message-----
> From: owner-postfix-userspostfix.org
> [mailto:owner-postfix-userspostfix.org] On Behalf Of Payne
> Sent: Friday, 2 November 2007 2:21 PM
> To: postfix-userspostfix.org
> Subject: A problem with pcre
>
> Guys,
>
> I am having an issue, I have read several webpages and a
> couple man pages, and I can't get syntax correct for pcre files.
>
> I just create a file called helo_checks. I have added to my
> main.cf the following...
>
> check_helo_access pcre:/etc/postfix/helo_checks.pcre
>
> when I try to do this to create the file
>
> postmap -q - pcre:/etc/postfix/helo_checks.pcre <
> /etc/postfix/helo_checks
>
> I get this...
>
> open /etc/postfix/helo_checks.pcre: No such file or directory
>
> what am I doing wrong?
>
> Payne
>

You don't need to index the file, if that's what you're trying to do
(and if you were, you would still have the syntax wrong - it should be
"postmap hash(or btree|dbm|whatever):/path/to/file").

postmap -q is a query to validate an entry.

For example, you want to block a bunch of hosts on a network:

/etc/postfix/helo_checks.pcre
------------------------------
/\d{1,3}-\d{1,3}-\d{1,3}-\d{1,3}\.example\.com/ REJECT

(this domain conveniently gives their dialup hosts the naming convention
of xxx-xxx-xxx-xxx.example.com, which represents their IP addresses - I
realise that it will match more than the IP address range, but who
cares?)

To test that a specific hostname will be correctly found:

# postmap -q 24-113-121-241.example.com
pcre:/etc/postfix/pcre_client_access
REJECT

(this matches)

# postmap -q 113-121-241.example.com
pcre:/etc/postfix/pcre_client_access
#

(this doesn't)