Hi, I'm trying to implement freeradius with perl module, but have strange bug, perl module gives wrong ip address, not that one which it takes from mysql, it is observed in freeradius debug, but the perl module itself gives right ip address in syslog messages.
Here is the piece of code-
Here is the piece of code-
Perl:
$dbh = DBI->connect($dsn,$username,$password, \%attr);
$SQL="SELECT * FROM radius_reply WHERE uname = '$user_name' and conn_type = 'dhcp'";
$sth = $dbh->prepare($SQL);
$sth->execute();
$num_of_rows = $sth->rows;
if($num_of_rows == 0){
$message = "authenticate_dhcp, status: error, err_str: username not found, username: $user_name";
$result = RLM_MODULE_REJECT;
}elsif($num_of_rows == 1) {
while (@row = $sth->fetchrow_array()) {
$RAD_REPLY{'Service-Type'} = 'Framed-User';
$RAD_REPLY{'Framed-Ip-Netmask'} = $row[5];
$RAD_REPLY{'Framed-Ip-Address'} = $row[4];
syslog(LOG_INFO, "$row[4] +++ $user_name");
syslog(LOG_INFO, "$RAD_REPLY{'Framed-Ip-Address'} +-+-+ $user_name");
$RAD_REPLY{'ERX-Service-Activate:1'} = $row[9];
$RAD_REPLY{'ERX-Client-Profile-Name'} = $row[10];
}
$message = "authenticate_dhcp, status: ok, username: $user_name";
$result = RLM_MODULE_OK;
} else {
$message = "authenticate_dhcp, status: error, err_str: username presents more than once, username: $user_name";
$result = RLM_MODULE_REJECT;
}
$sth->finish();
$dbh->disconnect();
syslog(LOG_INFO, $message);
}else{
#$message = "authenticate_pppoe, status: ok, username: $user_name";
#$result = RLM_MODULE_OK;
#syslog(LOG_INFO, $message);
$message = "authenticate_else, status: error, no ERX-DHCP-Header username: $user_name";
$result = RLM_MODULE_REJECT;
}
return $result;
}