Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: exim: users

Embedded perl

 

 

exim users RSS feed   Index | Next | Previous | View Threaded


Klaus+exim at Ethgen

Nov 29, 2011, 7:52 AM

Post #1 of 3 (302 views)
Permalink
Embedded perl

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Hello folks,

I want to implement the relevant part of amavis spamchecking direct in
exim using embedded perl. The solution need to get several parameter
from ldap. So I plan to do the ldap query only once and cache it in a
global variable inside perl.

So my question ist, if it is sure that the same perl process is used for
different queries in the same ACL (or over all ACL?) Or do I have to
take care of mixed calls for different incoming mails in the same
context?

The documentation only mention perl_at_start but this parameter seems to
be somewhat unuseful as it will started several times in several states
of the daemon.

Regards
Klaus
- --
Klaus Ethgen http://www.ethgen.ch/
pub 4096R/4E20AF1C 2011-05-16 Klaus Ethgen <Klaus [at] Ethgen>
Fingerprint: 85D4 CA42 952C 949B 1753 62B3 79D0 B06F 4E20 AF1C
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQGcBAEBCgAGBQJO1P/BAAoJEKZ8CrGAGfasmY4L/AjACTPmlKXaV7hQhyum7mhn
dmOd9mYlP360tettx5OXS1LY3492tVAf3TrDd9xJ8MG5+Vif1SYsUuWorefZDr15
a2pUPsa1sUv9r8CJLL0fI1BE8/BzwqBQXzhEKhethqMc4HOEvIq1FV65tZDykS6p
8yzlnvqnAQlkjp0IHfj1DK+lz/MA+cSEtpEBNM6kb7x5pMiyWhC3SOqEiC4qOhgB
CNEMEhHhEUXIy1CJrYmAk20BwooH6RW80RWjmr0V4vzDVg7Rf8EofZzd7a4D1OO0
F0MKh0bp/5xJI97GJPNlfVqAtIIMVAGueDNqGCPZQbwF3IKbXKfw5tjt8fduOZsQ
xb4BqGxHNNKPdm7lS6pT9M1Lp4hf4MzJjOe9veBgEE2QHndWCGyxKLX3cnoiaNHU
BoRDPkNLL1IFvSN2zbgptMZN27RfkoDVUY22+Z4fQMzFLt4vaaD8/g6cFqQQu8bJ
1/9+OMymQKM/HPfv1uW+qeHetuRPngyJCqBytP6cJg==
=ozNU
-----END PGP SIGNATURE-----

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


hs at schlittermann

Nov 29, 2011, 12:33 PM

Post #2 of 3 (299 views)
Permalink
Re: Embedded perl [In reply to]

Hello Klaus,

please read the following statements only as guesswork, I didn't check
it with the source, it is just my understanding about what's going on
behind the scenes…

Klaus Ethgen <Klaus+exim [at] Ethgen> (Di 29 Nov 2011 16:52:34 CET):

> So my question ist, if it is sure that the same perl process is used for
> different queries in the same ACL (or over all ACL?) Or do I have to
> take care of mixed calls for different incoming mails in the same
> context?

A new process is used for every new connection. This new process should
be a fork(2) of the listener and this new process will evaluate the
ACL. This process will spool the message into the incoming/ directory
(if it passed the ACL) and this process then exec(2)s a fresh delivery
process.

Nobody can guarantee the number of messages the client will send you
down this single connection. But for *every* single message
the acl_smtp_mail needs to be passed first. And the acl_smtp_data needs
to be passed last. So you can use one of these acl to setup or clean
your cache.

> The documentation only mention perl_at_start but this parameter seems to
> be somewhat unuseful as it will started several times in several states
> of the daemon.

Normally the perl_start evaluation is delayed until the first perl
expansion is about to take place. If the code you execute in perl_start
needs the privileges, exim has at startup only, you need the
perl_at_start option.

--
Heiko
Attachments: signature.asc (0.19 KB)


Martin.Schuster1 at infineon

Nov 30, 2011, 12:30 AM

Post #3 of 3 (283 views)
Permalink
Re: Embedded perl [In reply to]

On 11/29/2011 04:52 PM, Klaus Ethgen wrote:
> Hello folks,
>
Servus Klaus,

> I want to implement the relevant part of amavis spamchecking direct in
> exim using embedded perl. The solution need to get several parameter
> from ldap. So I plan to do the ldap query only once and cache it in a
> global variable inside perl.
>
You could use Shared Memory for the cache. (you will need to
cpan -i IPC::Cache
on the server though...)

code-snippet:


use IPC::Cache;
# init shared cache
my $cache = new IPC::Cache( { namespace => 'exim', expires_in => 3600 } );

# allow forced flush via commandline
if ($#ARGV == 0 && $ARGV[0] eq '--clear') {
$cache->clear;
exit;
}

# Try to use the info from cache
my $bycache = $cache->get($user);
if (defined $bycache) {
return $bycache;
}

# Otherwise do all the LDAP stuff
my $mail = ldap_lookup($user);
# and put it into the cache
$cache->set($user, $mail);
return $mail;


hth,
--
Infineon Technologies IT-Services GmbH Martin.Schuster1 [at] infineon
Lakeside B05, 9020 Klagenfurt, Austria Martin Schuster
FB: LG Klagenfurt, FN 246787y +43 5 1777 3517
Attachments: smime.p7s (4.01 KB)

exim users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.