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:

  1. Edit the sites-available/default virtual server under the FreeRADIUS configuration directory and add the following inside the post-auth section, at the top of the section:
    if(request:Framed-Protocol =~ /.*PP$/i){
        update reply {
            Reply-Message := "Regexp match for %{0}"
        }
    }
  2. Restart FreeRADIUS in debug mode and try to authenticate as alice. First add a 1 to the end of the radtest command, then omit the 1.

    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.