Re: rlm_perl %RAD_REPLY issue
On Fri, 2005-10-14 at 09:48 +0300, Boyan Jordanov wrote: On Thursday 13 October 2005 21:55, Max Lock wrote: that's what I'm trying to do. sub authorize { Maybe you need authenticate instead of authorize ? Read docs/aaa.txt thanks Boyan, I realised that I'd accidently removed the var mappings for the return states RLM_MODULE... now it's all working fine, and the debug shows the vars I need going out.. just for the record, if anyone wants to limit a users data traffic here's some code, GPL applies as of current date... -Cheers Max. use DBI; use vars qw(%RAD_REQUEST %RAD_REPLY %RAD_CHECK); use Data::Dumper; # # This the remaping of return values # use constantRLM_MODULE_REJECT=0;# /* immediately reject the request */ use constantRLM_MODULE_FAIL= 1;# /* module failed, don't reply */ use constantRLM_MODULE_OK=2;# /* the module is OK, continue */ use constantRLM_MODULE_HANDLED= 3;# /* the module handled the request, so stop. */ use constantRLM_MODULE_INVALID= 4;# /* the module considers the request invalid. */ use constantRLM_MODULE_USERLOCK= 5;# /* reject the request (user is locked out) */ use constantRLM_MODULE_NOTFOUND= 6;# /* user not found */ use constantRLM_MODULE_NOOP= 7;# /* module succeeded without doing anything */ use constantRLM_MODULE_UPDATED= 8;# /* OK (pairs modified) */ use constantRLM_MODULE_NUMCODES= 9;# /* How many return codes there are */ sub authorize { my $used_user_octets = get_used_octets($RAD_REQUEST{'Stripped-User-Name'}); if (!$used_user_octets) { $used_user_octets = 0}; if (!$RAD_CHECK{'Max-All-Session-Data'}){ $unused_user_octets = ($RAD_CHECK{'Max-Daily-Session-Data'} - $used_user_octets); }else{ $unused_user_octets = ($RAD_CHECK{'Max-All-Session-Data'} - $used_user_octets); } radiusd::radlog(1,Voucher:$RAD_REQUEST{'Stripped-User-Name'} Used:$used_user_octets Total:$RAD_CHECK{'Max-Daily-Session-Data'} Left: $unused_user_octets); $RAD_REPLY{'ChilliSpot-Max-Total-Octets'} = $unused_user_octets; return RLM_MODULE_OK; } sub get_used_octets() { my $username = shift(@_); # get octets used from sql DB $dbuser = freeradius; $dbpassword = yourpasswordhere; $dbdatabase = freeradius; $dbhost = localhost; my $dsn = DBI:mysql:database=$dbdatabase;host=$dbhost; my $dbh = DBI-connect($dsn, $dbuser, $dbpassword); my $octets_used_sql = SELECT SUM(AcctInputOctets) + SUM(AcctOutputOctets) FROM radacct WHERE UserName='.$username.'; my $sth = $dbh-prepare($octets_used_sql); $sth-execute; my @results = $sth-fetchrow_array; my $used_user_octets = $results[0]; $sth-finish(); $dbh-disconnect(); return $used_user_octets; } - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Re: rlm_perl %RAD_REPLY issue
On Thursday 13 October 2005 05:08, Max Lock wrote: rlm_perl: ERROR: Failed to create pair Max-Total-Octets = 60 Do you have such attribute in your dictionary ? -- Best Regards, Boian Jordanov SNE Orbitel - Next Generation Telecom tel. +359 2 4004 723 tel. +359 2 4004 002 - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Re: rlm_perl %RAD_REPLY issue
On Thu, 2005-10-13 at 09:35 +0300, Boyan Jordanov wrote: On Thursday 13 October 2005 05:08, Max Lock wrote: rlm_perl: ERROR: Failed to create pair Max-Total-Octets = 60 Do you have such attribute in your dictionary ? You beauty! I do now :) works a treat! thankyou, I've been trying to get this working all day! :) -Max - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Re: rlm_perl %RAD_REPLY issue
On Thu, 2005-10-13 at 20:31 +1300, Max Lock wrote: On Thu, 2005-10-13 at 09:35 +0300, Boyan Jordanov wrote: On Thursday 13 October 2005 05:08, Max Lock wrote: rlm_perl: ERROR: Failed to create pair Max-Total-Octets = 60 Do you have such attribute in your dictionary ? You beauty! I do now :) works a treat! thankyou, I've been trying to get this working all day! :) Just one more question! for some reason, simply setting the hash and returning RLM_MODULE_OK works fine. but I'm returning the contents of a variable.. $RAD_REPLY{'ChilliSpot-Max-Total-Octets'} = $unused_user_octets; however the module then returns a reject? when it shouldn't? perl_pool: item 0x814b2b0 asigned new request. Handled so far: 1 found interpetator at address 0x814b2b0 rlm_perl: Voucher:QEMRS3LFLC01 Used:1003947 Total:600 Left:4996053 rlm_perl: RAD_REPLY: Acct-Interim-Interval = 120 rlm_perl: RAD_REPLY: Idle-Timeout = 300 rlm_perl: RAD_REPLY: Session-Timeout = 208 rlm_perl: RAD_REPLY: WISPr-Bandwidth-Max-Up = 128000 rlm_perl: RAD_REPLY: ChilliSpot-Max-Total-Octets = 4996053 rlm_perl: RAD_REPLY: WISPr-Bandwidth-Max-Down = 256000 rlm_perl: Added pair Acct-Interim-Interval = 120 rlm_perl: Added pair Idle-Timeout = 300 rlm_perl: Added pair Session-Timeout = 208 rlm_perl: Added pair WISPr-Bandwidth-Max-Up = 128000 rlm_perl: Added pair ChilliSpot-Max-Total-Octets = 4996053 rlm_perl: Added pair WISPr-Bandwidth-Max-Down = 256000 rlm_perl: Added pair Max-Daily-Session-Data = 600 rlm_perl: Added pair Password = QEMRS3LFLC01 rlm_perl: Added pair Simultaneous-Use = 1 rlm_perl: Added pair Max-Daily-Session-Time = 7200 rlm_perl: Added pair Auth-Type = Local perl_pool total/active/spare [5/0/5] Unreserve perl at address 0x814b2b0 modcall[authorize]: module perl returns reject for request 0 modcall: group authorize returns reject for request 0 What's happening? -Thanks Max. - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Re: rlm_perl %RAD_REPLY issue
On Thursday 13 October 2005 11:35, Max Lock wrote: Just one more question! for some reason, simply setting the hash and returning RLM_MODULE_OK works fine. but I'm returning the contents of a variable.. $RAD_REPLY{'ChilliSpot-Max-Total-Octets'} = $unused_user_octets; however the module then returns a reject? when it shouldn't? You don't need to return a variable just fill the hash and then return RLM_MODULE_OK, and then rlm_perl will take the values from hash and put them in radreply. -- Best Regards, Boian Jordanov SNE Orbitel - Next Generation Telecom tel. +359 2 4004 723 tel. +359 2 4004 002 - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Re: rlm_perl %RAD_REPLY issue
On Thu, 2005-10-13 at 15:14 +0300, Boyan Jordanov wrote: You don't need to return a variable just fill the hash and then return RLM_MODULE_OK, and then rlm_perl will take the values from hash and put them in radreply. that's what I'm trying to do. sub authorize { my $used_user_octets = get_used_octets($RAD_REQUEST{'Stripped-User-Name'}); $unused_user_octets = ($RAD_CHECK{'Max-Daily-Session-Data'} - $used_user_octets); radiusd::radlog(1,Voucher:$RAD_REQUEST{'Stripped-User-Name'} Used: $used_user_octets Total:$RAD_CHECK{'Max-Daily-Session-Data'} Left: $unused_user_octets); $RAD_REPLY{'ChilliSpot-Max-Total-Octets'} = $unused_user_octets; return RLM_MODULE_OK; } The log line shows that the variables are all correctly populated. -Cheers Max - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
rlm_perl %RAD_REPLY issue
Hi Folks, trying to run version 1.0.4 on Debian sarge.. export LD_PRELOAD=/usr/lib/libperl.so.5.8; freeradius -X (to account for known debian weirdness) using rlm_perl like so... sub authorize { $RAD_REPLY{'Max-Total-Octets'} = xxx600; log_request_attributes; log_reply_attributes; log_check_attributes; return RLM_MODULE_UPDATED; } and getting the following error on STDOUT... rlm_perl: ERROR: Failed to create pair Max-Total-Octets = 600 googled around, but can't see anything? other attribs in sql radgroupcheck table are working fine (also using rlm_sql). I took a look at the source code, but I'm not really a coder, and couldn't follow it too easily. However, all I can see is that the following is failing in rlm_perl.c vpp = pairmake(key, val, T_OP_EQ); if (vpp != NULL) { pairadd(vp, vpp); radlog(L_DBG, rlm_perl: Added pair %s = %s, key, val); return 1; } else { radlog(L_DBG, rlm_perl: ERROR: Failed to create pair %s = % s, key, val); } can anyone point me in the right direction? just going to try version 1.0.5 in the meantime :) -Thanks Max. - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Re: rlm_perl %RAD_REPLY issue
On Thu, 2005-10-13 at 15:08 +1300, Max Lock wrote: Hi Folks, trying to run version 1.0.4 on Debian sarge.. Nope, fails on 1.0.5 too :( also disregard the 3 x's in the attribute I was trying to pass, was just testing to see if it was an integer vs string type issue... -Cheers Max. - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html