OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: Check Quota with external program

From: Duane Hill (d.hillyournetplus.com)
Date: Tue Jul 03 2007 - 09:34:30 CDT


On Tue, 3 Jul 2007 at 16:00 +0200, s.felicialpikom.it confabulated:

> mouss ha scritto:
>> Simone Felici wrote:
>>>
>>> Hi again,
>>>
>>> I've write a script in perl that can query the backend and the output of
>>> the script is the using quota.
>>> Now, the 'virtual_mailbox_limit_maps' will point to a sql db where all
>>> quota limits for all mailboxes are set. Then, with
>>> smtpd_recipient_restrictions I'll use this option: check_policy_service
>>> unix:private/mailquota. 'mailquota' will be set up into a master.cf like
>>> this:
>>>
>>> mailquota unix - n n - - spawn
>>> user=nobody argv=/usr/bin/perl /etc/postfix/mailquota.pl
>>>
>>> But how can I pass to /etc/postfix/mailquota.pl the recipient argument?
>>> The syntax to obtain the usage quota is /etc/postfix/mailquota.pl
>>> <recipient-email>.
>>> The output is the used quota of the <recipient-email> in bytes.
>>
>>
>> you need to read the POLICY README document. but you certainly should use
>> the policy server example distributed with postfix source code instead of
>> reinventing the wheel.
>>
>>
>
>
> I've read about the policy and have understood how it works.
> Have someone an example on how collect the attr values sent from postfix to
> the external program?
>
> These:
>
[attributes removed]
>
> I've no idea how to grep these infos into variable to use them into the
> perl-script. The script works, 'cause if I set a static action="DUNNO",
> "REJECT", "OK" or wathever, the answer is accepted from postfix and he accept
> or reject the mails. My last problem is to pass the "send attr recipient =
> barexample.com" to a variable.
>
> A little help?
>
> I'm really new with perl too, btw someting is working ;)

Within the Postfix downloadable distribution there is a greylist policy
that can be used as a starting point:

   ../examples/smtpd-policy/greylist.pl

It is the one I used myself when I first created a policy.

If you are using the sample greylist.pl policy for an example, you don't
need to pass the attributes to any variable. They are already contained
within the variable:

   %attr

The recipient attribute can be accessed within via:

   $attr("recipient"}

Likewise, any of the other attributes can be accessed the same way:

        for the client IP : $attr{"client_address"}
   for the envelop sender : $attr{"sender"}