From 23c23b1ea1d4fc11b69a30bb8aa20e31324414ce Mon Sep 17 00:00:00 2001 From: Ion-Mihai Tetcu Date: Tue, 16 Jan 2007 10:28:15 +0000 Subject: [PATCH] - update to 0.16 - don't delete user-modified .conf file on deinstall - OPTIONify PR: ports/107651 Submitted by: Milan Obuch (maintainer) --- mail/courier-pythonfilter/Makefile | 77 +++++++++++++++++-- mail/courier-pythonfilter/distinfo | 6 +- .../files/patch-courier__config.py | 45 +++++++++++ .../files/patch-filters__TtlDb.py | 11 +++ .../files/patch-filters__clamav.py | 18 +++++ .../files/patch-filters__comeagain.py | 34 +++++--- .../files/patch-filters__dialback.py | 11 --- .../files/patch-filters__greylist.py | 11 +++ .../files/patch-pythonfilter | 34 ++++++++ .../files/patch-pythonfilter.conf | 13 ---- .../files/patch-pythonfilter.conf.sample | 24 ++++++ .../courier-pythonfilter/files/patch-setup.py | 2 +- .../files/patch-whitelist_auth.py | 26 ------- mail/courier-pythonfilter/pkg-plist | 15 +++- 14 files changed, 256 insertions(+), 71 deletions(-) create mode 100644 mail/courier-pythonfilter/files/patch-courier__config.py create mode 100644 mail/courier-pythonfilter/files/patch-filters__TtlDb.py create mode 100644 mail/courier-pythonfilter/files/patch-filters__clamav.py delete mode 100644 mail/courier-pythonfilter/files/patch-filters__dialback.py create mode 100644 mail/courier-pythonfilter/files/patch-filters__greylist.py create mode 100644 mail/courier-pythonfilter/files/patch-pythonfilter delete mode 100644 mail/courier-pythonfilter/files/patch-pythonfilter.conf create mode 100644 mail/courier-pythonfilter/files/patch-pythonfilter.conf.sample delete mode 100644 mail/courier-pythonfilter/files/patch-whitelist_auth.py diff --git a/mail/courier-pythonfilter/Makefile b/mail/courier-pythonfilter/Makefile index 312f929c18be..762897184b91 100644 --- a/mail/courier-pythonfilter/Makefile +++ b/mail/courier-pythonfilter/Makefile @@ -6,7 +6,7 @@ # PORTNAME= courier-pythonfilter -PORTVERSION= 0.9 +PORTVERSION= 0.16 CATEGORIES= mail python MASTER_SITES= http://phantom.dragonsdawn.net/~gordon/courier-patches/courier-pythonfilter/ @@ -26,13 +26,80 @@ MAILGID= 465 LOCALSTATEDIR= /var/spool/courier SCRIPTSDIR= ${PREFIX}/libexec/filters +OPTIONS= DEBUG "debug module" on \ + NODUPLICATES "noduplicates module" off \ + CLAMAV "clamav module" off \ + AUTO_WHITELIST "auto_whitelist module" off \ + WHITELIST "whitelist module" on \ + WHITELIST_AUTH "whitelist_auth module" on \ + PRIVATEADDR "privateaddr module" off \ + SPFCHECK "spfcheck module" off \ + NOSUCCESSDSN "nosuccessdsn module" off \ + COMEAGAIN "comeagain module" off \ + GREYLIST "greylist module" off \ + DIALBACK "dialback module" off \ + RATELIMIT "ratelimit module" off \ + ATTACHMENTS "attachments module" off + +.include + +PYDISTUTILS_INSTALLARGS:=${PYDISTUTILS_INSTALLARGS} --install-scripts=${SCRIPTSDIR} + +.if defined(WITH_CLAMAV) +RUN_DEPENDS+= ${PYTHON_SITELIBDIR}/pyclamav.so:${PORTSDIR}/security/py-clamav +.endif + post-extract: - ${MV} ${WRKSRC}/filters/whitelist-auth.py ${WRKSRC}/filters/whitelist_auth.py + ${MV} ${WRKSRC}/pythonfilter.conf ${WRKSRC}/pythonfilter.conf.sample + +post-configure: + @${ECHO_MSG} Creating sample config file based on your OPTIONS ... +.if !defined(WITHOUT_DEBUG) + @${ECHO_MSG} debug >> ${WRKSRC}/pythonfilter.conf.sample +.endif +.if defined(WITH_NODUPLICATES) + @${ECHO_MSG} noduplicate >> ${WRKSRC}/pythonfilter.conf.sample +.endif +.if defined(WITH_CLAMAV) + @${ECHO_MSG} clamav >> ${WRKSRC}/pythonfilter.conf.sample +.endif +.if !defined(WITHOUT_AUTO_WHITELIST) + @${ECHO_MSG} auto_whitelist >> ${WRKSRC}/pythonfilter.conf.sample +.endif +.if !defined(WITHOUT_WHITELIST) + @${ECHO_MSG} whitelist >> ${WRKSRC}/pythonfilter.conf.sample +.endif +.if !defined(WITHOUT_WHITELIST_AUTH) + @${ECHO_MSG} whitelist_auth >> ${WRKSRC}/pythonfilter.conf.sample +.endif +.if defined(WITH_PRIVATEADDR) + @${ECHO_MSG} privateaddr >> ${WRKSRC}/pythonfilter.conf.sample +.endif +.if defined(WITH_SPFCHECK) + @${ECHO_MSG} spfcheck >> ${WRKSRC}/pythonfilter.conf.sample +.endif +.if defined(WITH_NOSUCCESSDSN) + @${ECHO_MSG} nosuccessdsn >> ${WRKSRC}/pythonfilter.conf.sample +.endif +.if defined(WITH_COMEAGAIN) + @${ECHO_MSG} comeagain >> ${WRKSRC}/pythonfilter.conf.sample +.endif +.if defined(WITH_GREYLIST) + @${ECHO_MSG} greylist >> ${WRKSRC}/pythonfilter.conf.sample +.endif +.if defined(WITH_DIALBACK) + @${ECHO_MSG} dialback >> ${WRKSRC}/pythonfilter.conf.sample +.endif +.if defined(WITH_RATELIMIT) + @${ECHO_MSG} ratelimit >> ${WRKSRC}/pythonfilter.conf.sample +.endif +.if defined(WITH_ATTACHMENTS) + @${ECHO_MSG} attachments >> ${WRKSRC}/pythonfilter.conf.sample +.endif post-install: ${MKDIR} ${LOCALSTATEDIR}/pythonfilter ${CHOWN} ${MAILOWN}:${MAILGRP} ${LOCALSTATEDIR}/pythonfilter + if [ -e ${PREFIX}/etc/pythonfilter.conf ]; then ${CP} -p ${PREFIX}/etc/pythonfilter.conf.sample ${PREFIX}/etc/pythonfilter.conf; fi -.include - -PYDISTUTILS_INSTALLARGS:= ${PYDISTUTILS_INSTALLARGS} --install-scripts=${SCRIPTSDIR} +.include diff --git a/mail/courier-pythonfilter/distinfo b/mail/courier-pythonfilter/distinfo index 46aa0b8e4ed3..595cb71b3727 100644 --- a/mail/courier-pythonfilter/distinfo +++ b/mail/courier-pythonfilter/distinfo @@ -1,3 +1,3 @@ -MD5 (courier-pythonfilter-0.9.tar.gz) = 06d2c901ba6b700298da1c649d2788b9 -SHA256 (courier-pythonfilter-0.9.tar.gz) = 6840d63817ccae143f2c889d31e91f73a05966db350a7c5472e4859b278c84b3 -SIZE (courier-pythonfilter-0.9.tar.gz) = 27084 +MD5 (courier-pythonfilter-0.16.tar.gz) = 67998e92c107a1a55099c9c038084a32 +SHA256 (courier-pythonfilter-0.16.tar.gz) = d57c675bdcba52dea0fe7b29e8b39902703e05841a315fa2075b2d1ba0f75c14 +SIZE (courier-pythonfilter-0.16.tar.gz) = 33160 diff --git a/mail/courier-pythonfilter/files/patch-courier__config.py b/mail/courier-pythonfilter/files/patch-courier__config.py new file mode 100644 index 000000000000..ffba6426a7e4 --- /dev/null +++ b/mail/courier-pythonfilter/files/patch-courier__config.py @@ -0,0 +1,45 @@ +--- courier/config.py.orig Fri Dec 1 18:59:03 2006 ++++ courier/config.py Wed Dec 20 23:36:38 2006 +@@ -23,32 +23,11 @@ + import socket + + +-sysconf = '/etc/courier' +-prefix = '/usr/lib/courier' ++sysconf = '/usr/local/etc/courier' ++prefix = '/usr/local' + spool = '/var/spool/courier' + + +-def _setup(): +- sysconfs = ['/etc/courier', '/usr/lib/courier/etc'] +- prefixes = ['/usr/lib/courier'] +- spools = ['/var/lib/courier', '/var/spool/courier', '/usr/lib/courier/var/spool/courier'] +- global sysconf +- global prefix +- global spool +- for x in sysconfs: +- if os.path.isdir(x): +- sysconf = x +- break +- for x in prefixes: +- if os.path.isdir(x): +- prefix = x +- break +- for x in spools: +- if os.path.isdir(x): +- spool = x +- break +- +- + def read1line(file): + try: + cfile = open(sysconf + '/' + file, 'r') +@@ -283,7 +263,3 @@ + + """ + return getSmtpaccessVal('BLOCK', ip) +- +- +-# Call _setup to correct the module path values +-_setup() diff --git a/mail/courier-pythonfilter/files/patch-filters__TtlDb.py b/mail/courier-pythonfilter/files/patch-filters__TtlDb.py new file mode 100644 index 000000000000..0bbc50041dae --- /dev/null +++ b/mail/courier-pythonfilter/files/patch-filters__TtlDb.py @@ -0,0 +1,11 @@ +--- filters/TtlDb.py.orig Tue Dec 19 21:12:26 2006 ++++ filters/TtlDb.py Wed Dec 20 22:30:21 2006 +@@ -22,7 +22,7 @@ + import time + + +-_dbmDir = '/var/state/pythonfilter' ++_dbmDir = '/var/spool/courier/pythonfilter' + + + class TtlDbError(Exception): diff --git a/mail/courier-pythonfilter/files/patch-filters__clamav.py b/mail/courier-pythonfilter/files/patch-filters__clamav.py new file mode 100644 index 000000000000..4603bea32ba3 --- /dev/null +++ b/mail/courier-pythonfilter/files/patch-filters__clamav.py @@ -0,0 +1,18 @@ +--- filters/clamav.py.orig Sat Dec 16 03:11:51 2006 ++++ filters/clamav.py Sun Jan 7 10:56:30 2007 +@@ -31,13 +31,13 @@ + except Exception, e: + return "554 " + str(e) + if avresult[0]: +- return "554 %s was detected. Abort!" % avresult[1] ++ return "554 Virus found - Signature is %s" % avresult[1] + return '' + + + if __name__ == '__main__': + # we only work with 1 parameter + if len(sys.argv) != 2: +- print "Usage: attachment.py " ++ print "Usage: clamav.py " + sys.exit(0) + print doFilter(sys.argv[1], "") diff --git a/mail/courier-pythonfilter/files/patch-filters__comeagain.py b/mail/courier-pythonfilter/files/patch-filters__comeagain.py index 889bbb61a1cb..f7b30e19d030 100644 --- a/mail/courier-pythonfilter/files/patch-filters__comeagain.py +++ b/mail/courier-pythonfilter/files/patch-filters__comeagain.py @@ -1,11 +1,23 @@ ---- filters/comeagain.py.orig Mon Dec 13 09:26:13 2004 -+++ filters/comeagain.py Thu Jul 27 08:34:25 2006 -@@ -27,7 +27,7 @@ - - # Keep a dictionary of sender/recipient pairs that we've seen before - _sendersLock = thread.allocate_lock() --_sendersDir = '/var/state/pythonfilter' -+_sendersDir = '/var/spool/courier/pythonfilter' - try: - _senders = anydbm.open(_sendersDir + '/correspondents', 'c') - except: +--- filters/comeagain.py.orig Tue Jan 2 22:02:12 2007 ++++ filters/comeagain.py Sun Jan 7 12:35:20 2007 +@@ -89,11 +89,7 @@ + if foundAll: + return '' + else: +- return('421-Please send the message again.\n' +- '421-This is not an indication of a problem: We require\n' +- '421-that any new sender retry their delivery as proof that\n' +- '421-they are not spamware or virusware.\n' +- '421 Thank you.') ++ return('421 Please send the message again to proof you are not spamware or virusware.') + + + if __name__ == '__main__': +@@ -103,6 +99,6 @@ + # recipient. Run this script with the name of that file as an + # argument, and it'll validate that email address. + if not sys.argv[1:]: +- print 'Use: comeagain.py ' ++ print 'Use: comeagain.py ' + sys.exit(1) + print doFilter('', sys.argv[1:]) diff --git a/mail/courier-pythonfilter/files/patch-filters__dialback.py b/mail/courier-pythonfilter/files/patch-filters__dialback.py deleted file mode 100644 index d99fd282da60..000000000000 --- a/mail/courier-pythonfilter/files/patch-filters__dialback.py +++ /dev/null @@ -1,11 +0,0 @@ ---- filters/dialback.py.orig Sun Dec 26 00:01:02 2004 -+++ filters/dialback.py Thu Jul 27 08:33:13 2006 -@@ -32,7 +32,7 @@ - # Keep a dictionary of authenticated senders to avoid more work than - # required. - _sendersLock = thread.allocate_lock() --_sendersDir = '/var/state/pythonfilter' -+_sendersDir = '/var/spool/courier/pythonfilter' - try: - _goodSenders = anydbm.open(_sendersDir + '/goodsenders', 'c') - _badSenders = anydbm.open(_sendersDir + '/badsenders', 'c') diff --git a/mail/courier-pythonfilter/files/patch-filters__greylist.py b/mail/courier-pythonfilter/files/patch-filters__greylist.py new file mode 100644 index 000000000000..35c68ddc9900 --- /dev/null +++ b/mail/courier-pythonfilter/files/patch-filters__greylist.py @@ -0,0 +1,11 @@ +--- filters/greylist.py.orig Mon Dec 11 23:58:12 2006 ++++ filters/greylist.py Mon Jan 1 21:00:42 2007 +@@ -51,7 +51,7 @@ + sys.stderr.write(e.message) + sys.exit(1) + +-_whitelistDir = '/var/state/pythonfilter' ++_whitelistDir = '/var/spool/courier/pythonfilter' + try: + # messages which include these mail addresses either as sender or recipient + # should not be greylisted (could be your customer database) diff --git a/mail/courier-pythonfilter/files/patch-pythonfilter b/mail/courier-pythonfilter/files/patch-pythonfilter new file mode 100644 index 000000000000..8a59dd38307e --- /dev/null +++ b/mail/courier-pythonfilter/files/patch-pythonfilter @@ -0,0 +1,34 @@ +--- pythonfilter.orig Fri Dec 1 19:59:03 2006 ++++ pythonfilter Thu Dec 28 12:44:19 2006 +@@ -71,17 +71,15 @@ + # First, locate and open the configuration file. + config = None + try: +- configDirs = ('/etc', '/usr/local/etc') +- for x in configDirs: +- if os.access('%s/pythonfilter.conf' % x, os.R_OK): +- config = open('%s/pythonfilter.conf' % x) +- break ++ configDir = ('/usr/local/etc') ++ if os.access('%s/pythonfilter.conf' % configDir, os.R_OK): ++ config = open('%s/pythonfilter.conf' % configDir) + except IOError: + sys.stderr.write('Could not open config file for reading.\n') + sys.exit() + if not config: +- sys.stderr.write('Could not locate a configuration file in any of: %s\n', +- configDirs) ++ sys.stderr.write('Could not locate a configuration file in %s\n', ++ configDir) + sys.exit() + # Read the lines from the configuration file and load any module listed + # therein. Ignore lines that begin with a hash character. +@@ -106,7 +104,7 @@ + sys.stderr.write('Failed to load "doFilter" ' + 'function from %s\n' % + moduleName) +- sys.stderr.write('Exception : %s:%s\n' % ++ sys.stderr.write('Exception: %s:%s\n' % + (importError[0], importError[1])) + sys.stderr.write(string.join(traceback.format_tb(importError[2]), '')) + diff --git a/mail/courier-pythonfilter/files/patch-pythonfilter.conf b/mail/courier-pythonfilter/files/patch-pythonfilter.conf deleted file mode 100644 index e133b6384076..000000000000 --- a/mail/courier-pythonfilter/files/patch-pythonfilter.conf +++ /dev/null @@ -1,13 +0,0 @@ ---- pythonfilter.conf.orig Thu Jul 27 07:44:46 2006 -+++ pythonfilter.conf Thu Jul 27 07:44:56 2006 -@@ -11,8 +11,8 @@ - # whitelist: exempts IP addresses for which you relay from further filtering. - whitelist - --# whitelist-auth: exempts users who authenticate from further filtering. --whitelist-auth -+# whitelist_auth: exempts users who authenticate from further filtering. -+whitelist_auth - - # spfcheck: checks the sender against SPF records. - # Requires: spf - http://www.wayforward.net/spf/ diff --git a/mail/courier-pythonfilter/files/patch-pythonfilter.conf.sample b/mail/courier-pythonfilter/files/patch-pythonfilter.conf.sample new file mode 100644 index 000000000000..1e2791be00a5 --- /dev/null +++ b/mail/courier-pythonfilter/files/patch-pythonfilter.conf.sample @@ -0,0 +1,24 @@ +--- pythonfilter.conf.sample.orig Tue Dec 12 07:18:58 2006 ++++ pythonfilter.conf.sample Sun Jan 14 13:48:07 2007 +@@ -2,7 +2,7 @@ + # in this file. + + # debug: prints debugging information to the mail log. +-debug ++# debug + + # noduplicates: checks for duplicate recipients which may occur due to alias + # expansion, and removes the duplicates. +@@ -16,10 +16,10 @@ + # auto_whitelist + + # whitelist: exempts IP addresses for which you relay from further filtering. +-whitelist ++# whitelist + + # whitelist_auth: exempts users who authenticate from further filtering. +-whitelist_auth ++# whitelist_auth + + # privateaddr: restricts addresses to specific senders + # privateaddr diff --git a/mail/courier-pythonfilter/files/patch-setup.py b/mail/courier-pythonfilter/files/patch-setup.py index df1d0f313ebc..b3d8cf26ec41 100644 --- a/mail/courier-pythonfilter/files/patch-setup.py +++ b/mail/courier-pythonfilter/files/patch-setup.py @@ -5,5 +5,5 @@ packages=['courier', 'pythonfilter'], package_dir = {'pythonfilter': 'filters'}, - data_files=[('/etc/', ['pythonfilter.conf'])] -+ data_files=[('/usr/local/etc/', ['pythonfilter.conf'])] ++ data_files=[('/usr/local/etc/', ['pythonfilter.conf.sample'])] ) diff --git a/mail/courier-pythonfilter/files/patch-whitelist_auth.py b/mail/courier-pythonfilter/files/patch-whitelist_auth.py deleted file mode 100644 index f9ff0221b7fb..000000000000 --- a/mail/courier-pythonfilter/files/patch-whitelist_auth.py +++ /dev/null @@ -1,26 +0,0 @@ ---- filters/whitelist_auth.py.orig Sun Dec 26 00:01:02 2004 -+++ filters/whitelist_auth.py Thu Jul 27 07:46:24 2006 -@@ -1,5 +1,5 @@ - #!/usr/bin/python --# whitelist-auth -- Courier filter which exempts authenticated users from filtering -+# whitelist_auth -- Courier filter which exempts authenticated users from filtering - # Copyright (C) 2004 Gordon Messmer - # - # This program is free software; you can redistribute it and/or modify -@@ -28,7 +28,7 @@ - _auth_regex = re.compile(r'\(AUTH: \w* \w*([^)]*)\)\s*by %s' % _hostname) - - # Record in the system log that this filter was initialized. --sys.stderr.write('Initialized the "whitelist-auth" python filter\n') -+sys.stderr.write('Initialized the "whitelist_auth" python filter\n') - - - def checkHeader(header): -@@ -105,6 +105,6 @@ - # is whitelisted, or nothing to indicate that the remaining - # filters would be run. - if not sys.argv[1:]: -- print 'Use: whitelist-auth.py ' -+ print 'Use: whitelist_auth.py ' - sys.exit(1) - print doFilter(sys.argv[1], []) diff --git a/mail/courier-pythonfilter/pkg-plist b/mail/courier-pythonfilter/pkg-plist index ff0c2d2bf8e3..0537ff40ec9f 100644 --- a/mail/courier-pythonfilter/pkg-plist +++ b/mail/courier-pythonfilter/pkg-plist @@ -1,4 +1,5 @@ -etc/pythonfilter.conf +@unexec if cmp -s %D/etc/pythonfilter.conf %D/etc/pythonfilter.conf.sample; then rm -f %D/etc/pythonfilter.conf; fi +etc/pythonfilter.conf.sample libexec/filters/pythonfilter %%PYTHON_SITELIBDIR%%/courier/__init__.py %%PYTHON_SITELIBDIR%%/courier/__init__.pyc @@ -15,9 +16,15 @@ libexec/filters/pythonfilter %%PYTHON_SITELIBDIR%%/pythonfilter/__init__.py %%PYTHON_SITELIBDIR%%/pythonfilter/__init__.pyc %%PYTHON_SITELIBDIR%%/pythonfilter/__init__.pyo +%%PYTHON_SITELIBDIR%%/pythonfilter/TtlDb.py +%%PYTHON_SITELIBDIR%%/pythonfilter/TtlDb.pyc +%%PYTHON_SITELIBDIR%%/pythonfilter/TtlDb.pyo %%PYTHON_SITELIBDIR%%/pythonfilter/attachments.py %%PYTHON_SITELIBDIR%%/pythonfilter/attachments.pyc %%PYTHON_SITELIBDIR%%/pythonfilter/attachments.pyo +%%PYTHON_SITELIBDIR%%/pythonfilter/auto_whitelist.py +%%PYTHON_SITELIBDIR%%/pythonfilter/auto_whitelist.pyc +%%PYTHON_SITELIBDIR%%/pythonfilter/auto_whitelist.pyo %%PYTHON_SITELIBDIR%%/pythonfilter/clamav.py %%PYTHON_SITELIBDIR%%/pythonfilter/clamav.pyc %%PYTHON_SITELIBDIR%%/pythonfilter/clamav.pyo @@ -30,12 +37,18 @@ libexec/filters/pythonfilter %%PYTHON_SITELIBDIR%%/pythonfilter/dialback.py %%PYTHON_SITELIBDIR%%/pythonfilter/dialback.pyc %%PYTHON_SITELIBDIR%%/pythonfilter/dialback.pyo +%%PYTHON_SITELIBDIR%%/pythonfilter/greylist.py +%%PYTHON_SITELIBDIR%%/pythonfilter/greylist.pyc +%%PYTHON_SITELIBDIR%%/pythonfilter/greylist.pyo %%PYTHON_SITELIBDIR%%/pythonfilter/noduplicates.py %%PYTHON_SITELIBDIR%%/pythonfilter/noduplicates.pyc %%PYTHON_SITELIBDIR%%/pythonfilter/noduplicates.pyo %%PYTHON_SITELIBDIR%%/pythonfilter/nosuccessdsn.py %%PYTHON_SITELIBDIR%%/pythonfilter/nosuccessdsn.pyc %%PYTHON_SITELIBDIR%%/pythonfilter/nosuccessdsn.pyo +%%PYTHON_SITELIBDIR%%/pythonfilter/privateaddr.py +%%PYTHON_SITELIBDIR%%/pythonfilter/privateaddr.pyc +%%PYTHON_SITELIBDIR%%/pythonfilter/privateaddr.pyo %%PYTHON_SITELIBDIR%%/pythonfilter/ratelimit.py %%PYTHON_SITELIBDIR%%/pythonfilter/ratelimit.pyc %%PYTHON_SITELIBDIR%%/pythonfilter/ratelimit.pyo