Commit e6e98822 authored by Robert Anderson's avatar Robert Anderson
Browse files

Use size values as kbyte instead of byte

Convert bytes to kbytes on a new request
Updated UPGRADING file with details on how to modify the database to accommodate the changes to policyd

NOTE: This commit will change the behaviour of message size counters used in policyd!

The following changes will need to be made to your database:

UPDATE quotas_limits, quotas_tracking
               SET quotas_limits.CounterLimit = ceil(quotas_limits.CounterLimit / 1024),
               quotas_tracking.Counter = ceil(quotas_tracking.Counter / 1024)
               WHERE quotas_tracking.QuotasLimitsID = quotas_limits.ID
               AND quotas_limits.Type = "MessageCumulativeSize";

UPDATE session_tracking        SET Size = ceil(Size / 1024);
parent 21ef1a80
Updating database for 7ad3d831d7862d95d59a72ed19764264cc77c4b7
--------------------------------------------------------------
UPDATE quotas_limits, quotas_tracking
SET quotas_limits.CounterLimit = ceil(quotas_limits.CounterLimit / 1024),
quotas_tracking.Counter = ceil(quotas_tracking.Counter / 1024)
WHERE quotas_tracking.QuotasLimitsID = quotas_limits.ID
AND quotas_limits.Type = "MessageCumulativeSize";
UPDATE session_tracking SET Size = ceil(Size / 1024);
......@@ -37,6 +37,7 @@ use cbp::dblayer;
use cbp::logging;
use cbp::policies;
use cbp::system qw(parseCIDR);
use POSIX qw( ceil );
use Data::Dumper;
......@@ -138,6 +139,12 @@ sub getSessionDataFromRequest
return -1;
}
# Change size to kbyte, we don't want to use bytes
my $requestSize;
if (defined($request->{'size'})) {
$requestSize = ceil($request->{'size'} / 1024);
}
my $row = $sth->fetchrow_hashref();
# If no state information, create everything we need
......@@ -176,7 +183,7 @@ sub getSessionDataFromRequest
".DBQuote($request->{'sasl_username'}).",
".DBQuote($request->{'helo_name'}).",
".DBQuote($request->{'sender'}).",
".DBQuote($request->{'size'})."
".DBQuote($requestSize)."
)
");
if (!$sth) {
......@@ -203,7 +210,7 @@ sub getSessionDataFromRequest
$sessionData->{'SASLUsername'} = $request->{'sasl_username'};
$sessionData->{'Helo'} = $request->{'helo_name'};
$sessionData->{'Sender'} = $request->{'sender'};
$sessionData->{'Size'} = $request->{'size'};
$sessionData->{'Size'} = $requestSize;
$sessionData->{'RecipientData'} = "";
}
......@@ -232,7 +239,7 @@ sub getSessionDataFromRequest
$server->log(LOG_DEBUG,"[TRACKING] Decoded into: ".Dumper($sessionData->{'_Recipient_To_Policy'})) if ($log);
# This must be updated here ... we may of got actual size
$sessionData->{'Size'} = $request->{'size'};
$sessionData->{'Size'} = $requestSize;
# Only get a queue id once we have gotten the message
$sessionData->{'QueueID'} = $request->{'queue_id'};
}
......
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