pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/security/clamav security/clamav: add clamav-milter sta...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/fdb93036b40f
branches:  trunk
changeset: 439219:fdb93036b40f
user:      taca <taca%pkgsrc.org@localhost>
date:      Mon Sep 14 16:54:35 2020 +0000

description:
security/clamav: add clamav-milter startup script

Add clamav-milter startup script.

Bump PKGREVISION.

diffstat:

 security/clamav/Makefile               |   3 +-
 security/clamav/files/clamav-milter.sh |  76 ++++++++++++++++++++++++++++++++++
 security/clamav/options.mk             |   3 +-
 3 files changed, 80 insertions(+), 2 deletions(-)

diffs (109 lines):

diff -r 89e288984c39 -r fdb93036b40f security/clamav/Makefile
--- a/security/clamav/Makefile  Mon Sep 14 16:38:10 2020 +0000
+++ b/security/clamav/Makefile  Mon Sep 14 16:54:35 2020 +0000
@@ -1,6 +1,7 @@
-# $NetBSD: Makefile,v 1.69 2020/07/17 04:48:32 taca Exp $
+# $NetBSD: Makefile,v 1.70 2020/09/14 16:54:35 taca Exp $
 
 .include "Makefile.common"
+PKGREVISION= 1
 
 COMMENT=       Anti-virus toolkit
 
diff -r 89e288984c39 -r fdb93036b40f security/clamav/files/clamav-milter.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/security/clamav/files/clamav-milter.sh    Mon Sep 14 16:54:35 2020 +0000
@@ -0,0 +1,76 @@
+#!@RCD_SCRIPTS_SHELL@
+#
+# $NetBSD: clamav-milter.sh,v 1.1 2020/09/14 16:54:35 taca Exp $
+#
+# clamav-milter provides milter socket for mail daemon
+#
+# PROVIDE: clamav_milter
+# REQUIRE: clamd
+# BEFORE: mail local
+# KEYWORD: shutdown
+
+if [ -f /etc/rc.subr ]; then
+       . /etc/rc.subr
+fi
+
+name="clamav_milter"
+rcvar=$name
+command="@PREFIX@/sbin/clamav-milter"
+required_files="@PKG_SYSCONFDIR@/clamav-milter.conf"
+start_precmd="clamd_precmd"
+stop_cmd="clamav_milter_stopcmd"
+
+if [ -f "${required_files}" ]; then
+       pidfile_=`@AWK@ '/^#/ {next}; /^PidFile[        ]/ {r = $2};
+                       END {print r}' ${required_files}`
+       if [ -n "${pidfile_}" ]; then
+               pidfile=${pidfile_}
+       fi
+       logfile=`@AWK@ 'BEGIN {r = "/tmp/clamd.log"};
+                       /^#/ {next}; /^LogFile[         ]/ {r = $2};
+                       END {print r}' ${required_files}`
+       socket=`@AWK@ 'BEGIN {r = "/tmp/clamd"};
+                       /^#/ {next}; /^LocalSocket[     ]/ {r = $2};
+                       END {print r}' ${required_files}`
+       clamav_milter_user=`@AWK@ 'BEGIN {r = "@CLAMAV_USER@"};
+                       /^#/ {next}; /^User[    ]/ {r = $2};
+                       END {print r}' ${required_files}`
+fi
+
+clamav_milter_precmd()
+{
+       @RM@ -f ${socket}
+       if [ -n "${logfile}" ]; then
+               @TOUCH@ ${logfile}
+               @CHOWN@ ${clamav_milter_user} ${logfile}
+       fi
+       if [ -n "${pidfile}" ]; then
+               @TOUCH@ ${pidfile}
+               @CHOWN@ ${clamav_milter_user} ${pidfile}
+       fi
+}
+
+clamav_milter_stopcmd()
+{
+       # Workaround bug when clamd is built against pth by send TERM to
+       # clamd, then forcing it to start a worker thread that exits.
+       # This forces the main thread to awaken and realize that it's
+       # supposed to shutdown.
+       #
+       @ECHO@ "Stopping ${name}."
+       doit="@SU@ -m ${clamav_milter_user} -c \"kill -TERM $rc_pid\""
+       if ! eval $doit && [ -z "$rc_force" ]; then
+               return 1
+       fi
+       wait_for_pids $rc_pid
+}
+
+if [ -f /etc/rc.subr -a -f /etc/rc.conf \
+     -a -d /etc/rc.d -a -f /etc/rc.d/DAEMON ]; then
+       load_rc_config $name
+       run_rc_command "$1"
+else
+       @ECHO@ -n " ${name}"
+       eval ${start_precmd}
+       ${command} ${clamav_milter_flags} ${command_args}
+fi
diff -r 89e288984c39 -r fdb93036b40f security/clamav/options.mk
--- a/security/clamav/options.mk        Mon Sep 14 16:38:10 2020 +0000
+++ b/security/clamav/options.mk        Mon Sep 14 16:54:35 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: options.mk,v 1.6 2019/08/05 14:44:20 prlw1 Exp $
+# $NetBSD: options.mk,v 1.7 2020/09/14 16:54:35 taca Exp $
 
 PKG_OPTIONS_VAR=       PKG_OPTIONS.clamav
 PKG_SUPPORTED_OPTIONS= milter clamav-experimental unit-test
@@ -17,6 +17,7 @@
 PLIST.milter=          yes
 CONF_SAMPLES+=         clamav-milter.conf
 SMF_INSTANCES+=                clamav-milter
+RCD_SCRIPTS+=          clamav-milter
 .else
 CONFIGURE_ARGS+=       --disable-milter
 # XXX --disable-milter doesn't work as expected, so we need this



Home | Main Index | Thread Index | Old Index