procmail
[Top] [All Lists]

Re: Accept all mail sourced from IP address range

2006-07-01 05:18:04
Dallman Ross schreef:

   MYPUB = '(0?65\.0?84\.0?78\.(19[2-9]|2[0-4][0-9]|25[0-5]))'

The surrounding brackets are there to make it safe to use $MYPUB
inside regular expressions: ($MYPUB|$MYNAT128)

You showed me this once before privately a couple of years ago,
as I recall.  But I can't remember the case where it would matter.
Could you elucideate, please?


Right, and in this case I was too cautious, because there are no 'loose
groups' (yet!) in the regex.

This is wrong:

  $_6 = 19[2-9]|2[0-4][0-9]|25[0-5]
  $_8 = [01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5]

  MYNAT18 = 192\.168\.$_6\.$_8

and should be:

  $_6 = (19[2-9]|2[0-4][0-9]|25[0-5])
  $_8 = ([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])

  MYNAT18 = 192\.168\.$_6\.$_8

or defensively even

  MYNAT18 = (192\.168\.$_6\.$_8)



AFAIK, the 0? is to fill up to three digits.

Yup.  I think the script author's original premise was that some IP
addresses could come in with leading zeros.  I suppose some spammers'
could.  I've never seen any real, automatically produced (by mail
servers) IP addresses with leading zeros in the dotted quads, though.
Have you?

I haven't.

But there are several ways to write an IP-number.

For example: www.google.com = 66.249.93.104

66*2^24+249*2^16+93*2^8+104=1123638632

So http://1123638632/ will bring you to google.


66=0102, 249=0371, 93=0135, 104=0150:
  ping 0102.0371.0135.0150




Be careful with those leading zeroes in other contexts[ ]tha[n]
E-mail headers; some utilities (like ping) will consider such a
numeral as octal.

Theoretically could happen, I suppose.

google: ping octal

-- 
Groet, Ruud


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail