Re: Deleting stale session automatically with unlang

2011-01-15 Thread Bishal Pun
Hello Eddie,

 Thanks for the help at last deleting the space from sql: Update section did
the tricks.

Thank you all for help.


Thank you
On Sat, Jan 15, 2011 at 1:00 PM, Eddie Stassen  wrote:

> I should not give that error according to the source. It definitely
> works in the latest version.  Perhaps its the space between 'sql:' and
> 'UPDATE' that is preventing the parser from recognising it as a
> non-select query.  Try removing it?
>
> On Sat, Jan 15, 2011 at 4:02 AM, Bishal Pun  wrote:
> > Hello Edi,
> >  Enclosing sql statement inside empty if gives same error:
> >
> > if(User-Name){
> > if("%{sql: UPDATE radacct set
> > AcctStopTime=ADDDATE(AcctStartTime,INTERVAL AcctSessionTime SECOND),
> > AcctTerminateCause='Clear-Stale Session' WHERE UserName='%{User-Name}'
> and
> > CallingStationId='%{Calling-Station-Id}' and AcctStopTime is NULL}"){
> > }
> > }
> > Sat Jan 15 07:43:33 2011 : Auth: Login OK: [test] (from client nagios
> port
> > 0)
> > Sat Jan 15 07:44:47 2011 : Error: rlm_sql_mysql: MYSQL Error: No Fields
> > Sat Jan 15 07:44:47 2011 : Error: rlm_sql_mysql: MYSQL error:
> > Sat Jan 15 07:44:47 2011 : Info: rlm_sql_mysql: Starting connect to MySQL
> > server for #3
> > Sat Jan 15 07:44:47 2011 : Error: rlm_sql (sql): failed after re-connect
> >
> >
> > On Fri, Jan 14, 2011 at 6:19 PM, Eddie Stassen 
> wrote:
> >>
> >> On Fri, Jan 14, 2011 at 1:57 PM, Johan Meiring
> >>  wrote:
> >> > On 2011/01/14 12:50 PM, Bishal Pun wrote:
> >> >>
> >> >> Alan,
> >> >>
> >> >>  While running that command in mysql it clear the session of user.
> But
> >> >> with
> >> >> radius unlang it is giving error in radius log.
> >> >>
> >> >
> >> > I might be wrong, but as far as I know rlm_mysql expects something to
> >> > come
> >> > back from the query.
> >> >
> >> > Can't think of a solution though unless rlm_mysql will allow somehting
> >> > like
> >> >
> >> > "%{sql: SELECT 1; UPDATE radacct set
> >> > AcctStopTime=ADDDATE(AcctStartTime,INTERVAL
> >> > AcctSessionTime SECOND), AcctTerminateCause='Clear-Stale Session'
> WHERE
> >> > UserName='%{User-Name}' and CallingStationId='%{Calling-Station-Id}'
> and
> >> > AcctStopTime is null}"
> >> >
> >> > --
> >>
> >> Enclosing the UPDATE in an empty 'if' works:
> >>
> >> if ("%{sql: UPDATE ...}") {
> >> }
> >>
> >> That prevents the rlm_sql_mysql module from looking for returned fields.
> >>
> >> Eddie
> >>
> >> -
> >> List info/subscribe/unsubscribe? See
> >> http://www.freeradius.org/list/users.html
> >
> >
> > -
> > List info/subscribe/unsubscribe? See
> > http://www.freeradius.org/list/users.html
> >
>
> -
> List info/subscribe/unsubscribe? See
> http://www.freeradius.org/list/users.html
>
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

Re: Deleting stale session automatically with unlang

2011-01-14 Thread Eddie Stassen
I should not give that error according to the source. It definitely
works in the latest version.  Perhaps its the space between 'sql:' and
'UPDATE' that is preventing the parser from recognising it as a
non-select query.  Try removing it?

On Sat, Jan 15, 2011 at 4:02 AM, Bishal Pun  wrote:
> Hello Edi,
>  Enclosing sql statement inside empty if gives same error:
>
> if(User-Name){
>     if("%{sql: UPDATE radacct set
> AcctStopTime=ADDDATE(AcctStartTime,INTERVAL AcctSessionTime SECOND),
> AcctTerminateCause='Clear-Stale Session' WHERE UserName='%{User-Name}' and
> CallingStationId='%{Calling-Station-Id}' and AcctStopTime is NULL}"){
>     }
> }
> Sat Jan 15 07:43:33 2011 : Auth: Login OK: [test] (from client nagios port
> 0)
> Sat Jan 15 07:44:47 2011 : Error: rlm_sql_mysql: MYSQL Error: No Fields
> Sat Jan 15 07:44:47 2011 : Error: rlm_sql_mysql: MYSQL error:
> Sat Jan 15 07:44:47 2011 : Info: rlm_sql_mysql: Starting connect to MySQL
> server for #3
> Sat Jan 15 07:44:47 2011 : Error: rlm_sql (sql): failed after re-connect
>
>
> On Fri, Jan 14, 2011 at 6:19 PM, Eddie Stassen  wrote:
>>
>> On Fri, Jan 14, 2011 at 1:57 PM, Johan Meiring
>>  wrote:
>> > On 2011/01/14 12:50 PM, Bishal Pun wrote:
>> >>
>> >> Alan,
>> >>
>> >>  While running that command in mysql it clear the session of user. But
>> >> with
>> >> radius unlang it is giving error in radius log.
>> >>
>> >
>> > I might be wrong, but as far as I know rlm_mysql expects something to
>> > come
>> > back from the query.
>> >
>> > Can't think of a solution though unless rlm_mysql will allow somehting
>> > like
>> >
>> > "%{sql: SELECT 1; UPDATE radacct set
>> > AcctStopTime=ADDDATE(AcctStartTime,INTERVAL
>> > AcctSessionTime SECOND), AcctTerminateCause='Clear-Stale Session' WHERE
>> > UserName='%{User-Name}' and CallingStationId='%{Calling-Station-Id}' and
>> > AcctStopTime is null}"
>> >
>> > --
>>
>> Enclosing the UPDATE in an empty 'if' works:
>>
>> if ("%{sql: UPDATE ...}") {
>> }
>>
>> That prevents the rlm_sql_mysql module from looking for returned fields.
>>
>> Eddie
>>
>> -
>> List info/subscribe/unsubscribe? See
>> http://www.freeradius.org/list/users.html
>
>
> -
> List info/subscribe/unsubscribe? See
> http://www.freeradius.org/list/users.html
>

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


Re: Deleting stale session automatically with unlang

2011-01-14 Thread Christ Schlacta

try appending the following snippet to the end of the SQL statement:

; SELECT COUNT(*) col FROM dual WHERE 1=1;

the result is numeric 1 is returned, and the requirement that something must
return is satisfied.

I believe there may be some other statement you can append instead to
"query the result of the last operation", which may be more appropriate, 
however,
I don't know the exact syntax.



On 1/14/2011 18:02, Bishal Pun wrote:

Hello Edi,
 Enclosing sql statement inside empty if gives same error:

if(User-Name){
if("%{sql: UPDATE radacct set 
AcctStopTime=ADDDATE(AcctStartTime,INTERVAL AcctSessionTime SECOND), 
AcctTerminateCause='Clear-Stale Session' WHERE UserName='%{User-Name}' 
and CallingStationId='%{Calling-Station-Id}' and AcctStopTime is NULL}"){

}
}
Sat Jan 15 07:43:33 2011 : Auth: Login OK: [test] (from client nagios 
port 0)

Sat Jan 15 07:44:47 2011 : Error: rlm_sql_mysql: MYSQL Error: No Fields
Sat Jan 15 07:44:47 2011 : Error: rlm_sql_mysql: MYSQL error:
Sat Jan 15 07:44:47 2011 : Info: rlm_sql_mysql: Starting connect to 
MySQL server for #3

Sat Jan 15 07:44:47 2011 : Error: rlm_sql (sql): failed after re-connect


On Fri, Jan 14, 2011 at 6:19 PM, Eddie Stassen > wrote:


On Fri, Jan 14, 2011 at 1:57 PM, Johan Meiring
mailto:jmeir...@pcservices.co.za>> wrote:
> On 2011/01/14 12:50 PM, Bishal Pun wrote:
>>
>> Alan,
>>
>>  While running that command in mysql it clear the session of
user. But
>> with
>> radius unlang it is giving error in radius log.
>>
>
> I might be wrong, but as far as I know rlm_mysql expects
something to come
> back from the query.
>
> Can't think of a solution though unless rlm_mysql will allow
somehting like
>
> "%{sql: SELECT 1; UPDATE radacct set
> AcctStopTime=ADDDATE(AcctStartTime,INTERVAL
> AcctSessionTime SECOND), AcctTerminateCause='Clear-Stale
Session' WHERE
> UserName='%{User-Name}' and
CallingStationId='%{Calling-Station-Id}' and
> AcctStopTime is null}"
>
> --

Enclosing the UPDATE in an empty 'if' works:

if ("%{sql: UPDATE ...}") {
}

That prevents the rlm_sql_mysql module from looking for returned
fields.

Eddie

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



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


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


Re: Deleting stale session automatically with unlang

2011-01-14 Thread Bishal Pun
Hello Edi,
 Enclosing sql statement inside empty if gives same error:

if(User-Name){
if("%{sql: UPDATE radacct set
AcctStopTime=ADDDATE(AcctStartTime,INTERVAL AcctSessionTime SECOND),
AcctTerminateCause='Clear-Stale Session' WHERE UserName='%{User-Name}' and
CallingStationId='%{Calling-Station-Id}' and AcctStopTime is NULL}"){
}
}
Sat Jan 15 07:43:33 2011 : Auth: Login OK: [test] (from client nagios port
0)
Sat Jan 15 07:44:47 2011 : Error: rlm_sql_mysql: MYSQL Error: No Fields
Sat Jan 15 07:44:47 2011 : Error: rlm_sql_mysql: MYSQL error:
Sat Jan 15 07:44:47 2011 : Info: rlm_sql_mysql: Starting connect to MySQL
server for #3
Sat Jan 15 07:44:47 2011 : Error: rlm_sql (sql): failed after re-connect


On Fri, Jan 14, 2011 at 6:19 PM, Eddie Stassen  wrote:

> On Fri, Jan 14, 2011 at 1:57 PM, Johan Meiring
>  wrote:
> > On 2011/01/14 12:50 PM, Bishal Pun wrote:
> >>
> >> Alan,
> >>
> >>  While running that command in mysql it clear the session of user. But
> >> with
> >> radius unlang it is giving error in radius log.
> >>
> >
> > I might be wrong, but as far as I know rlm_mysql expects something to
> come
> > back from the query.
> >
> > Can't think of a solution though unless rlm_mysql will allow somehting
> like
> >
> > "%{sql: SELECT 1; UPDATE radacct set
> > AcctStopTime=ADDDATE(AcctStartTime,INTERVAL
> > AcctSessionTime SECOND), AcctTerminateCause='Clear-Stale Session' WHERE
> > UserName='%{User-Name}' and CallingStationId='%{Calling-Station-Id}' and
> > AcctStopTime is null}"
> >
> > --
>
> Enclosing the UPDATE in an empty 'if' works:
>
> if ("%{sql: UPDATE ...}") {
> }
>
> That prevents the rlm_sql_mysql module from looking for returned fields.
>
> Eddie
>
> -
> List info/subscribe/unsubscribe? See
> http://www.freeradius.org/list/users.html
>
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

Re: Deleting stale session automatically with unlang

2011-01-14 Thread Eddie Stassen
On Fri, Jan 14, 2011 at 1:57 PM, Johan Meiring
 wrote:
> On 2011/01/14 12:50 PM, Bishal Pun wrote:
>>
>> Alan,
>>
>>  While running that command in mysql it clear the session of user. But
>> with
>> radius unlang it is giving error in radius log.
>>
>
> I might be wrong, but as far as I know rlm_mysql expects something to come
> back from the query.
>
> Can't think of a solution though unless rlm_mysql will allow somehting like
>
> "%{sql: SELECT 1; UPDATE radacct set
> AcctStopTime=ADDDATE(AcctStartTime,INTERVAL
> AcctSessionTime SECOND), AcctTerminateCause='Clear-Stale Session' WHERE
> UserName='%{User-Name}' and CallingStationId='%{Calling-Station-Id}' and
> AcctStopTime is null}"
>
> --

Enclosing the UPDATE in an empty 'if' works:

if ("%{sql: UPDATE ...}") {
}

That prevents the rlm_sql_mysql module from looking for returned fields.

Eddie

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


Re: Deleting stale session automatically with unlang

2011-01-14 Thread Johan Meiring

On 2011/01/14 12:50 PM, Bishal Pun wrote:

Alan,

  While running that command in mysql it clear the session of user. But with
radius unlang it is giving error in radius log.



I might be wrong, but as far as I know rlm_mysql expects something to come 
back from the query.


Can't think of a solution though unless rlm_mysql will allow somehting like

"%{sql: SELECT 1; UPDATE radacct set AcctStopTime=ADDDATE(AcctStartTime,INTERVAL
AcctSessionTime SECOND), AcctTerminateCause='Clear-Stale Session' WHERE
UserName='%{User-Name}' and CallingStationId='%{Calling-Station-Id}' and
AcctStopTime is null}"

--


Johan Meiring
Cape PC Services CC
Tel: (021) 883-8271
Fax: (021) 886-7782

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


Re: Deleting stale session automatically with unlang

2011-01-14 Thread Bishal Pun
Alan,

 While running that command in mysql it clear the session of user. But with
radius unlang it is giving error in radius log.

Thanks

On Fri, Jan 14, 2011 at 3:41 PM, Alan DeKok wrote:

> Bishal Pun wrote:
>
> > if(User-Name){
> > "%{sql: UPDATE radacct set AcctStopTime=ADDDATE(AcctStartTime,INTERVAL
> > AcctSessionTime SECOND), AcctTerminateCause='Clear-Stale Session' WHERE
> > UserName='%{User-Name}' and CallingStationId='%{Calling-Station-Id}' and
> > AcctStopTime is null}"
> > }
>
>   That should work, barring SQL issues.
>
> > but it doesn't help me, giving me error like
> > Wed Jan 12 15:16:14 2011 : Error: rlm_sql_mysql: MYSQL Error: No Fields
>
>   That's a MySQL issue.
>
> > any help?
>
>  Can you run the command from the mysql client?  i.e. without RADIUS
> being involved?
>
>  Alan DeKok.
> -
> List info/subscribe/unsubscribe? See
> http://www.freeradius.org/list/users.html
>
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

Re: Deleting stale session automatically with unlang

2011-01-14 Thread Alan DeKok
Bishal Pun wrote:

> if(User-Name){
> "%{sql: UPDATE radacct set AcctStopTime=ADDDATE(AcctStartTime,INTERVAL
> AcctSessionTime SECOND), AcctTerminateCause='Clear-Stale Session' WHERE
> UserName='%{User-Name}' and CallingStationId='%{Calling-Station-Id}' and
> AcctStopTime is null}"
> }

  That should work, barring SQL issues.

> but it doesn't help me, giving me error like
> Wed Jan 12 15:16:14 2011 : Error: rlm_sql_mysql: MYSQL Error: No Fields

  That's a MySQL issue.

> any help?

  Can you run the command from the mysql client?  i.e. without RADIUS
being involved?

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


Deleting stale session automatically with unlang

2011-01-13 Thread Bishal Pun
+Hi ,

 I am using freeradius 2.1.6 + mysql + LDAP for AAA in freebsd server. What
I want to do is, when my AP reboots or due to power failure clients login is
still seen there as online but the client is not able to do login. SO is it
possible to clear the stale session with unlang if the authentication
request come from same calling station id? I tried to do in
/etc/freeradius/sites-enable/default  authorize section

if(User-Name){
"%{sql: UPDATE radacct set AcctStopTime=ADDDATE(AcctStartTime,INTERVAL
AcctSessionTime SECOND), AcctTerminateCause='Clear-Stale Session' WHERE
UserName='%{User-Name}' and CallingStationId='%{Calling-Station-Id}' and
AcctStopTime is null}"
}

but it doesn't help me, giving me error like
Wed Jan 12 15:16:14 2011 : Error: rlm_sql_mysql: MYSQL Error: No Fields
Wed Jan 12 15:16:14 2011 : Error: rlm_sql_mysql: MYSQL error:
Wed Jan 12 15:16:14 2011 : Info: rlm_sql_mysql: Starting connect to MySQL
server for #4
Wed Jan 12 15:16:14 2011 : Error: rlm_sql (sql): failed after re-connect

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