One of the famous problems, if you're building up a corporate email server, might be an email attachment size, that is allowed for your users to send as emails. On newbie's questions on forums most of gurus are pointing to policyd. Obviously, this plugin is more than amazing, works more than perfect and pretty fast as well. But.. It wont control the attachment size. It's plugin "Quotas" is only to control the amount of sent messages and consumed bandwidth, but not to control a single message size.
NOTE: MessageCumulativeSize will never block your first message with attachment, even it's size is exceeding the limits of hundred times! The first message will always go through. Read this: https://www.mail-archive.com/users@lists.policyd.org/msg01962.html
So this is not what I expected. I'd like to have a simple plugin, that BLOCKS the message sending, if it's size is larger, than I would allow. And I came up with this simple path.
Go to /usr/lib64/policyd-2.0/cbp/modules/ or wherever your cbpolicyd files stored and modify Quotas.pm or make a patch like this (name it Quotas.pm.patch):
NOTE: MessageCumulativeSize will never block your first message with attachment, even it's size is exceeding the limits of hundred times! The first message will always go through. Read this: https://www.mail-archive.com/users@lists.policyd.org/msg01962.html
So this is not what I expected. I'd like to have a simple plugin, that BLOCKS the message sending, if it's size is larger, than I would allow. And I came up with this simple path.
Go to /usr/lib64/policyd-2.0/cbp/modules/ or wherever your cbpolicyd files stored and modify Quotas.pm or make a patch like this (name it Quotas.pm.patch):
[root@server modules]# cat Quotas.pm.patch
--- Quotas.pm.orig 2014-07-25 21:01:38.332494503 -0400 +++ Quotas.pm 2014-07-25 22:24:08.297785096 -0400 @@ -101,7 +101,6 @@ # stage # if ($sessionData->{'ProtocolState'} eq "RCPT") { - # Key tracking list, if quotaExceeded is not undef, it will contain the msg my %newCounters; # Indexed by QuotaLimitsID my @trackingList; @@ -414,7 +413,24 @@ if (lc($limit->{'Type'}) eq "messagecumulativesize") { # Bump up counter my $currentCounter = $qtrack->{'Counter'} + $sessionData->{'Size'}; - + +#-------------------------------# Added by SHIRKER + # $server->maillog("DEBUG Quota TESTTTTT START!! Quota=%s MessageSize=%s", + # $limit->{'CounterLimit'}, + # $sessionData->{'Size'}); + + if ($sessionData->{'Size'} > $limit->{'CounterLimit'}){ + # $server->maillog("DEBUG Quota TESTTTTT DONE!! Quota=%s MessageSize=%s" Verdict=%s", + # $limit->{'CounterLimit'}, + # $sessionData->{'Size'}, + # $quota->{'Verdict'}); + + # Set verdict + $verdict = $quota->{'Verdict'}; + } +#-------------------------------# END added by Shirker +# +# # Update database my $sth = DBDo(" UPDATEThen apply it:
patch Quotas.pm < Quotas.pm.patch
No comments:
Post a Comment