1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-21 08:42:23 +00:00

- update to 0.16

- don't delete user-modified .conf file on deinstall
- OPTIONify

PR:		ports/107651
Submitted by:	Milan Obuch (maintainer)
This commit is contained in:
Ion-Mihai Tetcu 2007-01-16 10:28:15 +00:00
parent f5946d1ab6
commit 23c23b1ea1
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=182510
14 changed files with 256 additions and 71 deletions

View File

@ -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 <bsd.port.pre.mk>
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 <bsd.port.mk>
PYDISTUTILS_INSTALLARGS:= ${PYDISTUTILS_INSTALLARGS} --install-scripts=${SCRIPTSDIR}
.include <bsd.port.post.mk>

View File

@ -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

View File

@ -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()

View File

@ -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):

View File

@ -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 <message_body_file>"
+ print "Usage: clamav.py <message_body_file>"
sys.exit(0)
print doFilter(sys.argv[1], "")

View File

@ -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 <control file>'
+ print 'Use: comeagain.py <control file>'
sys.exit(1)
print doFilter('', sys.argv[1:])

View File

@ -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')

View File

@ -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)

View File

@ -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]), ''))

View File

@ -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/

View File

@ -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

View File

@ -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'])]
)

View File

@ -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 <gordon@dragonsdawn.net>
#
# 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 <control file>'
+ print 'Use: whitelist_auth.py <control file>'
sys.exit(1)
print doFilter(sys.argv[1], [])

View File

@ -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