git: 00b787288fc8 - main - mail/py-spf-engine: Miscellaneous bug fixes and improvements

From: Yasuhiro Kimura <yasu_at_FreeBSD.org>
Date: Mon, 05 Sep 2022 20:19:00 UTC
The branch main has been updated by yasu:

URL: https://cgit.FreeBSD.org/ports/commit/?id=00b787288fc81a2e5dba2a62a2627da760772b50

commit 00b787288fc81a2e5dba2a62a2627da760772b50
Author:     Yasuhiro Kimura <yasu@FreeBSD.org>
AuthorDate: 2022-09-05 16:31:19 +0000
Commit:     Yasuhiro Kimura <yasu@FreeBSD.org>
CommitDate: 2022-09-05 20:18:13 +0000

    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
---
 mail/py-spf-engine/Makefile                        | 19 +++------
 mail/py-spf-engine/files/patch-policyd-spf.1       | 48 ++++++++++++++++++++++
 mail/py-spf-engine/files/patch-policyd-spf.conf.5  | 36 ++++++++++++++++
 .../files/patch-policyd-spf.peruser.5              | 20 +++++++++
 .../files/patch-spf__engine_milter__spf.py         | 11 +++++
 .../files/patch-spf__engine_policyd__spf.py        | 11 +++++
 .../files/patch-spf__engine_policydspfsupp.py      | 25 +++++++++++
 mail/py-spf-engine/files/pyspf-milter.in           |  4 +-
 8 files changed, 159 insertions(+), 15 deletions(-)

diff --git a/mail/py-spf-engine/Makefile b/mail/py-spf-engine/Makefile
index 819357de8ccc..902407a18fe6 100644
--- a/mail/py-spf-engine/Makefile
+++ b/mail/py-spf-engine/Makefile
@@ -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 \
diff --git a/mail/py-spf-engine/files/patch-policyd-spf.1 b/mail/py-spf-engine/files/patch-policyd-spf.1
new file mode 100644
index 000000000000..1ab3cd78a9a3
--- /dev/null
+++ b/mail/py-spf-engine/files/patch-policyd-spf.1
@@ -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 =
+             ...
diff --git a/mail/py-spf-engine/files/patch-policyd-spf.conf.5 b/mail/py-spf-engine/files/patch-policyd-spf.conf.5
new file mode 100644
index 000000000000..6808c160c5ca
--- /dev/null
+++ b/mail/py-spf-engine/files/patch-policyd-spf.conf.5
@@ -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 =
diff --git a/mail/py-spf-engine/files/patch-policyd-spf.peruser.5 b/mail/py-spf-engine/files/patch-policyd-spf.peruser.5
new file mode 100644
index 000000000000..753aee30c928
--- /dev/null
+++ b/mail/py-spf-engine/files/patch-policyd-spf.peruser.5
@@ -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
diff --git a/mail/py-spf-engine/files/patch-spf__engine_milter__spf.py b/mail/py-spf-engine/files/patch-spf__engine_milter__spf.py
new file mode 100644
index 000000000000..6c384d78aa85
--- /dev/null
+++ b/mail/py-spf-engine/files/patch-spf__engine_milter__spf.py
@@ -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>]')
diff --git a/mail/py-spf-engine/files/patch-spf__engine_policyd__spf.py b/mail/py-spf-engine/files/patch-spf__engine_policyd__spf.py
new file mode 100644
index 000000000000..537f08fd7cca
--- /dev/null
+++ b/mail/py-spf-engine/files/patch-spf__engine_policyd__spf.py
@@ -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>]')
diff --git a/mail/py-spf-engine/files/patch-spf__engine_policydspfsupp.py b/mail/py-spf-engine/files/patch-spf__engine_policydspfsupp.py
new file mode 100644
index 000000000000..39968058e44d
--- /dev/null
+++ b/mail/py-spf-engine/files/patch-spf__engine_policydspfsupp.py
@@ -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,
+             }
+ 
diff --git a/mail/py-spf-engine/files/pyspf-milter.in b/mail/py-spf-engine/files/pyspf-milter.in
index 2019e2bf129f..a21e5a5c4da8 100644
--- a/mail/py-spf-engine/files/pyspf-milter.in
+++ b/mail/py-spf-engine/files/pyspf-milter.in
@@ -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