Hi, I have a couple of modules in this order, and I need to log only rejects(from each module) to sql, - check_password, "a1 User-Password := "a1" - check_maxoctets, "a1 Max-All-Octets := 100000" in my authorize section, I have this, ... check_password if(notfound) { # log notfound to sql, the line below gives error... "%{sql: INSERT INTO test.logs SET test.logs.user='%{User-Name}', test.description='user not found' }" } check_maxoctets if(reject) { # log to sql... } ... When I start radiusd, it gives: ... rlm_fastusers: Loaded 3 users and 1 defaults /home/radius205/etc/raddb/sites-enabled/default[99]: Failed to find module "%{sql: INSERT INTO test.logs SET test.logs.user='%{User-Name}', test.description='user not found' }". /home/radius205/etc/raddb/sites-enabled/default[99]: Failed to parse "%{sql: INSERT INTO test.logs SET test.logs.user='%{User-Name}', test.description='user not found' }" entry. /home/radius205/etc/raddb/sites-enabled/default[62]: Errors parsing authorize section. } } Errors initializing modules ... man unlang says it is possible to obtain results from db, but I need to execute only sql INSERT, is my syntax wrong ? Thanks, Flamur
mysql syntax error. You probably want test.logs.description. You should test those statements on the database before putting them into the configuration. Ivan Kalik Kalik Informatika ISP Dana 19/6/2008, "Flamur Rogova" <flamur@ipko.net> piše:
Hi,
I have a couple of modules in this order, and I need to log only rejects(from each module) to sql, - check_password, "a1 User-Password := "a1" - check_maxoctets, "a1 Max-All-Octets := 100000"
in my authorize section, I have this, .... check_password if(notfound) { # log notfound to sql, the line below gives error... "%{sql: INSERT INTO test.logs SET test.logs.user='%{User-Name}', test.description='user not found' }" } check_maxoctets if(reject) { # log to sql... } ....
When I start radiusd, it gives: .... rlm_fastusers: Loaded 3 users and 1 defaults /home/radius205/etc/raddb/sites-enabled/default[99]: Failed to find module "%{sql: INSERT INTO test.logs SET test.logs.user='%{User-Name}', test.description='user not found' }". /home/radius205/etc/raddb/sites-enabled/default[99]: Failed to parse "%{sql: INSERT INTO test.logs SET test.logs.user='%{User-Name}', test.description='user not found' }" entry. /home/radius205/etc/raddb/sites-enabled/default[62]: Errors parsing authorize section. } } Errors initializing modules ....
man unlang says it is possible to obtain results from db, but I need to execute only sql INSERT, is my syntax wrong ?
Thanks, Flamur - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Flamur Rogova wrote:
in my authorize section, I have this, ... check_password if(notfound) { # log notfound to sql, the line below gives error... "%{sql: INSERT INTO test.logs SET test.logs.user='%{User-Name}', test.description='user not found' }"
You cannot put strings into the configuration like that.
man unlang says it is possible to obtain results from db, but I need to execute only sql INSERT, is my syntax wrong ?
Yes. Nothing in the documentation says that this will work. You can do: if ("%{sql:INSERT ..."") { ok } Alan DeKok.
Good day! So, I try to INSERT (unlang) data into my sql table; I made in site-enable/default something like this: if ( Service-Type == Framed-User ) { if ( "%{sqlauth: INSERT into MYTAB VALUES ('1','2','3','4')}" ) { ok } } and it does not work.... Tue Jan 27 23:06:32 2009 : Info: expand: INSERT into MYTAB ... Tue Jan 27 23:06:32 2009 : Debug: rlm_sql (sqlauth): Reserving sql socket id: 0 Tue Jan 27 23:06:32 2009 : Error: rlm_sql_oracle: query failed in sql_select_query: ORA-24333: zero iteration count Tue Jan 27 23:06:32 2009 : Error: rlm_sql_oracle: OCI_SERVER_NORMAL well, if I change my INSERT -> SELECT (for example) if ( Service-Type == Framed-User ) { if ( "%{sqlauth: SELECT COUNT from MYTAB}" ) { ok } } this works well.. Tue Jan 27 23:06:57 2009 : Debug: rlm_sql (sqlauth): Reserving sql socket id: 0 Tue Jan 27 23:06:57 2009 : Info: sql_xlat finished ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Tue Jan 27 23:06:57 2009 : Debug: rlm_sql (sqlauth): Released sql socket id: 0 In rlm_sql.c : /* * sql xlat function. Right now only SELECTs are supported. Only * the first element of the SELECT result will be used. */ Oh, I am really very interested in INSERT sql. Please, tell me, Is this right? Can I insert or update any data into my DB? Can I use another way for INSERT sql data when I do not use sql accounting and accounting_start_query/stop_query statement? I need to insert or update sql data when my customers do authorize check. Thank you. Alan DeKok:
Flamur Rogova wrote:
in my authorize section, I have this, ... check_password if(notfound) { # log notfound to sql, the line below gives error... "%{sql: INSERT INTO test.logs SET test.logs.user='%{User-Name}', test.description='user not found' }"
You cannot put strings into the configuration like that.
man unlang says it is possible to obtain results from db, but I need to execute only sql INSERT, is my syntax wrong ?
Yes. Nothing in the documentation says that this will work.
You can do:
if ("%{sql:INSERT ..."") { ok }
Alan DeKok. - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
-- Yours faithfully, Anton Borisov.
/* * sql xlat function. Right now only SELECTs are supported. Only * the first element of the SELECT result will be used. */
Oh, I am really very interested in INSERT sql. Please, tell me, Is this right? Can I insert or update any data into my DB? Can I use another way for INSERT sql data when I do not use sql accounting and accounting_start_query/stop_query statement? I need to insert or update sql data when my customers do authorize check.
I use perl. Ivan Kalik Kalik Informatika ISP
Good day! Thank you for your reply. I try to add prepaid system to my equipment. In this case when quota is reached, equipment sends Access-Request with quota comsumed and I need to store this data in sql. But. Unfortunately, I must think about how many on-line customers send quota to sql in same time. Yes, I can write perl script with sql insert and update and freeradius will execute this one every time for quota data. But, I think this is not for system with many customers. Do you mean Exec-programm perl? If you are talking about something else, please, give me some examples... Sorry for my language. Thank you! tnt@kalik.net wrote:
/* * sql xlat function. Right now only SELECTs are supported. Only * the first element of the SELECT result will be used. */
Oh, I am really very interested in INSERT sql. Please, tell me, Is this right? Can I insert or update any data into my DB? Can I use another way for INSERT sql data when I do not use sql accounting and accounting_start_query/stop_query statement? I need to insert or update sql data when my customers do authorize check.
I use perl.
Ivan Kalik Kalik Informatika ISP
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
-- Yours faithfully, Anton Borisov.
Anton Borisov wrote: Also may be try to do commit, or check that autocommit is set.
I try to add prepaid system to my equipment. In this case when quota is reached, equipment sends Access-Request with quota comsumed and I need to store this data in sql. But. Unfortunately, I must think about how many on-line customers send quota to sql in same time. Yes, I can write perl script with sql insert and update and freeradius will execute this one every time for quota data. But, I think this is not for system with many customers. Do you mean Exec-programm perl? If you are talking about something else, please, give me some examples... Sorry for my language.
-- With best regards, Evgeniy Kozhuhovskiy Leader, Services team Minsk State Phone Network, RUE Beltelecom.
I try to add prepaid system to my equipment. In this case when quota is reached, equipment sends Access-Request with quota comsumed and I need to store this data in sql. But. Unfortunately, I must think about how many on-line customers send quota to sql in same time. Yes, I can write perl script with sql insert and update and freeradius will execute this one every time for quota data. But, I think this is not for system with many customers.
Perl is very fast but it needs to open (and close) the connection to the database and that is expensive. Unlang uses threads open by freeradius at startup. So it will work faster. But I don't think that INSERT is supported. Ivan Kalik Kalik Informatika ISP
Good day! We have made sql oracle function. This function insert data into sql table, but we call into this funtion as "select myfunction ('aaa','bbbbbb') from dual" and it returns "OK: Quota consumed." And... this is wotking!! In unlang we added: if ("%{sqlauth: select myfunction ('...','...') from dual}") { ok } Now: Wed Jan 28 16:15:43 2009 : Info: expand: select myfunction... Wed Jan 28 16:15:43 2009 : Debug: rlm_sql (sqlauth): Reserving sql socket id: 0 Wed Jan 28 16:15:43 2009 : Info: sql_xlat finished Wed Jan 28 16:15:43 2009 : Debug: rlm_sql (sqlauth): Released sql socket id: 0 Wed Jan 28 16:15:43 2009 : Info: expand: %{sqlauth: select myfunction... -> OK: Quota consumed. Wed Jan 28 16:15:43 2009 : Info: ++++[reply] returns noop So, I can see my data from Access-Request in my sql table. tnt@kalik.net wrote:
I try to add prepaid system to my equipment. In this case when quota is reached, equipment sends Access-Request with quota comsumed and I need to store this data in sql. But. Unfortunately, I must think about how many on-line customers send quota to sql in same time. Yes, I can write perl script with sql insert and update and freeradius will execute this one every time for quota data. But, I think this is not for system with many customers.
Perl is very fast but it needs to open (and close) the connection to the database and that is expensive. Unlang uses threads open by freeradius at startup. So it will work faster. But I don't think that INSERT is supported.
Ivan Kalik Kalik Informatika ISP
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
-- Yours faithfully, Anton Borisov.
Anton Borisov wrote:
So, I try to INSERT (unlang) data into my sql table;
This isn't supported.
Oh, I am really very interested in INSERT sql. Please, tell me, Is this right? Can I insert or update any data into my DB? Can I use another way for INSERT sql data when I do not use sql accounting and accounting_start_query/stop_query statement? I need to insert or update sql data when my customers do authorize check.
Edit the source code to rlm_sql to look for "INSERT" in the query, and do an insert. Alan DeKok.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Alan DeKok wrote:
Flamur Rogova wrote:
in my authorize section, I have this, ... check_password if(notfound) { # log notfound to sql, the line below gives error... "%{sql: INSERT INTO test.logs SET test.logs.user='%{User-Name}', test.description='user not found' }"
You cannot put strings into the configuration like that.
man unlang says it is possible to obtain results from db, but I need to execute only sql INSERT, is my syntax wrong ?
Yes. Nothing in the documentation says that this will work.
You can do:
if ("%{sql:INSERT ..."") { ok }
No. Look at the code, only SELECT is available for xlat'd queries... Arran - -- Arran Cudbard-Bell (A.Cudbard-Bell@sussex.ac.uk), Authentication, Authorisation and Accounting Officer, Infrastructure Services (IT Services), E1-1-08, Engineering 1, University Of Sussex, Brighton, BN1 9QT DDI+FAX: +44 1273 873900 | INT: 3900 GPG: 86FF A285 1AA1 EE40 D228 7C2E 71A9 25BB 1E68 54A2 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkmAXukACgkQcaklux5oVKJaGACfY3O42M9nHvvWHPaYqQkI58vZ ijIAnRxjVNiR+VSB5BwT6TxKlJ2BjjP5 =OCFr -----END PGP SIGNATURE-----
participants (7)
-
Alan DeKok -
Anton Borisov -
Arran Cudbard-Bell -
Evgeniy Kozhuhovskiy -
Flamur Rogova -
Ivan Kalik -
tnt@kalik.net