Re: Implementing SQL Insert/logging for SoH.

2011-08-04 Thread Arran Cudbard-Bell

On 2 Aug 2011, at 16:09, Palmer J.D.F. wrote:

 Didn't think xlat could do inserts and updates?
 
 I wrote the patch to add the functionality and its been in the server
 code for about the past three years :)
 
 Good stuff. :)
 
 The source of rlm_sql.c still states only ...
 *  sql xlat function. Right now only SELECTs are supported.

Yeah its just to scare off the uninitiated. I guess I should really fix it :)

Arran Cudbard-Bell
a.cudba...@freeradius.org

RADIUS - Half the complexity of Diameter

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


Implementing SQL Insert/logging for SoH.

2011-08-02 Thread Palmer J.D.F.
Hi,

Further to my last foray onto the list regarding SoH, I'm looking to
commit the returned SoH info to the radius database using FreeRADIUS'
sql connection.

I could be well off target here, but please humour me, so far I have...

Created a table 'radsoh', and declared this inside sql.conf. 
Added a query (soh_query) to dialup.conf, at present this simply just
inserts User-Name to the table.
Declared soh_query in rlm_sql/conf.h
Declared soh_query in the 'module_config' section of rlm_sql.c
Declared a function, rlm_sql_soh, which is essentially a copy of
rlm_sql_postauth into rlm_sql.c.
Added rlm_sql_soh to the export section of rlm_sql.c.

It compiles and runs, but here is where I run out of ideas.

Presuming I'm on the right track, what else is required to enable the
query, and how would I make the call to execute the query? 
Ideally the call should be made from the with SoH virtual server defined
in raddb/sites-enabled.

Thanks,
Jezz.


Jezz Palmer
Information Services and Systems
Swansea University
Singleton Park
Swansea
SA2 8PP







-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


Re: Implementing SQL Insert/logging for SoH.

2011-08-02 Thread Alan DeKok
Palmer J.D.F. wrote:
 Further to my last foray onto the list regarding SoH, I'm looking to
 commit the returned SoH info to the radius database using FreeRADIUS'
 sql connection.

  It's just attributes.

 I could be well off target here, but please humour me, so far I have...
 
 Created a table 'radsoh', and declared this inside sql.conf. 

  OK...

 Added a query (soh_query) to dialup.conf, at present this simply just
 inserts User-Name to the table.

  Uh... that won't work.

 Declared soh_query in rlm_sql/conf.h
 Declared soh_query in the 'module_config' section of rlm_sql.c
 Declared a function, rlm_sql_soh, which is essentially a copy of
 rlm_sql_postauth into rlm_sql.c.
 Added rlm_sql_soh to the export section of rlm_sql.c.

 And all of that is unnecessary.

 It compiles and runs, but here is where I run out of ideas.
 
 Presuming I'm on the right track, what else is required to enable the
 query, and how would I make the call to execute the query? 
 Ideally the call should be made from the with SoH virtual server defined
 in raddb/sites-enabled.

  Read raddb/sites-available/soh.  The server runs an authorize
section.  This is *exactly* like the normal authorize section for a
RADIUS packet.  Just configure the authorize queries, and go.

  No source code mods are needed.

  Alan DeKok.
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


Re: Implementing SQL Insert/logging for SoH.

2011-08-02 Thread Arran Cudbard-Bell

On 2 Aug 2011, at 15:07, Alan DeKok wrote:

 Palmer J.D.F. wrote:
 Further to my last foray onto the list regarding SoH, I'm looking to
 commit the returned SoH info to the radius database using FreeRADIUS'
 sql connection.
 
  It's just attributes.

just use sql xlat...

update request {
Tmp-String-1 := %{sql:INSERT INTO ...}
}


Arran Cudbard-Bell
a.cudba...@freeradius.org

RADIUS - Half the complexity of Diameter

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


RE: Implementing SQL Insert/logging for SoH.

2011-08-02 Thread Palmer J.D.F.
  Palmer J.D.F. wrote:
  Further to my last foray onto the list regarding SoH, I'm looking
to
  commit the returned SoH info to the radius database using
 FreeRADIUS'
  sql connection.
 
   It's just attributes.
 
 just use sql xlat...
 
 update request {
   Tmp-String-1 := %{sql:INSERT INTO ...}
 }
 

Didn't think xlat could do inserts and updates?

Cheers,
Jezz.

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


Re: Implementing SQL Insert/logging for SoH.

2011-08-02 Thread Arran Cudbard-Bell

On 2 Aug 2011, at 15:44, Palmer J.D.F. wrote:

 Palmer J.D.F. wrote:
 Further to my last foray onto the list regarding SoH, I'm looking
 to
 commit the returned SoH info to the radius database using
 FreeRADIUS'
 sql connection.
 
 It's just attributes.
 
 just use sql xlat...
 
 update request {
  Tmp-String-1 := %{sql:INSERT INTO ...}
 }
 
 
 Didn't think xlat could do inserts and updates?

I wrote the patch to add the functionality and its been in the server code for 
about the past three years :)

-Arran

Arran Cudbard-Bell
a.cudba...@freeradius.org

RADIUS - Half the complexity of Diameter


-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


RE: Implementing SQL Insert/logging for SoH.

2011-08-02 Thread Palmer J.D.F.
  Didn't think xlat could do inserts and updates?
 
 I wrote the patch to add the functionality and its been in the server
 code for about the past three years :)

Good stuff. :)

The source of rlm_sql.c still states only ...
*  sql xlat function. Right now only SELECTs are supported.

We'd already tried - Tmp-String-5  := %{sql:INSERT into radsoh
(sid,data) VALUES (NULL,'ss');} - but it wasn't encapsulated in an
'update request {.. ..}' statement so failed, schoolboy error.  
I did some digging on interweb which said INSERTs not possible, then
read the above comment in the 2.1.11 source, so gave up on xlat then.

All sorted now though.

Thanks,
Jezz.

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html