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

* Fixed case issue with some database column names as this could cause some queries to fail

parent 02f502fc
......@@ -104,14 +104,14 @@ sub check {
$server->log(LOG_ERR,"Database query failed: ".awitpt::db::dblayer::Error());
return $server->protocol_response(PROTO_DB_ERROR);
}
my $row = $sth->fetchrow_hashref();
my $row = hashifyLCtoMC($sth->fetchrow_hashref(), qw( Verdict Data ));
DBFreeRes($sth);
# If no result, next
next if (!$row);
# Setup result
if (!defined($row->{'verdict'})) {
if (!defined($row->{'Verdict'})) {
$server->maillog("module=AccessControl, action=none, host=%s, helo=%s, from=%s, to=%s, reason=no_verdict",
$sessionData->{'ClientAddress'},
$sessionData->{'Helo'},
......@@ -119,64 +119,64 @@ sub check {
$sessionData->{'Recipient'});
next; # No verdict
} elsif ($row->{'verdict'} =~ /^hold$/i) {
} elsif ($row->{'Verdict'} =~ /^hold$/i) {
$server->maillog("module=AccessControl, action=hold, host=%s, helo=%s, from=%s, to=%s, reason=verdict",
$sessionData->{'ClientAddress'},
$sessionData->{'Helo'},
$sessionData->{'Sender'},
$sessionData->{'Recipient'});
return $server->protocol_response(PROTO_HOLD,$row->{'data'});
return $server->protocol_response(PROTO_HOLD,$row->{'Data'});
} elsif ($row->{'verdict'} =~ /^reject$/i) {
} elsif ($row->{'Verdict'} =~ /^reject$/i) {
$server->maillog("module=AccessControl, action=reject, host=%s, helo=%s, from=%s, to=%s, reason=verdict",
$sessionData->{'ClientAddress'},
$sessionData->{'Helo'},
$sessionData->{'Sender'},
$sessionData->{'Recipient'});
return $server->protocol_response(PROTO_REJECT,$row->{'data'});
return $server->protocol_response(PROTO_REJECT,$row->{'Data'});
} elsif ($row->{'verdict'} =~ /^discard$/i) {
} elsif ($row->{'Verdict'} =~ /^discard$/i) {
$server->maillog("module=AccessControl, action=discard, host=%s, helo=%s, from=%s, to=%s, reason=verdict",
$sessionData->{'ClientAddress'},
$sessionData->{'Helo'},
$sessionData->{'Sender'},
$sessionData->{'Recipient'});
return $server->protocol_response(PROTO_DISCARD,$row->{'data'});
return $server->protocol_response(PROTO_DISCARD,$row->{'Data'});
} elsif ($row->{'verdict'} =~ /^filter$/i) {
} elsif ($row->{'Verdict'} =~ /^filter$/i) {
$server->maillog("module=AccessControl, action=filter, host=%s, helo=%s, from=%s, to=%s, reason=verdict",
$sessionData->{'ClientAddress'},
$sessionData->{'Helo'},
$sessionData->{'Sender'},
$sessionData->{'Recipient'});
return $server->protocol_response(PROTO_FILTER,$row->{'data'});
return $server->protocol_response(PROTO_FILTER,$row->{'Data'});
} elsif ($row->{'verdict'} =~ /^redirect$/i) {
} elsif ($row->{'Verdict'} =~ /^redirect$/i) {
$server->maillog("module=AccessControl, action=redirect, host=%s, helo=%s, from=%s, to=%s, reason=verdict",
$sessionData->{'ClientAddress'},
$sessionData->{'Helo'},
$sessionData->{'Sender'},
$sessionData->{'Recipient'});
return $server->protocol_response(PROTO_REDIRECT,$row->{'data'});
return $server->protocol_response(PROTO_REDIRECT,$row->{'Data'});
} elsif ($row->{'verdict'} =~ /^ok$/i) {
} elsif ($row->{'Verdict'} =~ /^ok$/i) {
$server->maillog("module=AccessControl, action=ok, host=%s, helo=%s, from=%s, to=%s, reason=verdict",
$sessionData->{'ClientAddress'},
$sessionData->{'Helo'},
$sessionData->{'Sender'},
$sessionData->{'Recipient'});
return $server->protocol_response(PROTO_OK,$row->{'data'});
return $server->protocol_response(PROTO_OK,$row->{'Data'});
} elsif ($row->{'verdict'} =~ /^pass$/i) {
} elsif ($row->{'Verdict'} =~ /^pass$/i) {
$server->maillog("module=AccessControl, action=pass, host=%s, helo=%s, from=%s, to=%s, reason=verdict",
$sessionData->{'ClientAddress'},
$sessionData->{'Helo'},
$sessionData->{'Sender'},
$sessionData->{'Recipient'});
return $server->protocol_response(PROTO_PASS,$row->{'data'});
return $server->protocol_response(PROTO_PASS,$row->{'Data'});
} else {
$server->log(LOG_ERR,"[ACCESSCONTROL] Unknown Verdict specification in access control '".$row->{'verdict'}."'");
$server->log(LOG_ERR,"[ACCESSCONTROL] Unknown Verdict specification in access control '".$row->{'Verdict'}."'");
$server->maillog("module=AccessControl, action=none, host=%s, helo=%s, from=%s, to=%s, reason=invalid_verdict",
$sessionData->{'ClientAddress'},
$sessionData->{'Helo'},
......
......@@ -631,8 +631,11 @@ sub getAccountings
$server->log(LOG_ERR,"Failed to get accounting data: ".awitpt::db::dblayer::Error());
return -1;
}
while (my $quota = $sth->fetchrow_hashref()) {
push(@res,hashifyLCtoMC($quota,qw(ID Track AccountingPeriod MessageCountLimit MessageCumulativeSizeLimit Verdict Data LastAccounting)));
while (my $quota = hashifyLCtoMC($sth->fetchrow_hashref(),
qw( ID Track AccountingPeriod MessageCountLimit MessageCumulativeSizeLimit Verdict Data LastAccounting )
)) {
push(@res, $quota);
}
return \@res;
......@@ -776,10 +779,12 @@ sub getTrackingInfo
$server->log(LOG_ERR,"[ACCOUNTING] Failed to query accounting_tracking: ".awitpt::db::dblayer::Error());
return -1;
}
my $row = $sth->fetchrow_hashref();
my $row = hashifyLCtoMC($sth->fetchrow_hashref(),
qw( AccountingID TrackKey PeriodKey MessageCount MessageCumulativeSize )
);
DBFreeRes($sth);
return hashifyLCtoMC($row,qw(AccountingID TrackKey PeriodKey MessageCount MessageCumulativeSize));
return $row;
}
......
......@@ -114,35 +114,37 @@ sub check {
$server->log(LOG_ERR,"[CHECKHELO] Database query failed: ".awitpt::db::dblayer::Error());
return $server->protocol_response(PROTO_DB_ERROR);
}
while (my $row = $sth->fetchrow_hashref()) {
while (my $row = hashifyLCtoMC($sth->fetchrow_hashref(),
qw( UseBlacklist BlacklistPeriod UseHRP HRPPeriod HRPLimit RejectInvalid RejectIP RejectUnresolvable )
)) {
$policy{'Identifier'} .= ":$policyID";
# If defined, its to override
if (defined($row->{'useblacklist'})) {
$policy{'UseBlacklist'} = $row->{'useblacklist'};
if (defined($row->{'UseBlacklist'})) {
$policy{'UseBlacklist'} = $row->{'UseBlacklist'};
}
if (defined($row->{'blacklistperiod'})) {
$policy{'BlacklistPeriod'} = $row->{'blacklistperiod'};
if (defined($row->{'BlacklistPeriod'})) {
$policy{'BlacklistPeriod'} = $row->{'BlacklistPeriod'};
}
if (defined($row->{'usehrp'})) {
$policy{'UseHRP'} = $row->{'usehrp'};
if (defined($row->{'UseHRP'})) {
$policy{'UseHRP'} = $row->{'UseHRP'};
}
if (defined($row->{'hrpperiod'})) {
$policy{'HRPPeriod'} = $row->{'hrpperiod'};
if (defined($row->{'HRPPeriod'})) {
$policy{'HRPPeriod'} = $row->{'HRPPeriod'};
}
if (defined($row->{'hrplimit'})) {
$policy{'HRPLimit'} = $row->{'hrplimit'};
if (defined($row->{'HRPLimit'})) {
$policy{'HRPLimit'} = $row->{'HRPLimit'};
}
if (defined($row->{'rejectinvalid'})) {
$policy{'RejectInvalid'} = $row->{'rejectinvalid'};
if (defined($row->{'RejectInvalid'})) {
$policy{'RejectInvalid'} = $row->{'RejectInvalid'};
}
if (defined($row->{'rejectip'})) {
$policy{'RejectIP'} = $row->{'rejectip'};
if (defined($row->{'RejectIP'})) {
$policy{'RejectIP'} = $row->{'RejectIP'};
}
if (defined($row->{'rejectunresolvable'})) {
$policy{'RejectUnresolvable'} = $row->{'rejectunresolvable'};
if (defined($row->{'RejectUnresolvable'})) {
$policy{'RejectUnresolvable'} = $row->{'RejectUnresolvable'};
}
} # while (my $row = $sth->fetchrow_hashref())
} # foreach my $policyID (@{$sessionData->{'Policy'}->{$priority}})
......@@ -558,13 +560,13 @@ sub cleanup
$server->log(LOG_ERR,"[CHECKHELO] Failed to query maximum periods: ".awitpt::db::dblayer::Error());
return -1;
}
my $row = $sth->fetchrow_hashref();
my $row = hashifyLCtoMC($sth->fetchrow_hashref(), qw( BlacklistPeriod HRPPeriod ));
# Check we have results
return if (!defined($row->{'blacklistperiod'}) || !defined($row->{'hrpperiod'}));
return if (!defined($row->{'BlacklistPeriod'}) || !defined($row->{'HRPPeriod'}));
# Work out which one is largest
my $period = $row->{'blacklistperiod'} > $row->{'hrpperiod'} ? $row->{'blacklistperiod'} : $row->{'hrpperiod'};
my $period = $row->{'BlacklistPeriod'} > $row->{'HRPPeriod'} ? $row->{'BlacklistPeriod'} : $row->{'HRPPeriod'};
# Bork if we didn't find anything of interest
return if (!($period > 0));
......@@ -614,9 +616,9 @@ sub getHRPCount
return;
}
my $row = $sth->fetchrow_hashref();
my $row = hashifyLCtoMC($sth->fetchrow_hashref(), qw( Count ));
return $row->{'count'};
return $row->{'Count'};
}
......@@ -654,16 +656,16 @@ sub getBlacklistCount
$server->log(LOG_ERR,"Database query failed: ".awitpt::db::dblayer::Error());
return $server->protocol_response(PROTO_DB_ERROR);
}
my $row = $sth->fetchrow_hashref();
my $row = hashifyLCtoMC($sth->fetchrow_hashref(), qw( Count ));
# Cache this
$cache_res = cacheStoreKeyPair('CheckHelo/Blacklist',$clientAddress,$row->{'count'});
$cache_res = cacheStoreKeyPair('CheckHelo/Blacklist',$clientAddress,$row->{'Count'});
if ($cache_res) {
$server->log(LOG_ERR,"[CHECKHELO] Blacklist cache store failed: ".awitpt::cache::Error());
return;
}
return $row->{'count'};
return $row->{'Count'};
}
......@@ -698,8 +700,8 @@ sub getWhitelist
}
# Loop with whitelist and calculate
my @sources;
while (my $row = $sth->fetchrow_hashref()) {
push(@sources,$row->{'source'});
while (my $row = hashifyLCtoMC($sth->fetchrow_hashref(), qw( Source ))) {
push(@sources,$row->{'Source'});
}
# Cache this
......
......@@ -114,18 +114,21 @@ sub check {
$server->log(LOG_ERR,"[CHECKSPF] Database query failed: ".awitpt::db::dblayer::Error());
return $server->protocol_response(PROTO_DB_ERROR);
}
while (my $row = $sth->fetchrow_hashref()) {
while (my $row = hashifyLCtoMC($sth->fetchrow_hashref(),
qw( UseSPF RejectFailedSPF AddSPFHeader )
)) {
# If defined, its to override
if (defined($row->{'usespf'})) {
$policy{'UseSPF'} = $row->{'usespf'};
if (defined($row->{'UseSPF'})) {
$policy{'UseSPF'} = $row->{'UseSPF'};
}
# If defined, its to override
if (defined($row->{'rejectfailedspf'})) {
$policy{'RejectFailedSPF'} = $row->{'rejectfailedspf'};
if (defined($row->{'RejectFailedSPF'})) {
$policy{'RejectFailedSPF'} = $row->{'RejectFailedSPF'};
}
# If defined, its to override
if (defined($row->{'addspfheader'})) {
$policy{'AddSPFHeader'} = $row->{'addspfheader'};
if (defined($row->{'AddSPFHeader'})) {
$policy{'AddSPFHeader'} = $row->{'AddSPFHeader'};
}
} # while (my $row = $sth->fetchrow_hashref())
} # foreach my $policyID (@{$sessionData->{'Policy'}->{$priority}})
......
......@@ -131,50 +131,58 @@ sub check {
return $server->protocol_response(PROTO_DB_ERROR);
}
# Loop with rows and build end policy
while (my $row = $sth->fetchrow_hashref()) {
while (my $row = hashifyLCtoMC($sth->fetchrow_hashref(),
qw(
UseGreylisting GreylistPeriod Track GreylistAuthValidity
GreylistUnAuthValidity UseAutoWhitelist AutoWhitelistPeriod
AutoWhitelistCount AutoWhitelistPercentage UseAutoBlacklist
AutoBlacklistPeriod AutoBlacklistCount AutoBlacklistPercentage
)
)) {
$policy{'Identifier'} .= ":$policyID";
# If defined, its to override
if (defined($row->{'usegreylisting'})) {
$policy{'UseGreylisting'} = $row->{'usegreylisting'};
if (defined($row->{'UseGreylisting'})) {
$policy{'UseGreylisting'} = $row->{'UseGreylisting'};
}
if (defined($row->{'greylistperiod'})) {
$policy{'GreylistPeriod'} = $row->{'greylistperiod'};
if (defined($row->{'GreylistPeriod'})) {
$policy{'GreylistPeriod'} = $row->{'GreylistPeriod'};
}
if (defined($row->{'track'})) {
$policy{'Track'} = $row->{'track'};
if (defined($row->{'Track'})) {
$policy{'Track'} = $row->{'Track'};
}
if (defined($row->{'greylistauthvalidity'})) {
$policy{'GreylistAuthValidity'} = $row->{'greylistauthvalidity'};
if (defined($row->{'GreylistAuthValidity'})) {
$policy{'GreylistAuthValidity'} = $row->{'GreylistAuthValidity'};
}
if (defined($row->{'greylistunauthvalidity'})) {
$policy{'GreylistUnAuthValidity'} = $row->{'greylistunauthvalidity'};
if (defined($row->{'GreylistUnAuthValidity'})) {
$policy{'GreylistUnAuthValidity'} = $row->{'GreylistUnAuthValidity'};
}
if (defined($row->{'useautowhitelist'})) {
$policy{'UseAutoWhitelist'} = $row->{'useautowhitelist'};
if (defined($row->{'UseAutoWhitelist'})) {
$policy{'UseAutoWhitelist'} = $row->{'UseAutoWhitelist'};
}
if (defined($row->{'autowhitelistperiod'})) {
$policy{'AutoWhitelistPeriod'} = $row->{'autowhitelistperiod'};
if (defined($row->{'AutoWhitelistPeriod'})) {
$policy{'AutoWhitelistPeriod'} = $row->{'AutoWhitelistPeriod'};
}
if (defined($row->{'autowhitelistcount'})) {
$policy{'AutoWhitelistCount'} = $row->{'autowhitelistcount'};
if (defined($row->{'AutoWhitelistCount'})) {
$policy{'AutoWhitelistCount'} = $row->{'AutoWhitelistCount'};
}
if (defined($row->{'autowhitelistpercentage'})) {
$policy{'AutoWhitelistPercentage'} = $row->{'autowhitelistpercentage'};
if (defined($row->{'AutoWhitelistPercentage'})) {
$policy{'AutoWhitelistPercentage'} = $row->{'AutoWhitelistPercentage'};
}
if (defined($row->{'useautoblacklist'})) {
$policy{'UseAutoBlacklist'} = $row->{'useautoblacklist'};
if (defined($row->{'UseAutoBlacklist'})) {
$policy{'UseAutoBlacklist'} = $row->{'UseAutoBlacklist'};
}
if (defined($row->{'autoblacklistperiod'})) {
$policy{'AutoBlacklistPeriod'} = $row->{'autoblacklistperiod'};
if (defined($row->{'AutoBlacklistPeriod'})) {
$policy{'AutoBlacklistPeriod'} = $row->{'AutoBlacklistPeriod'};
}
if (defined($row->{'autoblacklistcount'})) {
$policy{'AutoBlacklistCount'} = $row->{'autoblacklistcount'};
if (defined($row->{'AutoBlacklistCount'})) {
$policy{'AutoBlacklistCount'} = $row->{'AutoBlacklistCount'};
}
if (defined($row->{'autoblacklistpercentage'})) {
$policy{'AutoBlacklistPercentage'} = $row->{'autoblacklistpercentage'};
if (defined($row->{'AutoBlacklistPercentage'})) {
$policy{'AutoBlacklistPercentage'} = $row->{'AutoBlacklistPercentage'};
}
} # while (my $row = $sth->fetchrow_hashref())
......@@ -209,10 +217,10 @@ sub check {
return $server->protocol_response(PROTO_DB_ERROR);
}
# Loop with whitelist and calculate
while (my $row = $sth->fetchrow_hashref()) {
while (my $row = hashifyLCtoMC($sth->fetchrow_hashref(), qw( Source ))) {
# Check format is SenderIP
if ((my $raw_waddress = $row->{'source'}) =~ s/^SenderIP://i) {
if ((my $raw_waddress = $row->{'Source'}) =~ s/^SenderIP://i) {
# Create our IP object
my $waddress = new awitpt::netip($raw_waddress);
......@@ -232,7 +240,7 @@ sub check {
}
} else {
$server->log(LOG_WARN,"[GREYLISTING] Skipping invalid whitelist entry '".$row->{'source'}."'.");
$server->log(LOG_WARN,"[GREYLISTING] Skipping invalid whitelist entry '".$row->{'Source'}."'.");
}
}
DBFreeRes($sth);
......@@ -272,13 +280,13 @@ sub check {
$server->log(LOG_ERR,"[GREYLISTING] Database query failed: ".awitpt::db::dblayer::Error());
return $server->protocol_response(PROTO_DB_ERROR);
}
my $row = $sth->fetchrow_hashref();
my $row = hashifyLCtoMC($sth->fetchrow_hashref(), qw( ID LastSeen ));
# Pull off first row
if ($row) {
# Check if we're within the auto-whitelisting period
if ($sessionData->{'UnixTimestamp'} - $row->{'lastseen'} <= $policy{'AutoWhitelistPeriod'}) {
if ($sessionData->{'UnixTimestamp'} - $row->{'LastSeen'} <= $policy{'AutoWhitelistPeriod'}) {
my $sth = DBDo('
UPDATE
......@@ -355,13 +363,13 @@ sub check {
$server->log(LOG_ERR,"[GREYLISTING] Database query failed: ".awitpt::db::dblayer::Error());
return $server->protocol_response(PROTO_DB_ERROR);
}
my $row = $sth->fetchrow_hashref();
my $row = hashifyLCtoMC($sth->fetchrow_hashref(), qw( ID Added ));
# Pull off first row
if ($row) {
# Check if we're within the auto-blacklisting period
if ($sessionData->{'UnixTimestamp'} - $row->{'added'} <= $policy{'AutoBlacklistPeriod'}) {
if ($sessionData->{'UnixTimestamp'} - $row->{'Added'} <= $policy{'AutoBlacklistPeriod'}) {
# Cache positive result
my $cache_res = cacheStoreKeyPair(
'Greylisting/Auto-Blacklist/PolicyIdentifier-Blacklisted-IP',
......@@ -445,8 +453,8 @@ sub check {
$server->log(LOG_ERR,"[GREYLISTING] Database query failed: ".awitpt::db::dblayer::Error());
return $server->protocol_response(PROTO_DB_ERROR);
}
my $row = $sth->fetchrow_hashref();
my $totalCount = defined($row->{'totalcount'}) ? $row->{'totalcount'} : 0;
my $row = hashifyLCtoMC($sth->fetchrow_hashref(), qw( TotalCount ));
my $totalCount = defined($row->{'TotalCount'}) ? $row->{'TotalCount'} : 0;
# If count exceeds or equals blacklist count, nail the server
......@@ -470,8 +478,8 @@ sub check {
$server->log(LOG_ERR,"[GREYLISTING] Database query failed: ".awitpt::db::dblayer::Error());
return $server->protocol_response(PROTO_DB_ERROR);
}
$row = $sth->fetchrow_hashref();
my $failCount = defined($row->{'failcount'}) ? $row->{'failcount'} : 0;
$row = hashifyLCtoMC($sth->fetchrow_hashref(), qw( FailCount ));
my $failCount = defined($row->{'FailCount'}) ? $row->{'FailCount'} : 0;
# Check if we should blacklist this host
if (defined($policy{'AutoBlacklistPercentage'}) && $policy{'AutoBlacklistPercentage'} > 0) {
......@@ -601,8 +609,7 @@ sub check {
SELECT
FirstSeen,
LastUpdate,
Tries,
Count
Tries
FROM
@TP@greylisting_tracking
......@@ -618,14 +625,14 @@ sub check {
$server->log(LOG_ERR,"[GREYLISTING] Database query failed: ".awitpt::db::dblayer::Error());
return $server->protocol_response(PROTO_DB_ERROR);
}
my $row = $sth->fetchrow_hashref();
my $row = hashifyLCtoMC($sth->fetchrow_hashref(), qw( FirstSeen LastUpdate Tries ));
if (!$row) {
$server->log(LOG_ERR,"[GREYLISTING] Failed to find triplet in database");
return $server->protocol_response(PROTO_DB_ERROR);
}
# Check if we should greylist, or not
my $timeElapsed = $row->{'lastupdate'} - $row->{'firstseen'};
my $timeElapsed = $row->{'LastUpdate'} - $row->{'FirstSeen'};
if (!$config{'training_mode'} && $timeElapsed < $policy{'GreylistPeriod'}) {
# Get time left, debug and return
my $timeLeft = $policy{'GreylistPeriod'} - $timeElapsed;
......@@ -634,7 +641,7 @@ sub check {
$sessionData->{'Helo'},
$sessionData->{'Sender'},
$sessionData->{'Recipient'},
$row->{'tries'} + 1);
$row->{'Tries'} + 1);
# Update stats
my $sth = DBDo('
......@@ -702,8 +709,8 @@ sub check {
$server->log(LOG_ERR,"[GREYLISTING] Database query failed: ".awitpt::db::dblayer::Error());
return $server->protocol_response(PROTO_DB_ERROR);
}
my $row = $sth->fetchrow_hashref();
my $totalCount = defined($row->{'totalcount'}) ? $row->{'totalcount'} : 0;
my $row = hashifyLCtoMC($sth->fetchrow_hashref(), qw( TotalCount ));
my $totalCount = defined($row->{'TotalCount'}) ? $row->{'TotalCount'} : 0;
# If count exceeds or equals whitelist count, nail the server
if ($totalCount >= $policy{'AutoWhitelistCount'}) {
......@@ -725,8 +732,8 @@ sub check {
$server->log(LOG_ERR,"[GREYLISTING] Database query failed: ".awitpt::db::dblayer::Error());
return $server->protocol_response(PROTO_DB_ERROR);
}
$row = $sth->fetchrow_hashref();
my $passCount = defined($row->{'passcount'}) ? $row->{'passcount'} : 0;
$row = hashifyLCtoMC($sth->fetchrow_hashref(), qw( PassCount ));
my $passCount = defined($row->{'PassCount'}) ? $row->{'PassCount'} : 0;
# Check if we should whitelist this host
if (defined($policy{'AutoWhitelistPercentage'}) && $policy{'AutoWhitelistPercentage'} > 0) {
......@@ -883,11 +890,11 @@ sub cleanup
$server->log(LOG_ERR,"[GREYLISTING] Failed to query AutoWhitelistPeriod: ".awitpt::db::dblayer::Error());
return -1;
}
my $row = $sth->fetchrow_hashref();
my $row = hashifyLCtoMC($sth->fetchrow_hashref(), qw( Period ));
# Check if we have something...
my $AWLPeriod;
if (($AWLPeriod = $row->{'period'}) && $AWLPeriod > 0) {
if (($AWLPeriod = $row->{'Period'}) && $AWLPeriod > 0) {
# Get start time
$AWLPeriod = $now - $AWLPeriod;
......@@ -923,11 +930,11 @@ sub cleanup
$server->log(LOG_ERR,"[GREYLISTING] Failed to query AutoBlacklistPeriod: ".awitpt::db::dblayer::Error());
return -1;
}
$row = $sth->fetchrow_hashref();
$row = hashifyLCtoMC($sth->fetchrow_hashref(), qw( Period ));
# Check if we have something...
my $ABLPeriod;
if (($ABLPeriod = $row->{'period'}) && $ABLPeriod > 0) {
if (($ABLPeriod = $row->{'Period'}) && $ABLPeriod > 0) {
# Get start time
$ABLPeriod = $now - $ABLPeriod;
......@@ -962,11 +969,11 @@ sub cleanup
$server->log(LOG_ERR,"[GREYLISTING] Failed to query GreylistAuthValidity: ".awitpt::db::dblayer::Error());
return -1;
}
$row = $sth->fetchrow_hashref();
$row = hashifyLCtoMC($sth->fetchrow_hashref(), qw( Period ));
# Check if we have something...
my $AuthPeriod;
if (($AuthPeriod = $row->{'period'}) && $AuthPeriod > 0) {
if (($AuthPeriod = $row->{'Period'}) && $AuthPeriod > 0) {
# Get start time
$AuthPeriod = $now - $AuthPeriod;
......@@ -1002,11 +1009,11 @@ sub cleanup
$server->log(LOG_ERR,"[GREYLISTING] Failed to query GreylistUnAuthValidity: ".awitpt::db::dblayer::Error());
return -1;
}
$row = $sth->fetchrow_hashref();
$row = hashifyLCtoMC($sth->fetchrow_hashref(), qw( Period ));
# Check if we have something...
my $UnAuthPeriod;
if (($UnAuthPeriod = $row->{'period'}) && $UnAuthPeriod > 0) {
if (($UnAuthPeriod = $row->{'Period'}) && $UnAuthPeriod > 0) {
# Get start time
$UnAuthPeriod = $now - $UnAuthPeriod;
......
......@@ -568,8 +568,11 @@ sub getQuotas
$server->log(LOG_ERR,"Failed to get quota data: ".awitpt::db::dblayer::Error());
return -1;
}
while (my $quota = $sth->fetchrow_hashref()) {
push(@res,hashifyLCtoMC($quota,qw(ID Period Track Verdict Data LastQuota)));
while (my $quota = hashifyLCtoMC($sth->fetchrow_hashref(),
qw( ID Period Track Verdict Data LastQuota )
)) {
push(@res, $quota);
}
return \@res;
......@@ -681,10 +684,10 @@ sub getTrackingInfo
$server->log(LOG_ERR,"[QUOTAS] Failed to query quotas_tracking: ".awitpt::db::dblayer::Error());
return -1;
}
my $row = $sth->fetchrow_hashref();
my $row = hashifyLCtoMC($sth->fetchrow_hashref(), qw( QuotasLimitsID TrackKey Counter LastUpdate ));
DBFreeRes($sth);
return hashifyLCtoMC($row,qw(QuotasLimitsID TrackKey Counter LastUpdate));
return $row;
}
......@@ -711,8 +714,8 @@ sub getLimits
return -1;
}
my $list = [];
while (my $qtrack = $sth->fetchrow_hashref()) {
push(@{$list},hashifyLCtoMC($qtrack,qw(ID Type CounterLimit)));
while (my $qtrack = hashifyLCtoMC($sth->fetchrow_hashref(), qw( ID Type CounterLimit ))) {
push(@{$list}, $qtrack);
}
return $list;
......
......@@ -232,15 +232,18 @@ sub getPolicyMembers
# Loop with results
my @policyMembers;
while (my $row = $sth->fetchrow_hashref()) {
while (my $row = hashifyLCtoMC($sth->fetchrow_hashref(),
qw( Name Priority PolicyDisabled ID PolicyID Source Destination MemberDisabled )
)) {
# Log what we see
if ($row->{'policydisabled'} eq "1") {
$server->log(LOG_DEBUG,"[POLICIES] Policy '".$row->{'name'}."' is disabled") if ($log);
} elsif ($row->{'memberdisabled'} eq "1") {
$server->log(LOG_DEBUG,"[POLICIES] Policy member item with ID '".$row->{'id'}."' is disabled") if ($log);
if ($row->{'PolicyDisabled'} eq "1") {