Time for action – using regular expressions
Unlang allows regular expression evaluations in condition checking. These usually are Posix regular expressions. The operators =~
and !~
are associated with regular expressions. For a simple proof of concept we will modify the previous exercise:
- Edit the
sites-available/default
virtual server under the FreeRADIUS configuration directory and add the following inside thepost-auth
section, at the top of the section:if(request:Framed-Protocol =~ /.*PP$/i){ update reply { Reply-Message := "Regexp match for %{0}" } }
- Restart FreeRADIUS in debug mode and try to authenticate as
alice
. First add a1
to the end of theradtest
command, then omit the1
.Take note how the regular expression match changes the value ...
Get FreeRADIUS Beginner's Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.