Commit dee062c0 authored by Nigel Kukard's avatar Nigel Kukard
Browse files

Migrated to latest AWIT Perl Toolkit (master)

parent e32f9f2f
......@@ -24,7 +24,7 @@ use warnings;
# Set library directory
use lib qw(
smradius
awitpt
awitpt/lib
);
......@@ -337,8 +337,8 @@ use warnings;
use smradius::logging;
use smradius::config;
use awitpt::db::dbilayer;
use awitpt::db::dblayer;
use AWITPT::DB::DBILayer;
use AWITPT::DB::DBLayer;
# Return oursevles
sub new
......@@ -361,9 +361,9 @@ sub init
smradius::config::Init($self);
# Init system stuff
$self->{'client'}->{'dbh'} = awitpt::db::dbilayer::Init($self,'smradius');
$self->{'client'}->{'dbh'} = AWITPT::DB::DBILayer::Init($self,'smradius');
if (!defined($self->{'client'}->{'dbh'})) {
$self->log(LOG_WARN,"Failed to Initialize: ".awitpt::db::dbilayer::internalError()." ($$)");
$self->log(LOG_WARN,"Failed to Initialize: ".AWITPT::DB::DBILayer::internalError()." ($$)");
die;
}
if ($self->{'client'}->{'dbh'}->connect()) {
......@@ -371,7 +371,7 @@ sub init
die;
}
# Setup database handle
awitpt::db::dblayer::setHandle($self->{'client'}->{'dbh'});
AWITPT::DB::DBLayer::setHandle($self->{'client'}->{'dbh'});
return;
}
......
......@@ -22,8 +22,9 @@ use warnings;
# Modules we need
use smradius::constants;
use awitpt::cache;
use awitpt::db::dblayer;
use AWITPT::Cache;
use AWITPT::DB::DBLayer;
use AWITPT::Util;
use smradius::logging;
use smradius::util;
......@@ -353,7 +354,7 @@ sub getUsage
# Fetch data
my $sth = DBSelect(@dbDoParams);
if (!$sth) {
$server->log(LOG_ERR,"[MOD_ACCOUNTING_SQL] Database query failed: ".awitpt::db::dblayer::Error());
$server->log(LOG_ERR,"[MOD_ACCOUNTING_SQL] Database query failed: ".AWITPT::DB::DBLayer::Error());
return;
}
......@@ -458,7 +459,7 @@ sub acct_log
# Fetch previous records of the same session
my $sth = DBSelect(@dbDoParams);
if (!$sth) {
$server->log(LOG_ERR,"[MOD_ACCOUNTING_SQL] Database query failed: ".awitpt::db::dblayer::Error());
$server->log(LOG_ERR,"[MOD_ACCOUNTING_SQL] Database query failed: ".AWITPT::DB::DBLayer::Error());
return;
}
......@@ -549,7 +550,7 @@ sub acct_log
$sth = DBDo(@dbDoParams);
if (!$sth) {
$server->log(LOG_ERR,"[MOD_ACCOUNTING_SQL] Failed to update accounting ALIVE record: ".
awitpt::db::dblayer::Error());
AWITPT::DB::DBLayer::Error());
return MOD_RES_NACK;
}
......@@ -579,7 +580,7 @@ sub acct_log
my $sth = DBDo(@dbDoParams);
if (!$sth) {
$server->log(LOG_ERR,"[MOD_ACCOUNTING_SQL] Failed to insert accounting START record: ".
awitpt::db::dblayer::Error());
AWITPT::DB::DBLayer::Error());
return MOD_RES_NACK;
}
# Update first login?
......@@ -607,7 +608,7 @@ sub acct_log
# Update database (status)
my $sth = DBDo(@dbDoParams);
if (!$sth) {
$server->log(LOG_ERR,"[MOD_ACCOUNTING_SQL] Failed to update accounting STOP record: ".awitpt::db::dblayer::Error());
$server->log(LOG_ERR,"[MOD_ACCOUNTING_SQL] Failed to update accounting STOP record: ".AWITPT::DB::DBLayer::Error());
return MOD_RES_NACK;
}
}
......@@ -628,7 +629,7 @@ sub fixDuplicates
# Select duplicates
my $sth = DBSelect(@dbDoParams);
if (!$sth) {
$server->log(LOG_ERR,"[MOD_ACCOUNTING_SQL] Database query failed: ".awitpt::db::dblayer::Error());
$server->log(LOG_ERR,"[MOD_ACCOUNTING_SQL] Database query failed: ".AWITPT::DB::DBLayer::Error());
return;
}
......@@ -651,7 +652,7 @@ sub fixDuplicates
# Delete duplicates
$sth = DBDo(@dbDoParams);
if (!$sth) {
$server->log(LOG_ERR,"[MOD_ACCOUNTING_SQL] Database query failed: ".awitpt::db::dblayer::Error());
$server->log(LOG_ERR,"[MOD_ACCOUNTING_SQL] Database query failed: ".AWITPT::DB::DBLayer::Error());
DBRollback();
return;
}
......@@ -699,7 +700,7 @@ sub cleanup
);
if (!$sth) {
$server->log(LOG_ERR,"[MOD_ACCOUNTING_SQL] Cleanup => Failed to delete accounting summary record: ".
awitpt::db::dblayer::Error());
AWITPT::DB::DBLayer::Error());
DBRollback();
return;
}
......@@ -724,7 +725,7 @@ sub cleanup
);
if (!$sth) {
$server->log(LOG_ERR,"[MOD_ACCOUNTING_SQL] Cleanup => Failed to select accounting record: ".
awitpt::db::dblayer::Error());
AWITPT::DB::DBLayer::Error());
return;
}
......@@ -831,7 +832,7 @@ sub cleanup
);
if (!$sth) {
$server->log(LOG_ERR,"[MOD_ACCOUNTING_SQL] Cleanup => Failed to create accounting summary record: ".
awitpt::db::dblayer::Error());
AWITPT::DB::DBLayer::Error());
DBRollback();
return;
}
......
......@@ -26,6 +26,7 @@ use smradius::constants;
use smradius::logging;
use smradius::util;
use AWITPT::Util;
use POSIX qw(floor);
......
......@@ -22,7 +22,7 @@ use warnings;
# Modules we need
use smradius::constants;
use awitpt::db::dblayer;
use AWITPT::DB::DBLayer;
use smradius::logging;
use smradius::util;
......@@ -152,7 +152,7 @@ sub updateUserStats
# Perform query
my $sth = DBDo(@dbDoParams);
if (!$sth) {
$server->log(LOG_ERR,"[MOD_FEATURE_UPDATE_USER_STATS_SQL] Database query failed: ".awitpt::db::dblayer::Error());
$server->log(LOG_ERR,"[MOD_FEATURE_UPDATE_USER_STATS_SQL] Database query failed: ".AWITPT::DB::DBLayer::Error());
return;
}
......
......@@ -22,7 +22,7 @@ use warnings;
# Modules we need
use smradius::constants;
use awitpt::db::dblayer;
use AWITPT::DB::DBLayer;
use smradius::logging;
use smradius::util;
......
......@@ -23,9 +23,10 @@ use warnings;
# Modules we need
use smradius::constants;
use smradius::logging;
use awitpt::db::dblayer;
use awitpt::cache;
use awitpt::netip;
use AWITPT::DB::DBLayer;
use AWITPT::Cache;
use AWITPT::NetIP;
use AWITPT::Util;
use smradius::util;
use smradius::attributes;
......@@ -170,7 +171,7 @@ sub getConfig
$server->log(LOG_DEBUG,"Processing DEFAULT realm attributes");
my $sth = DBSelect($config->{'get_config_realm_id_query'},$realmName);
if (!$sth) {
$server->log(LOG_ERR,"Failed to get default realm ID: ".awitpt::db::dblayer::Error());
$server->log(LOG_ERR,"Failed to get default realm ID: ".AWITPT::DB::DBLayer::Error());
return MOD_RES_NACK;
}
# Set realm ID
......@@ -185,7 +186,7 @@ sub getConfig
if (defined($realmID)) {
$sth = DBSelect($config->{'get_config_realm_attributes_query'},$realmID);
if (!$sth) {
$server->log(LOG_ERR,"Failed to get default realm config attributes: ".awitpt::db::dblayer::Error());
$server->log(LOG_ERR,"Failed to get default realm config attributes: ".AWITPT::DB::DBLayer::Error());
return MOD_RES_NACK;
}
# Add any default realm attributes to config attributes
......@@ -203,7 +204,7 @@ sub getConfig
$sth = DBSelect($config->{'get_config_realm_id_query'},$realmName);
if (!$sth) {
$server->log(LOG_ERR,"Failed to get user realm config attributes: ".awitpt::db::dblayer::Error());
$server->log(LOG_ERR,"Failed to get user realm config attributes: ".AWITPT::DB::DBLayer::Error());
return MOD_RES_NACK;
}
# Fetch realm ID
......@@ -215,7 +216,7 @@ sub getConfig
# User realm attributes
$sth = DBSelect($config->{'get_config_realm_attributes_query'},$realmID);
if (!$sth) {
$server->log(LOG_ERR,"Failed to get user realm config attributes: ".awitpt::db::dblayer::Error());
$server->log(LOG_ERR,"Failed to get user realm config attributes: ".AWITPT::DB::DBLayer::Error());
return MOD_RES_NACK;
}
# Add any realm attributes to config attributes
......@@ -257,12 +258,12 @@ sub getConfig
$sth = DBSelect($config->{'get_config_accesslist_query'},$realmID);
if (!$sth) {
$server->log(LOG_ERR,"Failed to get config attributes: ".awitpt::db::dblayer::Error());
$server->log(LOG_ERR,"Failed to get config attributes: ".AWITPT::DB::DBLayer::Error());
return MOD_RES_NACK;
}
# Grab peer address object
my $peerAddrObj = new awitpt::netip($server->{'server'}{'peeraddr'});
my $peerAddrObj = AWITPT::NetIP->new($server->{'server'}{'peeraddr'});
# Check if we know this client
my @accessList;
......@@ -273,7 +274,7 @@ sub getConfig
@accessList = split(',',$res->{'AccessList'});
# Loop with what we get and check if we have match
foreach my $range (@accessList) {
my $rangeObj = new awitpt::netip($range);
my $rangeObj = new AWITPT::NetIP->new($range);
# Check for match
if ($peerAddrObj->is_within($rangeObj)) {
$clientID = $res->{'ID'};
......@@ -299,7 +300,7 @@ sub getConfig
if (defined($clientID)) {
my $sth = DBSelect($config->{'get_config_client_attributes_query'},$clientID);
if (!$sth) {
$server->log(LOG_ERR,"Failed to get default config attributes: ".awitpt::db::dblayer::Error());
$server->log(LOG_ERR,"Failed to get default config attributes: ".AWITPT::DB::DBLayer::Error());
return MOD_RES_NACK;
}
# Add to config attributes
......
......@@ -23,7 +23,8 @@ use warnings;
# Modules we need
use smradius::constants;
use smradius::logging;
use awitpt::db::dblayer;
use AWITPT::DB::DBLayer;
use AWITPT::Util;
use smradius::util;
use smradius::attributes;
......@@ -182,7 +183,7 @@ sub getTopups
# Query database
my $sth = DBSelect($config->{'get_topups_summary_query'},$periodKey,$username);
if (!$sth) {
$server->log(LOG_ERR,"Failed to get topup information: ".awitpt::db::dblayer::Error());
$server->log(LOG_ERR,"Failed to get topup information: ".AWITPT::DB::DBLayer::Error());
return MOD_RES_NACK;
}
while (my $row = hashifyLCtoMC($sth->fetchrow_hashref(), qw(Balance Type ID))) {
......@@ -193,7 +194,7 @@ sub getTopups
# Query database
$sth = DBSelect($config->{'get_topups_query'},$thisMonth->ymd,$now->ymd,$username);
if (!$sth) {
$server->log(LOG_ERR,"Failed to get topup information: ".awitpt::db::dblayer::Error());
$server->log(LOG_ERR,"Failed to get topup information: ".AWITPT::DB::DBLayer::Error());
return MOD_RES_NACK;
}
# Fetch all new topups
......@@ -251,7 +252,7 @@ sub cleanup
if (!$sth) {
$server->log(LOG_ERR,"[MOD_CONFIG_SQL_TOPUPS] Cleanup => Failed to select users: ".
awitpt::db::dblayer::Error());
AWITPT::DB::DBLayer::Error());
return;
}
......@@ -280,7 +281,7 @@ sub cleanup
);
if (!$sth) {
$server->log(LOG_ERR,"[MOD_CONFIG_SQL_TOPUPS] Cleanup => Failed to delete topup summaries: ".
awitpt::db::dblayer::Error());
AWITPT::DB::DBLayer::Error());
DBRollback();
return;
}
......@@ -297,7 +298,7 @@ sub cleanup
);
if (!$sth) {
$server->log(LOG_ERR,"[MOD_CONFIG_SQL_TOPUPS] Cleanup => Failed to undeplete topups: ".
awitpt::db::dblayer::Error());
AWITPT::DB::DBLayer::Error());
DBRollback();
return;
}
......@@ -316,7 +317,7 @@ sub cleanup
);
if (!$sth) {
$server->log(LOG_ERR,"[MOD_CONFIG_SQL_TOPUPS] Cleanup => Failed to retrieve accounting summaries: ".
awitpt::db::dblayer::Error());
AWITPT::DB::DBLayer::Error());
DBRollback();
return;
}
......@@ -343,7 +344,7 @@ sub cleanup
);
if (!$sth) {
$server->log(LOG_ERR,"[MOD_CONFIG_SQL_TOPUPS] Cleanup => Failed to select accounting summary record: ".
awitpt::db::dblayer::Error());
AWITPT::DB::DBLayer::Error());
goto FAIL_ROLLBACK;
}
......@@ -393,7 +394,7 @@ sub cleanup
if (!$sth) {
$server->log(LOG_ERR,"[MOD_CONFIG_SQL_TOPUPS] Cleanup => Failed to select group usage caps: ".
awitpt::db::dblayer::Error());
AWITPT::DB::DBLayer::Error());
goto FAIL_ROLLBACK;
}
......@@ -448,7 +449,7 @@ sub cleanup
if (!$sth) {
$server->log(LOG_ERR,"[MOD_CONFIG_SQL_TOPUPS] Cleanup => Failed to select user usage caps: ".
awitpt::db::dblayer::Error());
AWITPT::DB::DBLayer::Error());
goto FAIL_ROLLBACK;
}
......@@ -517,7 +518,7 @@ sub cleanup
if (!$sth) {
$server->log(LOG_ERR,"[MOD_CONFIG_SQL_TOPUPS] Cleanup => Failed to select topup summaries: ".
awitpt::db::dblayer::Error());
AWITPT::DB::DBLayer::Error());
goto FAIL_ROLLBACK;
}
......@@ -588,7 +589,7 @@ sub cleanup
if (!$sth) {
$server->log(LOG_ERR,"[MOD_CONFIG_SQL_TOPUPS] Cleanup => Failed to select topups: ".
awitpt::db::dblayer::Error());
AWITPT::DB::DBLayer::Error());
goto FAIL_ROLLBACK;
}
......@@ -980,7 +981,7 @@ sub cleanup
if (!$sth) {
$server->log(LOG_ERR,"[MOD_CONFIG_SQL_TOPUPS] Cleanup => Failed to create topup summary: ".
awitpt::db::dblayer::Error());
AWITPT::DB::DBLayer::Error());
goto FAIL_ROLLBACK;
}
......@@ -1007,7 +1008,7 @@ sub cleanup
);
if (!$sth) {
$server->log(LOG_ERR,"[MOD_CONFIG_SQL_TOPUPS] Cleanup => Failed to deplete topup: ".
awitpt::db::dblayer::Error());
AWITPT::DB::DBLayer::Error());
goto FAIL_ROLLBACK;
}
......@@ -1033,7 +1034,7 @@ sub cleanup
);
if (!$sth) {
$server->log(LOG_ERR,"[MOD_CONFIG_SQL_TOPUPS] Cleanup => Failed to update topups_summary: ".
awitpt::db::dblayer::Error());
AWITPT::DB::DBLayer::Error());
goto FAIL_ROLLBACK;
}
......
......@@ -22,9 +22,10 @@ use warnings;
# Modules we need
use smradius::constants;
use awitpt::cache;
use AWITPT::Cache;
use smradius::logging;
use awitpt::db::dblayer;
use AWITPT::DB::DBLayer;
use AWITPT::Util;
use smradius::util;
use smradius::attributes;
......@@ -137,7 +138,7 @@ sub find
my $sth = DBSelect(@dbDoParams);
if (!$sth) {
$server->log(LOG_ERR,"[MOD_USERDB_MACAUTH_SQL] Failed to find data for MAC address: ".awitpt::db::dblayer::Error());
$server->log(LOG_ERR,"[MOD_USERDB_MACAUTH_SQL] Failed to find data for MAC address: ".AWITPT::DB::DBLayer::Error());
return MOD_RES_SKIP;
}
......
......@@ -22,9 +22,10 @@ use warnings;
# Modules we need
use smradius::constants;
use awitpt::cache;
use AWITPT::Cache;
use smradius::logging;
use awitpt::db::dblayer;
use AWITPT::DB::DBLayer;
use AWITPT::Util;
use smradius::util;
use smradius::attributes;
......@@ -270,7 +271,7 @@ sub find
my $sth = DBSelect(@dbDoParams);
if (!$sth) {
$server->log(LOG_ERR,"[MOD_USERDB_SQL] Failed to find user data: ".awitpt::db::dblayer::Error());
$server->log(LOG_ERR,"[MOD_USERDB_SQL] Failed to find user data: ".AWITPT::DB::DBLayer::Error());
return MOD_RES_SKIP;
}
......@@ -330,7 +331,7 @@ sub get
# Query database
my $sth = DBSelect(@dbDoParams);
if (!$sth) {
$server->log(LOG_ERR,"Failed to get group attributes: ".awitpt::db::dblayer::Error());
$server->log(LOG_ERR,"Failed to get group attributes: ".AWITPT::DB::DBLayer::Error());
return RES_ERROR;
}
......@@ -348,7 +349,7 @@ sub get
# Query database
$sth = DBSelect(@dbDoParams);
if (!$sth) {
$server->log(LOG_ERR,"Failed to get user attributes: ".awitpt::db::dblayer::Error());
$server->log(LOG_ERR,"Failed to get user attributes: ".AWITPT::DB::DBLayer::Error());
return RES_ERROR;
}
......@@ -396,7 +397,7 @@ sub data_set
# Query database
my $sth = DBDo(@dbDoParams);
if (!$sth) {
$server->log(LOG_ERR,"Failed to update users data: ".awitpt::db::dblayer::Error());
$server->log(LOG_ERR,"Failed to update users data: ".AWITPT::DB::DBLayer::Error());
return RES_ERROR;
}
......@@ -407,7 +408,7 @@ sub data_set
# Insert
$sth = DBDo(@dbDoParams);
if (!$sth) {
$server->log(LOG_ERR,"Failed to set users data: ".awitpt::db::dblayer::Error());
$server->log(LOG_ERR,"Failed to set users data: ".AWITPT::DB::DBLayer::Error());
return RES_ERROR;
}
}
......@@ -476,7 +477,7 @@ sub data_get
# Query database
my $sth = DBSelect(@dbDoParams);
if (!$sth) {
$server->log(LOG_ERR,"Failed to get users data: ".awitpt::db::dblayer::Error());
$server->log(LOG_ERR,"Failed to get users data: ".AWITPT::DB::DBLayer::Error());
return RES_ERROR;
}
......
......@@ -21,7 +21,7 @@ use strict;
use warnings;
use lib('/usr/local/lib/smradius-0.0','/usr/lib/smradius-0.0',
'/usr/lib64/smradius-0.0','smradius','awitpt');
'/usr/lib64/smradius-0.0','smradius','awitpt/lib');
package smradiusd;
......@@ -49,7 +49,7 @@ if (!eval {require Cache::FastMmap; 1;}) {
print STDERR "You're missing DateTime, try 'apt-get install libcache-fastmmap-perl'\n";
exit 1;
} else {
eval {use awitpt::cache;};
eval {use AWITPT::Cache;};
}
......@@ -66,7 +66,7 @@ use smradius::version;
use smradius::constants;
use smradius::logging;
use smradius::config;
use awitpt::db::dbilayer;
use AWITPT::DB::DBILayer;
use smradius::util;
use smradius::attributes;
......@@ -386,7 +386,7 @@ sub post_configure_hook {
$self->log(LOG_INFO,"[SMRADIUS] Initializing system modules.");
# Init caching engine
awitpt::cache::Init($self,{
AWITPT::Cache::Init($self,{
'cache_file' => $self->{'config'}{'cache_file'},
'cache_file_user' => $self->{'server'}->{'user'},
'cache_file_group' => $self->{'server'}->{'group'}
......@@ -434,7 +434,7 @@ sub child_init_hook
$self->SUPER::child_init_hook();
$self->log(LOG_INFO,"[SMRADIUS] Starting up caching engine");
awitpt::cache::connect($self);
AWITPT::Cache::connect($self);
# Do we need database support?
if ($self->{'smradius'}->{'database'}->{'enabled'}) {
......@@ -443,7 +443,7 @@ sub child_init_hook
$self->{'client'}->{'dbh_status'} = time();
# Init core database support
$self->{'client'}->{'dbh'} = awitpt::db::dbilayer::Init($self,'smradius');
$self->{'client'}->{'dbh'} = AWITPT::DB::DBILayer::Init($self,'smradius');
if (defined($self->{'client'}->{'dbh'})) {
# Check if we succeeded
if (!($self->{'client'}->{'dbh'}->connect())) {
......@@ -471,7 +471,7 @@ sub child_finish_hook {
$self->SUPER::child_finish_hook();
$self->log(LOG_INFO,"[SMRADIUS] Shutting down caching engine ($$)");
awitpt::cache::disconnect($self);
AWITPT::Cache::disconnect($self);
return;
}
......@@ -544,7 +544,7 @@ sub process_request {
}
# Setup database handle
awitpt::db::dblayer::setHandle($self->{'client'}->{'dbh'});
AWITPT::DB::DBLayer::setHandle($self->{'client'}->{'dbh'});
# Log line to use with logging
my $logLine = "";
......@@ -1268,7 +1268,7 @@ sub server_exit
$self->log(LOG_DEBUG,"Destroying system modules.");
# Destroy cache
awitpt::cache::Destroy($self);
AWITPT::Cache::Destroy($self);
$self->log(LOG_DEBUG,"System modules destroyed.");
# Parent exit
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment