mail/py-spf-engine: Miscellaneous bug fixes and improvements

* Fix runtime error of pyspf-milter that happens when either 'UMask'
  or 'IntHosts' is set in configuration file.
* Stop installing backup files.
* Make miscellaneous paths consistent between library files, man
  pages, pkg-message and rc.d script.
* Remove CONFLICTS as mail/postfix-policyd-spf-python is removed from
  ports tree

MFH:		2022Q3
This commit is contained in:
Yasuhiro Kimura 2022-09-06 01:31:19 +09:00
parent f107392645
commit 00b787288f
8 changed files with 159 additions and 15 deletions

View File

@ -1,5 +1,6 @@
PORTNAME= spf-engine
DISTVERSION= 2.9.3
PORTREVISION= 1
CATEGORIES= mail python
MASTER_SITES= CHEESESHOP
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
@ -22,19 +23,14 @@ USE_RC_SUBR= pyspf-milter
SHEBANG_FILES= spf_engine/milter_spf.py spf_engine/policyd_spf.py
CONFLICTS= py*-postfix-policyd-spf-python
NO_ARCH= yes
SUB_FILES= pkg-message
SUB_LIST= PYSPF_MILTER_RUNDIR=${PYSPF_MILTER_RUNDIR} \
PYTHON_CMD=${PYTHON_CMD}
SUB_LIST= PYTHON_CMD=${PYTHON_CMD}
USERS= pyspf-milter
GROUPS= pyspf-milter
PYSPF_MILTER_RUNDIR= /var/run/pyspf-milter
PLIST_FILES= '@dir(${USERS},${GROUPS},755) ${PYSPF_MILTER_RUNDIR}' \
PLIST_FILES= '@dir(${USERS},${GROUPS},755) /var/run/pyspf-milter' \
'@sample etc/python-policyd-spf/policyd-spf.conf.sample'
PORTDOCS= CHANGES README README.per_user_whitelisting \
@ -43,14 +39,11 @@ PORTDOCS= CHANGES README README.per_user_whitelisting \
OPTIONS_DEFINE= DOCS
post-patch:
@${REINPLACE_CMD} -e "s|/usr/local/etc/|${PREFIX}/etc/|" \
${WRKSRC}/spf_engine/milter_spf.py
@${REINPLACE_CMD} -e "s|/etc/|${PREFIX}/etc/|" \
${WRKSRC}/spf_engine/policyd_spf.py
@${REINPLACE_CMD} -e "s|/run|/var/run|" ${WRKSRC}/spf_engine/policydspfsupp.py
@${REINPLACE_CMD} -e "s|/etc/|${PREFIX}/etc/|" -e "s|/usr/bin/|${PREFIX}/bin/|" \
@${REINPLACE_CMD} -e "s|%%PREFIX%%|${PREFIX}|" \
${WRKSRC}/spf_engine/milter_spf.py ${WRKSRC}/spf_engine/policyd_spf.py \
${WRKSRC}/policyd-spf.1 ${WRKSRC}/policyd-spf.conf.5 \
${WRKSRC}/policyd-spf.peruser.5
@${FIND} ${WRKSRC} \( -name '*.bak' -or -name '*.orig' \) -delete
post-install:
@${MKDIR} ${STAGEDIR}/var/run/pyspf-milter \

View File

@ -0,0 +1,48 @@
--- policyd-spf.1.orig 2020-04-18 06:04:36 UTC
+++ policyd-spf.1
@@ -144,12 +144,12 @@ $ policyd-spf (Start using installed config file)
$ policyd-spf \-h (Display usage message)
-$ policyd-spf /etc/policyd-spf/policyd-spf.conf (Config file name to use)
+$ policyd-spf %%PREFIX%%/etc/python-policyd-spf/policyd-spf.conf (Config file name to use)
Configuration options are described in the sample configuration file provided
with the package (policyd-spf.conf.commented) and in policyd-spf.conf(5). The
provided setup.py installs an uncommented configuration file in
-/etc/policyd-spf/.
+%%PREFIX%%/etc/python-policyd-spf/.
Additionally, whitelisting certain IP addresses or IP addresses used by listed
domains from SPF checks is supported. Skipping SPF checks for local submission
@@ -186,7 +186,7 @@ script is smoothed over time
The default policy_time_limit is 1000 seconds. This may be too short for some
SMTP transactions to complete. As recommended in SMTPD_POLICY_README, this
should be extended to 3600 seconds. To do so, set "policy_time_limit = 3600"
-in /etc/postfix/main.cf.
+in %%PREFIX%%/etc/postfix/main.cf.
Messages that get a Fail SPF result will be rejected. Messages that get a
Permerror are, by default, treated as if they had no SPF record. Messages
@@ -244,10 +244,10 @@ followed by a empty line:
.SH "POSTFIX INTEGRATION"
- 1. Add the following to /etc/postfix/master.cf:
+ 1. Add the following to %%PREFIX%%/etc/postfix/master.cf:
policyd-spf unix - n n - 0 spawn
- user=nobody argv=/usr/bin/policyd-spf
+ user=nobody argv=%%PREFIX%%/bin/policyd-spf
NOTE: Check the path to both the installed Python 3 interpreter and
policyd-spf. These vary from system to system. To use non-default
@@ -257,7 +257,7 @@ followed by a empty line:
that instead. Python and Python 3 versions prior to 3.3 are not
supported.
- 2. Configure the Postfix policy service in /etc/postfix/main.cf:
+ 2. Configure the Postfix policy service in %%PREFIX%%/etc/postfix/main.cf:
smtpd_recipient_restrictions =
...

View File

@ -0,0 +1,36 @@
--- policyd-spf.conf.5.orig 2020-04-18 06:04:36 UTC
+++ policyd-spf.conf.5
@@ -137,7 +137,7 @@ policyd-spf python configuration parameters
.SH "USAGE"
Usage:
- policyd-spf [/etc/policyd-spf/policyd-spf.conf]
+ policyd-spf [%%PREFIX%%/etc/python-policyd-spf/policyd-spf.conf]
.SH "OTHER DOCUMENTATION"
This documentation assumes you have read Postfix's README_FILES/
@@ -162,7 +162,7 @@ file.
Configuration options are described here and in the configuration file
provided with the package. The provided setup.py installs this configuration
-file in /etc/policyd-spf/.
+file in %%PREFIX%%/etc/python-policyd-spf/.
Additionally, whitelisting certain IP addresses from SPF checks is supported.
This man page and the sample configuration file show the format to use.
@@ -684,12 +684,12 @@ visible to milters such as DMARC milter.
To use this feature requires additional postfix configuration to execute the
second, mock, instance of the policy server:
- Add a second service to /etc/postfix/master.cf:
+ Add a second service to %%PREFIX%%/etc/postfix/master.cf:
policyd-spf-mock unix - n n - 0 spawn
- user=nobody argv=/usr/bin/policyd-spf '/etc/pypolicyd-spf/mock
+ user=nobody argv=%%PREFIX%%/bin/policyd-spf '%%PREFIX%%/etc/pypolicyd-spf/mock
-Configure the Postfix additional policy service in /etc/postfix/main.cf to
+Configure the Postfix additional policy service in %%PREFIX%%/etc/postfix/main.cf to
run before the regular service:
smtpd_recipient_restrictions =

View File

@ -0,0 +1,20 @@
--- policyd-spf.peruser.5.orig 2022-09-05 16:01:49 UTC
+++ policyd-spf.peruser.5
@@ -137,7 +137,7 @@ policyd-spf python per-user configuration
.SH "USAGE"
Usage:
- policyd-spf [/etc/policyd-spf/policyd-spf.conf]
+ policyd-spf [%%PREFIX%%/etc/python-policyd-spf/policyd-spf.conf]
.SH "OTHER DOCUMENTATION"
This documentation assumes you have read Postfix's README_FILES/
@@ -196,7 +196,7 @@ The text file option is useful for testing and when on
users require per-user configurations. It is specified in the main
configuration file:
-"Per_User = text,/etc/pypolicyd-spf/userconf"
+"Per_User = text,%%PREFIX%%/etc/python-pypolicyd-spf/userconf"
Lines beginning with "#" are treated as comments and ignored. The location of
the file is determined by the system administrator. No default file is

View File

@ -0,0 +1,11 @@
--- spf_engine/milter_spf.py.orig 2022-09-05 15:47:42 UTC
+++ spf_engine/milter_spf.py
@@ -207,7 +207,7 @@ class spfMilter(Milter.Base):
def main():
# Ugh, but there's no easy way around this.
global milterconfig
- configFile = '/usr/local/etc/python-policyd-spf/policyd-spf.conf'
+ configFile = '%%PREFIX%%/etc/python-policyd-spf/policyd-spf.conf'
if len(sys.argv) > 1:
if sys.argv[1] in ('-?', '--help', '-h'):
print('usage: pyspf-milter [<configfilename>]')

View File

@ -0,0 +1,11 @@
--- spf_engine/policyd_spf.py.orig 2022-09-05 15:47:42 UTC
+++ spf_engine/policyd_spf.py
@@ -46,7 +46,7 @@ def main():
# load config file {{{1
# Default location:
- configFile = '/etc/python-policyd-spf/policyd-spf.conf'
+ configFile = '%%PREFIX%%/etc/python-policyd-spf/policyd-spf.conf'
if len(sys.argv) > 1:
if sys.argv[1] in ( '-?', '--help', '-h' ):
print('usage: policyd-spf [<configfilename>]')

View File

@ -0,0 +1,25 @@
--- spf_engine/policydspfsupp.py.orig 2020-04-18 06:04:36 UTC
+++ spf_engine/policydspfsupp.py
@@ -47,8 +47,8 @@ defaultConfigData = {
'No_Mail' : False,
'Mock' : False,
# For milter front end
- 'Socket': 'local:/run/pyspf-milter/pyspf-milter.sock',
- 'PidFile': '/run/pyspf-milter/pyspf-milter.pid',
+ 'Socket': 'local:/var/run/pyspf-milter/pyspf-milter.sock',
+ 'PidFile': '/var/run/pyspf-milter/pyspf-milter.pid',
'UserID': 'pyspf-milter',
'UMask': 7,
'InternalHosts': '127.0.0.1',
@@ -153,9 +153,9 @@ def _readConfigFile(path, configData = None, configGlo
'Socket': str,
'PidFile': str,
'UserID': str,
- 'UMask': 'int',
+ 'UMask': int,
'InternalHosts': str,
- 'IntHosts': 'bool',
+ 'IntHosts': bool,
'MacroListVerify': str,
}

View File

@ -26,8 +26,8 @@ command=/usr/sbin/daemon
command_interpreter=%%PYTHON_CMD%%
procname=%%PREFIX%%/bin/pyspf-milter
command_args="-c -f ${procname} ${pyspf_milter_conffile}"
pidfile=%%PYSPF_MILTER_RUNDIR%%/pyspf-milter.pid
required_dirs=%%PYSPF_MILTER_RUNDIR%%
pidfile=/var/run/pyspf-milter/pyspf-milter.pid
required_dirs=/var/run/pyspf-milter
required_files=${pyspf_milter_conffile}
start_precmd=pyspf_milter_cleanup
stop_postcmd=pyspf_milter_cleanup