Howto: Session-Timeout for DTAG (Zwangstrennung)

Uwe Kastens kiste at kiste.org
Mon Apr 20 19:13:08 CEST 2009


Hello list,

This might be interesting for users in germany, since there is a
disconnect each 24h if you are working with products from Deutsche
Telekom (DTAG). The disconnect will be forced, if the session is up for
more than 24h. So the job was to set the session-timeout so that logout
will ocur each day at the same time.

I solved it with freeradius/postgres with an internal sql-function. Its
a quick hack and there might be 100 better ways to solve. Here we go:

The function for postgres:
CREATE FUNCTION sessionto(character varying(64)) RETURNS integer AS'
DECLARE
user ALIAS FOR $1;
timeout INTEGER;
BEGIN
IF (select time from disctime where username=user and time is not NULL)
> extract(epoch from (localtime)) THEN
select into timeout round((select time from disctime where username=user
and time is not NULL) - extract(epoch from (localtime)));
ELSE
select into timeout round((86400 + (select time from disctime where
username=user and time is not NULL) - extract(epoch from (localtime))));
END IF;
if (timeout is NULL) THEN
timeout:=86399;
END IF;
RETURN timeout;
END;
' LANGUAGE 'plpgsql';

disctime is a table which has fields for username and time in seconds
since 0:00 of the day.


The session-timeout can be set via sql xlat from reply module as an
dynamic value:

attribute,op, value
Session-Timeout	= 	`%{sql: select sessionto('%{User-Name}') }`

BR

Uwe



-- 

kiste lat: 54.322684, lon: 10.13586



More information about the Freeradius-Users mailing list