Date: Fri, 14 Jan 2022 18:01:44 GMT From: Chris Rees <crees@FreeBSD.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org Subject: git: 0e46cdf18498 - main - mail/opendkim: Respect PidFile setting in opendkim.conf Message-ID: <202201141801.20EI1ifJ085950@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by crees: URL: https://cgit.FreeBSD.org/ports/commit/?id=0e46cdf18498118d3309812946e1df0245d62cb0 commit 0e46cdf18498118d3309812946e1df0245d62cb0 Author: Chris Rees <crees@FreeBSD.org> AuthorDate: 2022-01-14 17:56:38 +0000 Commit: Chris Rees <crees@FreeBSD.org> CommitDate: 2022-01-14 18:01:28 +0000 mail/opendkim: Respect PidFile setting in opendkim.conf While here, pet rclint a bit, though it doesn't like the profile parts not being in functions PR: ports/254762 Reported by: Rob LA LAU <freebsd@ohreally.nl> Reviewed by: skozlov (a previous iteration) Approved by: maintainer timeout, 9 months Differential Revision: https://reviews.freebsd.org/D29586 --- mail/opendkim/Makefile | 2 +- mail/opendkim/files/milter-opendkim.in | 98 ++++++++++++++++------------------ 2 files changed, 48 insertions(+), 52 deletions(-) diff --git a/mail/opendkim/Makefile b/mail/opendkim/Makefile index 18cf989dcb06..620252c2fff5 100644 --- a/mail/opendkim/Makefile +++ b/mail/opendkim/Makefile @@ -2,7 +2,7 @@ PORTNAME= opendkim PORTVERSION= 2.10.3 -PORTREVISION= 13 +PORTREVISION= 14 CATEGORIES= mail security MASTER_SITES= SF/${PORTNAME} \ SF/${PORTNAME}/Previous%20Releases \ diff --git a/mail/opendkim/files/milter-opendkim.in b/mail/opendkim/files/milter-opendkim.in index 930b91ee32d5..8d83197d8884 100644 --- a/mail/opendkim/files/milter-opendkim.in +++ b/mail/opendkim/files/milter-opendkim.in @@ -51,15 +51,55 @@ load_rc_config $name # # DO NOT CHANGE THESE DEFAULT VALUES HERE # -: ${milteropendkim_enable="NO"} -: ${milteropendkim_uid="mailnull"} -: ${milteropendkim_gid="mailnull"} -: ${milteropendkim_cfgfile="%%PREFIX%%/etc/mail/opendkim.conf"} -: ${milteropendkim_socket_perms="0755"} +: ${milteropendkim_enable:="NO"} +: ${milteropendkim_uid:="mailnull"} +: ${milteropendkim_gid:="mailnull"} +: ${milteropendkim_cfgfile:="%%PREFIX%%/etc/mail/opendkim.conf"} +: ${milteropendkim_socket_perms:="0755"} # Options other than above can be set with $milteropendkim_flags. # see dkim-milter documentation for detail. +extra_commands="reload" +start_precmd="dkim_prepcmd" +start_postcmd="dkim_start_postcmd" +stop_postcmd="dkim_cleansockets" +command="%%PREFIX%%/sbin/opendkim" +sig_reload="USR1" + +dkim_cleansockets() +{ + rm -f "${milteropendkim_socket##local:}" "${milteropendkim_socket##unix:}" +} + +dkim_get_pidfile() +{ + if get_pidfile_from_conf PidFile ${milteropendkim_cfgfile#-x }; then + pidfile="$_pidfile_from_conf" + else + pidfile="/var/run/milteropendkim/${profile:-pid}" + fi +} + +dkim_prepcmd() +{ + dkim_cleansockets + dkim_get_pidfile + install -d -o ${milteropendkim_uid%:*} -g $milteropendkim_gid \ + -m ${milteropendkim_socket_perms} ${pidfile%/*} +} + +dkim_start_postcmd() +{ + if [ -n "${milteropendkim_socket}" ] ; then + # postcmd is executed too fast and socket is not created before checking... + sleep 1 + chmod -f ${milteropendkim_socket_perms} \ + ${milteropendkim_socket##local:} \ + ${milteropendkim_socket##unix:} + fi +} + if [ -n "$2" ]; then profile="$2" if [ -n "${milteropendkim_profiles}" ]; then @@ -67,7 +107,7 @@ if [ -n "$2" ]; then eval milteropendkim_enable="\${milteropendkim_${profile}_enable:-${milteropendkim_enable}}" eval milteropendkim_socket="\${milteropendkim_${profile}_socket:-}" eval milteropendkim_socket_perms="\${milteropendkim_${profile}_socket_perms:-}" - if [ "x${milteropendkim_socket}" = "x" ];then + if [ -z "${milteropendkim_socket}" ];then echo "You must define a socket (milteropendkim_${profile}_socket)" exit 1 fi @@ -103,6 +143,7 @@ if [ -n "$2" ]; then if [ -n "${milteropendkim_alg}" ];then milteropendkim_alg="-S ${milteropendkim_alg}" fi + dkim_get_pidfile command_args="-l ${_socket_prefix} ${milteropendkim_socket} ${_uid_prefix} ${milteropendkim_uid} -P ${pidfile} ${milteropendkim_cfgfile} ${milteropendkim_domain} ${milteropendkim_key} ${milteropendkim_selector} ${milteropendkim_alg}" else echo "$0: extra argument ignored" @@ -155,49 +196,4 @@ else fi fi -dkim_prepcmd () -{ - if [ -S "${milteropendkim_socket##local:}" ] ; then - rm -f "${milteropendkim_socket##local:}" - elif [ -S "${milteropendkim_socket##unix:}" ] ; then - rm -f "${milteropendkim_socket##unix:}" - fi - if [ ! -d ${_piddir} ] ; then - mkdir -p ${_piddir} - fi - if [ -n "${milteropendkim_uid}" ] ; then - chown ${milteropendkim_uid} ${_piddir} - fi - if [ -n "${milteropendkim_gid}" ] ; then - chgrp ${milteropendkim_gid} ${_piddir} - fi - chmod ${milteropendkim_socket_perms} ${_piddir} -} - -dkim_start_postcmd () -{ - if [ -n "${milteropendkim_socket}" ] ; then - # postcmd is executed too fast and socket is not created before checking... - sleep 1 - if [ -S "${milteropendkim_socket##local:}" ] ; then - chmod ${milteropendkim_socket_perms} ${milteropendkim_socket##local:} - elif [ -S "${milteropendkim_socket##unix:}" ] ; then - chmod ${milteropendkim_socket_perms} ${milteropendkim_socket##unix:} - fi - fi -} - -dkim_postcmd() -{ - if [ -n "${milteropendkim_socket}" ] ; then - if [ -S "${milteropendkim_socket##local:}" ] ; then - rm -f "${milteropendkim_socket##local:}" - elif [ -S "${milteropendkim_socket##unix:}" ] ; then - rm -f "${milteropendkim_socket##unix:}" - fi - fi - # just if the directory is empty - rmdir ${_piddir} > /dev/null 2>&1 -} - run_rc_command "$1"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202201141801.20EI1ifJ085950>