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'} = "xxx6000000"; &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 = 6000000 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.
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.
hi, all We were struggling a few weeks ago trying to get CDR collection to work. Does anybody know how to setup FreedRadius and Vocal CDR? You are very thankful, if you can help B.R Arthur Pan
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 = 600000
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
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 = 600000
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:6000000 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 = 6000000 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.
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
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
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 -- Best Regards, Boian Jordanov SNE Orbitel - Next Generation Telecom tel. +359 2 4004 723 tel. +359 2 4004 002
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 constant RLM_MODULE_REJECT=> 0;# /* immediately reject the request */ use constant RLM_MODULE_FAIL=> 1;# /* module failed, don't reply */ use constant RLM_MODULE_OK=> 2;# /* the module is OK, continue */ use constant RLM_MODULE_HANDLED=> 3;# /* the module handled the request, so stop. */ use constant RLM_MODULE_INVALID=> 4;# /* the module considers the request invalid. */ use constant RLM_MODULE_USERLOCK=> 5;# /* reject the request (user is locked out) */ use constant RLM_MODULE_NOTFOUND=> 6;# /* user not found */ use constant RLM_MODULE_NOOP=> 7;# /* module succeeded without doing anything */ use constant RLM_MODULE_UPDATED=> 8;# /* OK (pairs modified) */ use constant RLM_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; }
participants (3)
-
Arthur pan -
Boyan Jordanov -
Max Lock