I am fairly new to Radius, so please forgive me if this question is very basic. 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)} 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. Am I doing something wrong or is it just not supported? Thanks! Koos
On Jun 16, 2017, at 4:33 AM, Marius Booysen <tuppe99@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.
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@eircom.net>example.org (0) SQL-User-Name set to 'fr-end-prof8813@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@example.org <fr-end-prof8813@example.org>] (from client localhost port 3525263410)* On Fri, Jun 16, 2017 at 12:34 PM, Alan DeKok <aland@deployingradius.com> wrote:
On Jun 16, 2017, at 4:33 AM, Marius Booysen <tuppe99@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
On Jun 16, 2017, at 9:47 AM, Marius Booysen <tuppe99@gmail.com> wrote:
Here is an excerpt from the debug log: ... 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
Which means that one row was updated. It's working from the FreeRADIUS side. Alan DeKok.
Yes that is what I thought, but no updates were done on the mysql side. I was wondering if the return value of 1: --> 1 indicated success or failure. It is a very simple one column table, so I don't understand why the update is not there. Weird. On Fri, Jun 16, 2017 at 2:53 PM, Alan DeKok <aland@deployingradius.com> wrote:
On Jun 16, 2017, at 9:47 AM, Marius Booysen <tuppe99@gmail.com> wrote:
Here is an excerpt from the debug log: ... 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
Which means that one row was updated.
It's working from the FreeRADIUS side.
Alan DeKok.
- List info/subscribe/unsubscribe? See http://www.freeradius.org/ list/users.html
On Jun 16, 2017, at 9:58 AM, Bul <tuppe99@gmail.com> wrote:
Yes that is what I thought, but no updates were done on the mysql side. I was wondering if the return value of 1:
--> 1
indicated success or failure. It is a very simple one column table, so I don't understand why the update is not there. Weird.
The "1" indicates that 1 row was updated. Alan DeKok.
Ok, thanks. Now that I know it is supported, I will investigate some more. On Fri, Jun 16, 2017 at 2:59 PM, Alan DeKok <aland@deployingradius.com> wrote:
On Jun 16, 2017, at 9:58 AM, Bul <tuppe99@gmail.com> wrote:
Yes that is what I thought, but no updates were done on the mysql side. I was wondering if the return value of 1:
--> 1
indicated success or failure. It is a very simple one column table, so I don't understand why the update is not there. Weird.
The "1" indicates that 1 row was updated.
Alan DeKok.
- List info/subscribe/unsubscribe? See http://www.freeradius.org/ list/users.html
participants (3)
-
Alan DeKok -
Bul -
Marius Booysen