Regular expression in postauth section

Alexander Clouter alex at digriz.org.uk
Tue Jun 29 09:21:46 CEST 2010


JOE <joeplc at gmail.com> wrote:
>
> Thanks Alan, I meant something like this:
> 
> post-auth {
>        if(!(User-Name=="test-user")){
>
And this is *still* not regex.  The following is regex:
----
if (Calling-Station-Id =~ /^([0-9a-f]{2})-([0-9a-f]{2})-([0-9a-f]{2})-([0-9a-f]{2})-([0-9a-f]{2})-([0-9a-f]{2})$/i) {
	update control {
		MAC-Address-Trimmed := "%{1}%{2}%{3}%{4}%{5}%{6}"
	}
}
----

For a tutorial on what and how to use regex, look at:

man 7 regex - http://www.cl.cam.ac.uk/cgi-bin/manpage?7+regex
http://www.zytrax.com/tech/web/regex.htm

Always remember though, 'regex != perl regex', so do not mix up your 
tutorials.  Also there is a thing known as 'extended' regex, known in
POSIX.2 as 'modern RE', and also there is 'basic RE' that are obsoleted.

Regards

-- 
Alexander Clouter
.sigmonster says: Please come again.




More information about the Freeradius-Users mailing list