Re: [SLE] Postfix - Sandy - 1 more Q re: /etc/postfix/recepient_check



david rankin wrote:
From: "Per Jessen" <per@xxxxxxxxxxxx>


> The second point I'm missing is "why can't I just use the
> existing recepient_check file and put "support@ reject" in there?"


Because postfix lookup tables don't work like that :-)

Can't I do something similar with hash?? I don't have a clue about
perl. Assembler, Fortran, C, C++ maybe, but definately not perl.....


I'm none too fond of perl myself - but fortunately you don't need to
know anything about perl to write PCREs. Are you any good with regular
expressions in general?


Uhh... I'm a little hesitant to answer, because I'm not sure what "regular" means in this case. I'm mean, I can hande "regular" anything as long as I have a man page that tells me what the syntax is : - ). I will give your suggestions a try and take it on faith that regular, in the PCREs case, means the /^ ... @ ...$/ as in:

Regular expressions are an absolute must for adminstrators. You will encounter these pattern matching expressions in most scripting and programming languages.


Create a file called /etc/postfix/recipient_check.pcre :

/^support@[domain1|domain2|domain3....]$/ REJECT

The square brackets don't work on my system with either pcre or regexp.
I use round brackets instead. Have you tried it, Per?

What you have here is a pattern set between the to slashes:

/ pattern start

^ the beginning of the line, pattern can not start in the middle

support@ just text. (^-^)

(val1|val2...) the pattern can have one of the mentioned values within the brackets.
| OR

$ the end of the line
/ pattern end

hash:
support@xxxxxxxxxxx REJECT

pcre:
/^support@example\.com$/ REJECT

The backslash is escaping the ".", otherwise it would have a special meaning and would match any single character. A literal $ would have to be escaped as \$ to avoid the use as expression matching denominator.

The big advantage of pattern versus hashes is that pattern can have placeholders and/or multiple values.

testpcre:
/^(support@(*example\.com|example2\.*))$/ REJECT internal address $1 rejected!

This will hit every the following patterns:
support@*example.com
support@example2.*

Additionally it will use the content in the round brackets as $1, $2 (content of first found expression in brackets, second found...


postmap -q "support@xxxxxxxxxxxxxxxxxxxxxx" pcre:testpcre
REJECT internal address support@xxxxxxxxxxxxxxxxxxxxxx rejected!

Take a while to get accustomed to regular expressions. As Per already said, it takes some time and lots of own tests to build up experience and confidence with regular expressions.

They will slooowly grow on you. (^-^)

Sandy
--
List replies only please!
Please address PMs to: news-reply2 (@) japantest (.) homelinux (.) com

--
Check the headers for your unsubscription address
For additional commands send e-mail to suse-linux-e-help@xxxxxxxx
Also check the archives at http://lists.suse.com
Please read the FAQs: suse-linux-e-faq@xxxxxxxx



Relevant Pages

  • Re: [SLE] Postfix - Sandy - 1 more Q re: /etc/postfix/recepient_check
    ... I'm a little hesitant to answer, because I'm not sure what "regular" means in this case. ... Regular expressions are an absolute must for adminstrators. ... You will encounter these pattern matching expressions in most scripting and programming languages. ... Additionally it will use the content in the round brackets as $1, $2 (content of first found expression in brackets, second found... ...
    (SuSE)
  • Re: Help with Regex and trying to mimic the VB "like" comparison
    ... But I don't want to have to teach hundreds of users how to use regular ... expressions, as this is far to complex for their needs. ... > You can use regexes, just allow the pattern the user types be the pattern for the regex, but with a few precautions: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: grep command or operator
    ... expressions. ... I though that 'e' in egrep was just random letter put there. ... egrep - search a file for a pattern using full regular ...
    (comp.unix.solaris)
  • Matching neighbouring words of a pattern using Regex
    ... How can I match 'n' number of neighbouring words of a pattern using regular ... suppose I am looking for the pattern "length xyz cm" in some ...
    (comp.lang.perl)
  • Matching neighbouring words of a pattern using Regex
    ... How can I match 'n' number of neighbouring words of a pattern using regular ... suppose I am looking for the pattern "length xyz cm" in some ...
    (comp.lang.perl.misc)