Time for action – setting default values for variables
We are not always sure if a variable exists. Unlang features syntax for us to specify a default value in case a variable does not exist. Again we will demonstrate this by modifying the previous exercise. We will use radtest
to first include Framed-Protocol = PPP
in the request and also to leave it out. If the Framed-Protocol
AVP is not present, we will return a default string.
- Edit the
sites-available/default
virtual server under the FreeRADIUS configuration directory and add the following code inside thepost-auth
section, at the top of the section:if(control:Auth-Type == 'PAP'){ update reply { Reply-Message := "Framed protocol is: %{%{request:Framed-Protocol}:-Not in request}" } }
- Restart ...
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.