Time for action – SQL statements as variables

One very powerful function of unlang is that it allows you to execute SQL queries through the sql module. The query is actually a variable and the return value of this query is the value of the variable. We will now modify the previous exercise to fetch the time from the database and add this to the Reply-Message value.

Note

To execute SQL queries you need to include and configure FreeRADIUS to use the sql module. The sql module also needs to be used in at least one section, for instance, the authorize or the accounting section.

  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(control:Auth-Type ...

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.