I am getting core dumped while running that script. rlm_perl: perl_embed:: module = /usr/local/etc/raddb/mac_check.pl , func = authorize exit status= Undefined subroutine &main::authorize called Segmentation fault (core dumped) ##Script part use vars qw(%RAD_REQUEST %RAD_REPLY %RAD_CHECK); $username = $RAD_REQUEST{'User-Name'}; $callerid = $RAD_REQUEST{'Calling-Station-Id'}; Is this the right process of getting value from the request ? How can I bypass perl function Authorization, authentication, accounting so that only MAC assignment process will be done by this script? Thanks On 5/15/2008, "Ivan Kalik" <tnt@kalik.net> wrote:
PS. You should run your script in authorize.
Ivan Kalik Kalik Informatika ISP
Dana 15/5/2008, "Bishal" <bishal@baayu.com.np> pi¹e:
Hello Ivan,
I came up with this scripts but looks like it;s not working. In radiusd.conf
perl{ modules = /usr/local/etc/raddb/mac_check.pl }
Instantiate { exec expr dailycounter noresetcounter perl }
radius debug shows perl modules loaded. But my script is not working. How can I assign variables username and callingStationid in my script during authentication process. rlm_perl doc show %RAD_REQUEST{'User-name'} but it's not helping?
#!/usr/bin/perl # Check for MAC Authentication is enable or not
#$username = $ARGV[4];
#$username = %RAD_REQUEST{'User-Name'}; #$callerid = %RAD_REQUEST{'Calling-Station-Id'};
use DBI;
$database = "radius"; $user = "freeradius"; $password = "blaba2r"; $option = "localhost";
$dsn = "DBI:mysql:$database"; $dsn = "DBI:mysql:database=$database;$option"; $dbh = DBI->connect($dsn, $user, $password);
my $sql = $dbh->prepare( "SELECT Usemac FROM radcheck WHERE UserName='$RAD_REQUEST{'User-Name'}' AND Attribute='Expiration' "); my $sql2 = $dbh->prepare( "SELECT Value FROM radcheck WHERE Attribute='Calling-Station-Id' AND UserName='tori' "); my $sql3 = $dbh->prepare( "INSERT INTO radcheck (id,UserName,Attribute,op,Value) VALUES('','$RAD_REQUEST{'User-Name'}','Calling-Statio n-Id','+=','$RAD_REQUEST{'Calling-Station-Id'}' ");
$rowcount = $sql->execute or die "Cannot execute SQL statement: $DBI::errstr\n";
my @row; while ( @row = $sql->fetchrow_array() ) { $mac = $row[0]; chomp($mac); } # Check if MAC authentication is enabled or not if enabled then insert the mac if ($mac == 1 ){
$rowcount = $sql3->execute or die "Cannot execute SQL Statement: $DBI::errstr\n";
}else { exit; } $sql->finish; $dbh->disconnect() or warn "Disconnection failed: $DBI::errstr\n";
On 5/14/2008, "Bishal" <bishal@baayu.com.np> wrote:
Any sample scripts IVAN?
On 5/14/2008, "Ivan Kalik" <tnt@kalik.net> wrote:
I am using sql for AAA.
I have news for you - you are not. You are using it to store attributes.
Can u give me some exaples how can I do that withl Rlm_perl modules.?
Do Google: mysql perl tutorial. If it's not MySQL, replace that with the name of your sql server.
Ivan Kalik Kalik Informatika ISP
- 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