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 FreeRADIUS in debug mode and try to authenticate as
alice
. First add a1
to the end of theradtest
command, then omit the1
. - The value of
Reply-Message
with1
added toradtest
should be:Reply-Message =...