From python-milter at frederic.jolliton.com Sun Jul 15 14:16:11 2007 From: python-milter at frederic.jolliton.com (=?iso-8859-1?Q?Fr=E9d=E9ric_Jolliton?=) Date: Sun, 15 Jul 2007 20:16:11 +0200 Subject: [Pymilter] [PATCH] Patch to add support for new Milter callbacks Message-ID: <87zm1xilck.fsf@mau.intra.tuxee.net> Hi, I made a patch to add support for the recent callbacks added in Sendmail 8.14.0 to milter. It is NOT backward compatible with older milter library versions (if you apply the patch, it will not compile for sendmail/milter<=8.13) but it shouldn't be too hard to conditionnaly compile new features otherwise. I've not found support planned for them, but I hope I've not duplicated some works. This add support for `data', `unknown' and `negotiate' callbacks, including constants definitions for the new return values (SKIP, NOREPLY and ALL_OPTS) and also constants definitions needed by the negotiate callback. However, this patch doesn't implements all the new features, such as chgfrom, addrcpt_par or macros, because I don't need them at the moment. Since negotiate is called first, it is now the negotiatecallback in the Python module which create the filter instance (instead of connectcallback previously.) An example: to request that the connect callback shouldn't be called, we can use something like: class MyFilter( NullFilter ) : .. def negotiate(self, inputs, outputs): if inputs[1] & Milter.P_NOCONNECT : # Ok, milter can be configured to not call connect callback outputs[1] != Milter.P_NOCONNECT return CONTINUE .. The inputs parameters is a tuple with the (f0,f1,f2,f3) values and outputs parameters is a list which represent the values pointed by (pf0,pf1,pf2,pf3) and must be destructively modified, accordingly to: http://www.mirbsd.org/cman/docs/milter/xxfi_negotiate.html Tested under Linux 2.6/x86-32, Python 2.5, Sendmail 8.14.1, gcc 4.1.2. -- Fr?d?ric Jolliton -------------- next part -------------- A non-text attachment was scrubbed... Name: milter-api-814.patch Type: text/x-patch Size: 11177 bytes Desc: Patch to support new callbacks introduced in Sendmail 8.14 URL: From stuart at bmsi.com Thu Jul 26 11:32:09 2007 From: stuart at bmsi.com (Stuart D. Gathman) Date: Thu, 26 Jul 2007 11:32:09 -0400 (EDT) Subject: [Pymilter] new Milter callbacks and new pymilter version Message-ID: CVS head now builds 3 RPM packages: pymilter, milter, pymilter-spf. pymilter is "just the modules". milter is the bms.py application, and pymilter-spf is an spf-only milter application. The milter application code has been moved to /usr/lib/pymilter, since people don't seem to like having it in /var/log/milter. I am calling it 0.8.8, but may not release it. I want to create a new module for pymilter, I think. I also need to apply the patch for new callbacks (thanks Fr??d??ric!), but want to let the reorganization settle in. -- Stuart D. Gathman Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 "Confutatis maledictis, flammis acribus addictis" - background song for a Microsoft sponsored "Where do you want to go from here?" commercial. From heller at teragram.com Mon Jul 30 14:02:17 2007 From: heller at teragram.com (Chris Heller) Date: Mon, 30 Jul 2007 14:02:17 -0400 Subject: [Pymilter] envrcpt not called after returning ACCEPT Message-ID: <791B7EB4A7981548B75FAE6B00D280B903240176@hammond.teragram.com> I've got a question about the Python Milter behavior. I created a Milter which does whitelist filtering on the RCPT TO value. It is working correctly while I feed it invalid addresses (addresses which return Milter.REJECT from the envrcpt() method), however once I feed it a valid address (address which returns Milter.ACCEPT from the envrcpt() method) the envrcpt() method is no longer called. This allows any invalid addresses to get past the Milter once a single valid address has been accepted. Is there something I can do to change this behavior? Regards, Chris Heller -- _/_/_/_/ Chris Heller Network Systems | _/_/_/ Teragram Corporation e-mail: | _/_/_/ 10 Fawcett St. 2nd Flr. web: http://www.teragram.com | _/_/ Cambridge, Ma 02138 phone: 617.576.6800 x237 ~ fax: 617.576.7227 v From stuart at bmsi.com Mon Jul 30 14:15:23 2007 From: stuart at bmsi.com (Stuart D. Gathman) Date: Mon, 30 Jul 2007 14:15:23 -0400 (EDT) Subject: [Pymilter] envrcpt not called after returning ACCEPT In-Reply-To: <791B7EB4A7981548B75FAE6B00D280B903240176@hammond.teragram.com> Message-ID: On Mon, 30 Jul 2007, Chris Heller wrote: > I've got a question about the Python Milter behavior. > > I created a Milter which does whitelist filtering on the RCPT TO value. > It is working correctly while I feed it invalid addresses (addresses > which return Milter.REJECT from the envrcpt() method), however once I > feed it a valid address (address which returns Milter.ACCEPT from the > envrcpt() method) the envrcpt() method is no longer called. > > This allows any invalid addresses to get past the Milter once a single > valid address has been accepted. > > Is there something I can do to change this behavior? This is actually libmilter behaviour. Returning ACCEPT causes all further callbacks to be skipped. Return CONTINUE to continue with callbacks. In many contexts, returning REJECT also causes all further callbacks to be skipped. Refer to the libmilter API for details. PS: I subscribed you to the list. -- Stuart D. Gathman Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 "Confutatis maledictis, flammis acribus addictis" - background song for a Microsoft sponsored "Where do you want to go from here?" commercial. From heller at teragram.com Mon Jul 30 14:24:31 2007 From: heller at teragram.com (Chris Heller) Date: Mon, 30 Jul 2007 14:24:31 -0400 Subject: [Pymilter] envrcpt not called after returning ACCEPT In-Reply-To: Message-ID: <791B7EB4A7981548B75FAE6B00D280B903240177@hammond.teragram.com> I changed ACCEPT to CONTINUE and now my Milter works. I presume you are referring to connection, or message oriented contexts in which REJECT causes further processing to be skipped, right? In a recipient context REJECT seems to work just as planned. Thanks, Chris -----Original Message----- From: Stuart D. Gathman [mailto:stuart at bmsi.com] Sent: Monday, July 30, 2007 2:15 PM To: Chris Heller Cc: pymilter at bmsi.com Subject: Re: [Pymilter] envrcpt not called after returning ACCEPT On Mon, 30 Jul 2007, Chris Heller wrote: > I've got a question about the Python Milter behavior. > > I created a Milter which does whitelist filtering on the RCPT TO > value. It is working correctly while I feed it invalid addresses > (addresses which return Milter.REJECT from the envrcpt() method), > however once I feed it a valid address (address which returns > Milter.ACCEPT from the > envrcpt() method) the envrcpt() method is no longer called. > > This allows any invalid addresses to get past the Milter once a single > valid address has been accepted. > > Is there something I can do to change this behavior? This is actually libmilter behaviour. Returning ACCEPT causes all further callbacks to be skipped. Return CONTINUE to continue with callbacks. In many contexts, returning REJECT also causes all further callbacks to be skipped. Refer to the libmilter API for details. PS: I subscribed you to the list. -- Stuart D. Gathman Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 "Confutatis maledictis, flammis acribus addictis" - background song for a Microsoft sponsored "Where do you want to go from here?" commercial.