Topic: Account expiration

I have a hotspot with chillispot and radius. When users buy for instance 1 day of internet time they can be logged on for 12 hours one day and 12 hours another.

I want to be able to make the account expire exactly 1 day after it is started instead of 1 day in total use.
How do I do this?

Re: Account expiration

you can add the expiration attribute to your radcheck table set up the date to expire when they first login.

Re: Account expiration

You can do that with the customized Access-Period attribute,
it is supported out of the box in daloRADIUS.

http://sourceforge.net/projects/daloradius/


Regards,
Liran.

4 (edited by gelvis 2008-10-31 13:56:50)

Re: Account expiration

I already had it setup like this. But it is still not expiring the way I want it to.

sqlcounter noresetcounter {
         counter-name = Max-All-Session-Time
         check-name = "Max-All-Session"
         sqlmod-inst = sql
         key = User-Name
         reset = never
         query = "SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='%{%k}'"
}
        sqlcounter dailycounter {
                counter-name = Daily-Session-Time
                check-name = Max-Daily-Session
                reply-name = Session-Timeout
                sqlmod-inst = sql
                key = User-Name
                reset = daily
                query = "SELECT SUM(AcctSessionTime - \                                                                             
                 GREATEST((%b - UNIX_TIMESTAMP(AcctStartTime)), 0)) \                                                               
                 FROM radacct WHERE UserName='%{%k}' AND \                                                                         
                 UNIX_TIMESTAMP(AcctStartTime) + AcctSessionTime > '%b'"
        }
        sqlcounter monthlycounter {
                counter-name = Monthly-Session-Time
                check-name = Max-Monthly-Session
                reply-name = Session-Timeout
                sqlmod-inst = sql
                key = User-Name
                reset = monthly
                query = "SELECT SUM(AcctSessionTime - \                                                                             
                 GREATEST((%b - UNIX_TIMESTAMP(AcctStartTime)), 0)) \                                                               
                 FROM radacct WHERE UserName='%{%k}' AND \                                                                         
                 UNIX_TIMESTAMP(AcctStartTime) + AcctSessionTime > '%b'"
        }
        always fail {
                rcode = fail
        }
        always reject {
                rcode = reject
        }
        always ok {
                rcode = ok
                simulcount = 0
                mpp = no
       }
        expr {
        }
        digest {
        }
        exec {
                wait = yes
                input_pairs = request
        }

exec echo {
                wait = yes
                program = "/bin/echo %{User-Name}"
                input_pairs = request
                output_pairs = reply
        }
        ippool main_pool {
                range-start = 192.168.182.3
                range-stop = 192.168.182.254
                netmask = 255.255.255.0
                cache-size = 800
                session-db = ${raddbdir}/db.ippool
                ip-index = ${raddbdir}/db.ipindex
                override = no
                maximum-timeout = 0
        }
}
authorize {
        preprocess
        chap
        mschap
        suffix
        sql
        noresetcounter
}

| 625 | gitbup6   | User-Password    | := | bonkacis   |
| 626 | gitbup6   | Simultaneous-Use | := | 1          |
| 627 | gitbup6   | Max-All-Session  | := | 300        |

Re: Account expiration

Yes.

627 | gitbup6   | Max-All-Session  | := | 300        |

Re: Account expiration

I'm using freeradius version 1.1.7 under FC8 with phpmyprepaid.  I also would like to have 3-day accounts expire exactly 3 days after the first login.  I follow the instruction found at http://www.warungdigital.com/freeradius-limit-user-access-by-period-started-from-activation-time.htm, but after I restart the server (using service radiusd restart) I have the following error:

Fri May 22 23:10:48 2009 : Error: /etc/raddb/radiusd.conf[1563]: Line is not in 'attribute = value' format
Fri May 22 23:10:48 2009 : Error: Errors reading radiusd.conf

What should I do?

Please see the related part of my radius.conf below:

in the module part:
------------
       sqlcounter accessperiod {
               counter-name = Max-Access-Period-Time
               check-name = Access-Period
               sqlmod-inst = sql
               key = User-Name
               reset = never
               query = "SELECT UNIX_TIMESTAMP() - UNIX_TIMESTAMP(AcctStartTime) FROM radacct \
               WHERE UserName = '%{%k}' LIMIT 1"
       }
-----------

in the authorization part:
-----------
        #
        # As of 1.1.4, you should list "pap" last in this section.
        # See "man rlm_pap" for more information.
        pap
noresetcounter
dailycounter
monthlycounter
accessperiod
}
----------

I have also added the following in the /etc/raddb/dictionary

ATTRIBUTE Access-Period 3000 integer



in radcheck table of mySQL database:

id          |  UserName   |  Attribute          |op |     Value
28003    |    3d               |  Access-Period   |:=  |    259200
28004    |    3d               |  User-Password  |:=  |    3d

Re: Account expiration

Hi dmkhn,

The line 1563 of the radius.conf is the query line 'query = "SELECT UNIX_TIMESTAMP() - UNIX_TIMESTAMP(AcctStartTime) FROM radacct \

WHERE UserName = '%{%k}' LIMIT 1"   <-----this line.

Re: Account expiration

Thanks very much kmkhn,  I have fixed the problem by removing the '\' of the query and make it in a whole one line.

It works now.

Thanks so much.