Time for action – using command substitution
Up to now we have used double-quotes to contain a variable that will be referenced. Unlang also features back-quoted strings, which allows for command substitution. The string inside these back-quotes is evaluated similarly to double-quoted strings where string expansion can take place.
Let's modify the previous exercise to show command substitution in action:
- 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(control:Auth-Type == 'PAP'){ update reply { Reply-Message := `/bin/echo We are using %{control:Auth-Type}` } }
- Restart FreeRADIUS in debug mode and try to authenticate as
alice
.The feedback of the
echo
command will now be assigned to theReply-Message
attribute.
What just happened?
We have used back-quotes to perform command substitution. The output of this command has been assigned...