Problem expanding "%{Calling-Station-Id}"

Ana Gallardo Gómez anaougu at gmail.com
Wed May 4 12:05:25 CEST 2016


Hello all :)

I'm using FreeRADIUS Version 3.0.8in a debian 8.

I want to exec a sql query to return a value in Reply-Message, but I don't
know why freeradius doesn't expand Calling-Station-Id every time...

I use:

Reply-Message := "%{sqllocal:SELECT username FROM radpostauth WHERE client
like 'PA%%' and reply='Access-Accept' and mac='%{Calling-Station-Id}' and
authdate > (SELECT DATE_SUB(NOW(),INTERVAL 1 DAY)) order by authdate desc
limit 1}"

My log:

Wed May  4 11:48:37 2016 : Debug: (0) Received Access-Request Id 215 from
192.168.1.15:47353 to 192.168.1.3:1812 length 80
Wed May  4 11:48:37 2016 : Debug: (0)   User-Name = 'nodowifi at nodo.unex.es'
Wed May  4 11:48:37 2016 : Debug: (0)   User-Password = 'password'
Wed May  4 11:48:37 2016 : Debug: (0)   Calling-Station-Id =
'f0:f6:1c:58:da:cd'
Wed May  4 11:48:37 2016 : Debug: (0) session-state: No State attribute
Wed May  4 11:48:37 2016 : Debug: (0) # Executing section authorize from
file /etc/freeradius/sites-enabled/captive

In Hints, freeradius doesn't expand Calling-Station-Id:

DEFAULT    Realm == "nodo.unex.es"
        Reply-Message = "%{sqllocal:SELECT username FROM radpostauth WHERE
client like 'PA%%' and reply='Access-Accept' and
mac='%{Calling-Station-Id}' and authdate > (SELECT DATE_SUB(NOW(),INTERVAL
1 DAY)) order by authdate desc limit 1}",

Log:

Wed May  4 11:48:37 2016 : Debug: (0) preprocess: ::: Examining
Reply-Message
Wed May  4 11:48:37 2016 : Debug: %{sqllocal:SELECT username FROM
radpostauth WHERE client like 'PA%%' and reply='Access-Accept' and
mac='%{Calling-Station-Id}' and authdate > (SELECT DATE_SUB(NOW(),INTERVAL
1 DAY)) order by authdate desc limit 1}
Wed May  4 11:48:37 2016 : Debug: Parsed xlat tree:
Wed May  4 11:48:37 2016 : Debug: xlat --> sqllocal
Wed May  4 11:48:37 2016 : Debug: {
Wed May  4 11:48:37 2016 : Debug:     literal --> SELECT username FROM
radpostauth WHERE client like 'PA
Wed May  4 11:48:37 2016 : Debug:     literal --> %
Wed May  4 11:48:37 2016 : Debug:     literal --> ' and
reply='Access-Accept' and mac='
Wed May  4 11:48:37 2016 : Debug:     attribute --> Calling-Station-Id
Wed May  4 11:48:37 2016 : Debug:     literal --> ' and authdate > (SELECT
DATE_SUB(NOW(),INTERVAL 1 DAY)) order by authdate desc limit 1
Wed May  4 11:48:37 2016 : Debug: }
Wed May  4 11:48:37 2016 : Debug:
%{%{Stripped-User-Name}:-%{%{User-Name}:-DEFAULT}}
Wed May  4 11:48:37 2016 : Debug: Parsed xlat tree:
Wed May  4 11:48:37 2016 : Debug: if {
Wed May  4 11:48:37 2016 : Debug:     attribute --> Stripped-User-Name
Wed May  4 11:48:37 2016 : Debug: }
Wed May  4 11:48:37 2016 : Debug: else {
Wed May  4 11:48:37 2016 : Debug:     if {
Wed May  4 11:48:37 2016 : Debug:         attribute --> User-Name
Wed May  4 11:48:37 2016 : Debug:     }
Wed May  4 11:48:37 2016 : Debug:     else {
Wed May  4 11:48:37 2016 : Debug:         literal --> DEFAULT
Wed May  4 11:48:37 2016 : Debug:     }
Wed May  4 11:48:37 2016 : Debug: }
Wed May  4 11:48:37 2016 : Debug: (0) preprocess: EXPAND
%{%{Stripped-User-Name}:-%{%{User-Name}:-DEFAULT}}
Wed May  4 11:48:37 2016 : Debug: (0) preprocess:    -->
nodowifi at nodo.unex.es
Wed May  4 11:48:37 2016 : Debug: (0) preprocess: SQL-User-Name set to '
nodowifi at nodo.unex.es'
Wed May  4 11:48:37 2016 : Debug: (0) preprocess: ::: FROM 1 TO 1 MAX 2
Wed May  4 11:48:37 2016 : Debug: (0) preprocess: ::: Examining
SQL-User-Name
Wed May  4 11:48:37 2016 : Debug: (0) preprocess: ::: APPENDING
SQL-User-Name FROM 0 TO 1
Wed May  4 11:48:37 2016 : Debug: (0) preprocess: ::: TO in 1 out 2
Wed May  4 11:48:37 2016 : Debug: (0) preprocess: ::: to[0] = User-Name
Wed May  4 11:48:37 2016 : Debug: (0) preprocess: ::: to[1] = SQL-User-Name
Wed May  4 11:48:37 2016 : Debug: rlm_sql (sqllocal): Reserved connection
(4)
Wed May  4 11:48:37 2016 : Debug: /var/log/freeradius/sqllog.sql
Wed May  4 11:48:37 2016 : Debug: Parsed xlat tree:
Wed May  4 11:48:37 2016 : Debug: literal --> /var/log/freeradius/sqllog.sql
Wed May  4 11:48:37 2016 : Debug: (0) preprocess: EXPAND
/var/log/freeradius/sqllog.sql
Wed May  4 11:48:37 2016 : Debug: (0) preprocess:    -->
/var/log/freeradius/sqllog.sql
Wed May  4 11:48:37 2016 : Debug: (0) preprocess: Executing select query:
SELECT username FROM radpostauth WHERE client like 'PA%' and
reply='Access-Accept' and mac='' and authdate > (SELECT
DATE_SUB(NOW(),INTERVAL 1 DAY)) order by authdate desc limit 1
Wed May  4 11:48:37 2016 : Debug: (0) preprocess: SQL query returned no
results


In users, freeradius expand Calling-Station-Id:

nodowifi        Cleartext-Password := "password"
                Reply-Message := "%{sqllocal:SELECT username FROM
radpostauth WHERE client like 'PA%%' and reply='Access-Accept' and
mac='%{Calling-Station-Id}' and authdate > (SELECT DATE_SUB(NOW(),INTERVAL
1 DAY)) order by authdate desc limit 1}"


Wed May  4 11:48:37 2016 : Debug: (0) files: ::: Examining Reply-Message
Wed May  4 11:48:37 2016 : Debug: %{sqllocal:SELECT username FROM
radpostauth WHERE client like 'PA%%' and reply='Access-Accept' and
mac='%{Calling-Station-Id}' and authdate > (SELECT DATE_SUB(NOW(),INTERVAL
1 DAY)) order by authdate desc limit 1}
Wed May  4 11:48:37 2016 : Debug: Parsed xlat tree:
Wed May  4 11:48:37 2016 : Debug: xlat --> sqllocal
Wed May  4 11:48:37 2016 : Debug: {
Wed May  4 11:48:37 2016 : Debug:     literal --> SELECT username FROM
radpostauth WHERE client like 'PA
Wed May  4 11:48:37 2016 : Debug:     literal --> %
Wed May  4 11:48:37 2016 : Debug:     literal --> ' and
reply='Access-Accept' and mac='
Wed May  4 11:48:37 2016 : Debug:     attribute --> Calling-Station-Id
Wed May  4 11:48:37 2016 : Debug:     literal --> ' and authdate > (SELECT
DATE_SUB(NOW(),INTERVAL 1 DAY)) order by authdate desc limit 1
Wed May  4 11:48:37 2016 : Debug: }
Wed May  4 11:48:37 2016 : Debug:
%{%{Stripped-User-Name}:-%{%{User-Name}:-DEFAULT}}
Wed May  4 11:48:37 2016 : Debug: Parsed xlat tree:
Wed May  4 11:48:37 2016 : Debug: if {
Wed May  4 11:48:37 2016 : Debug:     attribute --> Stripped-User-Name
Wed May  4 11:48:37 2016 : Debug: }
Wed May  4 11:48:37 2016 : Debug: else {
Wed May  4 11:48:37 2016 : Debug:     if {
Wed May  4 11:48:37 2016 : Debug:         attribute --> User-Name
Wed May  4 11:48:37 2016 : Debug:     }
Wed May  4 11:48:37 2016 : Debug:     else {
Wed May  4 11:48:37 2016 : Debug:         literal --> DEFAULT
Wed May  4 11:48:37 2016 : Debug:     }
Wed May  4 11:48:37 2016 : Debug: }
Wed May  4 11:48:37 2016 : Debug: (0) files: EXPAND
%{%{Stripped-User-Name}:-%{%{User-Name}:-DEFAULT}}
Wed May  4 11:48:37 2016 : Debug: (0) files:    --> nodowifi
Wed May  4 11:48:37 2016 : Debug: (0) files: SQL-User-Name set to 'nodowifi'
Wed May  4 11:48:37 2016 : Debug: (0) files: ::: FROM 1 TO 9 MAX 10
Wed May  4 11:48:37 2016 : Debug: (0) files: ::: Examining SQL-User-Name
Wed May  4 11:48:37 2016 : Debug: (0) files: ::: APPENDING SQL-User-Name
FROM 0 TO 9
Wed May  4 11:48:37 2016 : Debug: (0) files: ::: TO in 9 out 10
Wed May  4 11:48:37 2016 : Debug: (0) files: ::: to[0] = User-Name
Wed May  4 11:48:37 2016 : Debug: (0) files: ::: to[1] = User-Password
Wed May  4 11:48:37 2016 : Debug: (0) files: ::: to[2] = Calling-Station-Id
Wed May  4 11:48:37 2016 : Debug: (0) files: ::: to[3] = Stripped-User-Name
Wed May  4 11:48:37 2016 : Debug: (0) files: ::: to[4] = Realm
Wed May  4 11:48:37 2016 : Debug: (0) files: ::: to[5] = Event-Timestamp
Wed May  4 11:48:37 2016 : Debug: (0) files: ::: to[6] = NAS-IP-Address
Wed May  4 11:48:37 2016 : Debug: (0) files: ::: to[7] = Reply-Message
Wed May  4 11:48:37 2016 : Debug: (0) files: ::: to[8] = Tipo-Usuario
Wed May  4 11:48:37 2016 : Debug: (0) files: ::: to[9] = SQL-User-Name
Wed May  4 11:48:37 2016 : Debug: rlm_sql (sqllocal): Reserved connection
(4)
Wed May  4 11:48:37 2016 : Debug: /var/log/freeradius/sqllog.sql
Wed May  4 11:48:37 2016 : Debug: Parsed xlat tree:
Wed May  4 11:48:37 2016 : Debug: literal --> /var/log/freeradius/sqllog.sql
Wed May  4 11:48:37 2016 : Debug: (0) files: EXPAND
/var/log/freeradius/sqllog.sql
Wed May  4 11:48:37 2016 : Debug: (0) files:    -->
/var/log/freeradius/sqllog.sql
Wed May  4 11:48:37 2016 : Debug: (0) files: Executing select query: SELECT
username FROM radpostauth WHERE client like 'PA%' and reply='Access-Accept'
and mac='f0:f6:1c:58:da:cd' and authdate > (SELECT DATE_SUB(NOW(),INTERVAL
1 DAY)) order by authdate desc limit 1
Wed May  4 11:48:37 2016 : Debug: rlm_sql (sqllocal): Released connection
(4)
Wed May  4 11:48:37 2016 : Debug: (0) files: EXPAND %{sqllocal:SELECT
username FROM radpostauth WHERE client like 'PA%%' and
reply='Access-Accept' and mac='%{Calling-Station-Id}' and authdate >
(SELECT DATE_SUB(NOW(),INTERVAL 1 DAY)) order by authdate desc limit 1}
Wed May  4 11:48:37 2016 : Debug: (0) files:    --> 961621qb at nodo.unex.es

Thank you very much in advance.


::::::::::::::::::::::::::::::::::::
:: Ana Gallardo Gómez ::
::::::::::::::::::::::::::::::::::::


More information about the Freeradius-Users mailing list