procmail
[Top] [All Lists]

Re: Local domain forgery detection?

2002-08-28 19:21:14
Paul wrote,

| Well, the traditional use of ^ and $ is to match a null at the start or
| end of a line, respectively.  As such, they do not actually match any
| character, including a null.  Your explanation appears to imply that
| they behave like \< and \>, which is not the case.

Yes, it is.  In procmail, ^ and $ need a newline to match to -- but it could
be a putative newline rather than a real one.  Procmail imagines a newline
before the first character of the search area and another after its last
character so that ^ and $ can seem to match the endpoints of the search area.
Those are what we call the putative newlines.  At either end of a procmailrc
regexp, ^^ specifically matches a putative newline.  Putative newlines are
never extracted into $MATCH; at that point, procmail remembers that they
aren't real.

I'm not sure who came up with this:

| > >  MYDOMAIN=| hostname | sed "s/`hostname -s`\.//"

but wouldn't

  :0
  * HOST ?? ()\.\/.+
  { MYDOMAIN=$MATCH }

accomplish the same thing without forking a shell, hostname, sed, and hostname
again?  Actually, I'd do it like this to make sure I extracted exactly two
elements:

 :0 # putative newlines never show up in $MATCH
 * HOST ?? ()\/[^.]+\.[^.]+^^
 { MYDOMAIN=$MATCH }

Paul also asked,

| How would you structure a recipe to grab only the first occurrence
| of the Received line, without using an external shell to strip it?

Ruud has since answered that.



_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail