SQL insert in rlm_expr

Marius Booysen tuppe99 at gmail.com
Fri Jun 16 15:47:56 CEST 2017


Thanks Alan,

Here is an excerpt from the debug log:

(0)     policy log_tos {

(0)       if ("%{reply:Class}" =~ /TOS/) {

(0)       EXPAND %{reply:Class}

(0)          --> :111111:11111111:TOS:

(0)       if ("%{reply:Class}" =~ /TOS/)  -> TRUE

(0)       if ("%{reply:Class}" =~ /TOS/)  {

(0)         EXPAND %{User-Name}

(0)            --> fr-end-prof8813@ <fr-end-prof8813 at eircom.net>example.org

(0)         SQL-User-Name set to 'fr-end-prof8813 at example.org'

rlm_sql (sql): Reserved connection (1)

(0)         Executing query: insert into tos values ("TEST TOS");

rlm_sql (sql): Released connection (1)

(0)         EXPAND %{sql:insert into tos values ("TEST TOS");}

(0)            --> 1

(0)       } # if ("%{reply:Class}" =~ /TOS/)  = ok

(0)     } # policy log_tos = ok

(0)   } # post-auth = ok

*(0) Login OK: [fr-end-prof8813 at example.org <fr-end-prof8813 at example.org>]
(from client localhost port 3525263410)*



On Fri, Jun 16, 2017 at 12:34 PM, Alan DeKok <aland at deployingradius.com>
wrote:

> On Jun 16, 2017, at 4:33 AM, Marius Booysen <tuppe99 at gmail.com> wrote:
> > I am using version 3.0.14 and I know you can use the sql module in
> rlm_expr
> > e.g
> > %{sql:SELECT.....WHERE...}
> >
> > Now I am wondering if this is limited to select statements only or can I
> > insert a row into a custom table like this:
> >
> > %{sql:INSERT INTO mytab (id) values (100)}
>
>   You should be able to INSERT using xlat.
>
> > I tried this in a policy and the policy executes fine (debugging shows
> that
> > it is executing the insert) and returns ok, but the mytab table stays
> empty.
>
>   Post the debug output here.
>
> > Am I doing something wrong or is it just not supported?
>
>   It's supported.
>
>   Alan DeKok.
>
>
> -
> List info/subscribe/unsubscribe? See http://www.freeradius.org/
> list/users.html


More information about the Freeradius-Users mailing list