summaryrefslogtreecommitdiff
path: root/app-antivirus/clamav/files
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2020-09-23 10:22:15 +0100
committerV3n3RiX <venerix@redcorelinux.org>2020-09-23 10:22:15 +0100
commit8b4ace9c50842c5b83401ea7b179dcab940387e1 (patch)
tree230f3135ceaace633cf93e9838b185c4a6664c2e /app-antivirus/clamav/files
parent9ee6d97c2883d42f204a533a8bc1f4562df778fb (diff)
gentoo resync : 23.09.2020
Diffstat (limited to 'app-antivirus/clamav/files')
-rw-r--r--app-antivirus/clamav/files/clamav-0.103.0-system-tomsfastmath.patch115
-rw-r--r--app-antivirus/clamav/files/clamav-0.103.0-upstream-openrc.patch439
-rw-r--r--app-antivirus/clamav/files/clamav-milter.logrotate25
-rw-r--r--app-antivirus/clamav/files/clamd.logrotate17
-rw-r--r--app-antivirus/clamav/files/freshclam.logrotate17
-rw-r--r--app-antivirus/clamav/files/freshclamd.service-r110
6 files changed, 623 insertions, 0 deletions
diff --git a/app-antivirus/clamav/files/clamav-0.103.0-system-tomsfastmath.patch b/app-antivirus/clamav/files/clamav-0.103.0-system-tomsfastmath.patch
new file mode 100644
index 000000000000..ad9276c1ad01
--- /dev/null
+++ b/app-antivirus/clamav/files/clamav-0.103.0-system-tomsfastmath.patch
@@ -0,0 +1,115 @@
+From 70cc96407302cf0fd4eee2b6a401253ed50fe4df Mon Sep 17 00:00:00 2001
+From: Michael Orlitzky <michael@orlitzky.com>
+Date: Sun, 20 Sep 2020 11:16:06 -0400
+Subject: [PATCH 1/1] autotools: use system tomsfastmath if possible.
+
+---
+ configure.ac | 2 ++
+ libclamav/Makefile.am | 10 ++++++++--
+ libclamav/bignum.h | 6 +++++-
+ libclamav/xdp.c | 2 +-
+ m4/reorganization/libs/tomsfastmath.m4 | 12 ++++++++++++
+ 5 files changed, 28 insertions(+), 4 deletions(-)
+ create mode 100644 m4/reorganization/libs/tomsfastmath.m4
+
+diff --git a/configure.ac b/configure.ac
+index 8e0e810f8..773787e49 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -104,6 +104,7 @@ m4_include([m4/reorganization/libs/libmspack.m4])
+ if test "x$use_internal_mspack" = "xno"; then
+ mspack_msg="External, $LIBMSPACK_CFLAGS $LIBMSPACK_LIBS"
+ fi
++m4_include([m4/reorganization/libs/tomsfastmath.m4])
+
+ AM_MAINTAINER_MODE
+ m4_include([m4/reorganization/libs/libz.m4])
+@@ -376,6 +377,7 @@ fi
+ CL_MSG_STATUS([yara ],[$enable_yara],[$enable_yara])
+ CL_MSG_STATUS([fts ],[yes],[$lfs_fts_msg])
+
++CL_MSG_STATUS([tomsfastmath],[yes],[$tomsfastmath_msg])
+
+ # Yep, downgrading the compiler avoids the bug too:
+ # 4.0.x, and 4.1.0 are the known buggy versions
+diff --git a/libclamav/Makefile.am b/libclamav/Makefile.am
+index ae655cfec..240fa23f8 100644
+--- a/libclamav/Makefile.am
++++ b/libclamav/Makefile.am
+@@ -588,8 +588,10 @@ libclamav_la_SOURCES += yara_arena.c \
+ yara_clam.h
+ endif
+
+-libclamav_la_SOURCES += bignum.h\
+- bignum_fast.h\
++libclamav_la_SOURCES += bignum.h
++
++if !SYSTEM_TOMSFASTMATH
++libclamav_la_SOURCES += bignum_fast.h\
+ tomsfastmath/addsub/fp_add.c\
+ tomsfastmath/addsub/fp_add_d.c\
+ tomsfastmath/addsub/fp_addmod.c\
+@@ -671,6 +673,10 @@ libclamav_la_SOURCES += bignum.h\
+ tomsfastmath/sqr/fp_sqr_comba_generic.c\
+ tomsfastmath/sqr/fp_sqr_comba_small_set.c\
+ tomsfastmath/sqr/fp_sqrmod.c
++else
++libclamav_la_CFLAGS += $(TOMSFASTMATH_CFLAGS)
++libclamav_la_LIBADD += $(TOMSFASTMATH_LIBS)
++endif
+
+ .PHONY2: version.h.tmp
+ version.c: version.h
+diff --git a/libclamav/bignum.h b/libclamav/bignum.h
+index 8fdc956bb..56dfa957e 100644
+--- a/libclamav/bignum.h
++++ b/libclamav/bignum.h
+@@ -1,9 +1,13 @@
+ #ifndef BIGNUM_H_
+ #define BIGNUM_H_
+
++#if HAVE_SYSTEM_TOMSFASTMATH
++#include <tfm.h>
++#else
+ #define TFM_CHECK
+-
+ #include "bignum_fast.h"
++#endif
++
+ typedef fp_int mp_int;
+ #define mp_cmp fp_cmp
+ #define mp_toradix_n(a, b, c, d) fp_toradix_n(a, b, c, d)
+diff --git a/libclamav/xdp.c b/libclamav/xdp.c
+index 87423421d..6370221ff 100644
+--- a/libclamav/xdp.c
++++ b/libclamav/xdp.c
+@@ -52,7 +52,7 @@
+ #include "scanners.h"
+ #include "conv.h"
+ #include "xdp.h"
+-#include "bignum_fast.h"
++#include "bignum.h"
+ #include "filetypes.h"
+
+ static char *dump_xdp(cli_ctx *ctx, const char *start, size_t sz);
+diff --git a/m4/reorganization/libs/tomsfastmath.m4 b/m4/reorganization/libs/tomsfastmath.m4
+new file mode 100644
+index 000000000..2a821a14d
+--- /dev/null
++++ b/m4/reorganization/libs/tomsfastmath.m4
+@@ -0,0 +1,12 @@
++dnl Check for system tomsfastmath
++PKG_CHECK_MODULES([TOMSFASTMATH], [tomsfastmath], [have_system_tomsfastmath=yes], [have_system_tomsfastmath=no])
++
++AM_CONDITIONAL([SYSTEM_TOMSFASTMATH], [test "x$have_system_tomsfastmath" = "xyes"])
++
++if test "x$have_system_tomsfastmath" = "xyes"; then
++ AC_DEFINE([HAVE_SYSTEM_TOMSFASTMATH], [1], [link against system-wide tomsfastmath library])
++ tomsfastmath_msg="External, $TOMSFASTMATH_CFLAGS $TOMSFASTMATH_LIBS"
++else
++ AC_DEFINE([HAVE_SYSTEM_TOMSFASTMATH], [0], [don't link against system-wide tomsfastmath library])
++ tomsfastmath_msg="Internal"
++fi
+--
+2.26.2
+
diff --git a/app-antivirus/clamav/files/clamav-0.103.0-upstream-openrc.patch b/app-antivirus/clamav/files/clamav-0.103.0-upstream-openrc.patch
new file mode 100644
index 000000000000..a7676f0ab82a
--- /dev/null
+++ b/app-antivirus/clamav/files/clamav-0.103.0-upstream-openrc.patch
@@ -0,0 +1,439 @@
+diff --git a/Makefile.am b/Makefile.am
+index 12e7fcc28..a3c47e23a 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -52,6 +52,17 @@ nodist_include_HEADERS = clamav-types.h clamav-version.h
+ distuninstallcheck_listfiles = find . -type f ! -name clamd.conf ! -name freshclam.conf ! -name daily.cvd ! -name main.cvd -print
+ DISTCLEANFILES = target.h
+ DISTCHECK_CONFIGURE_FLAGS=--enable-milter --disable-clamav --enable-all-jit-targets --enable-llvm=yes --with-system-llvm=no --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir) CC="$(CC)" CXX="$(CXX)" YACC="$(YACC)" LEX="$(LEX)" AR="$(AR)" AS="$(AS)"
++
++
++# This command allows us to replace bindir, libdir, etc.
++# within our script and conf file. The example is taken
++# from the autoconf documentation and can be found in the
++# "Installation Directory Variables" section.
++editgnudirs = sed -e 's|@BINDIR[@]|$(bindir)|g' \
++ -e 's|@SBINDIR[@]|$(sbindir)|g' \
++ -e 's|@RUNSTATEDIR[@]|$(runstatedir)|g'
++export editgnudirs
++
+ lcov:
+ ($(MAKE); cd unit_tests; $(MAKE) lcov)
+ quick-check:
+diff --git a/clamav-milter/Makefile.am b/clamav-milter/Makefile.am
+index 1ec4afff6..c75c2b4a3 100644
+--- a/clamav-milter/Makefile.am
++++ b/clamav-milter/Makefile.am
+@@ -35,6 +35,27 @@ clamav_milter_SOURCES = \
+ man_MANS = $(top_builddir)/docs/man/clamav-milter.8
+ AM_CFLAGS=@WERR_CFLAGS_MILTER@
+
++
++if INSTALL_OPENRC_SERVICES
++
++openrcdir = $(sysconfdir)/init.d
++
++# The next rule allows us to replace @RUNSTATEDIR@ and friends within
++# our OpenRC service scripts. This example is taken from the autoconf
++# documentation in the "Installation Directory Variables" section.
++openrc_SCRIPTS_src = openrc/clamav-milter.in.in
++openrc_SCRIPTS_intermediate = openrc/clamav-milter.in
++nodist_openrc_SCRIPTS = openrc/clamav-milter
++DISTCLEANFILES = $(nodist_openrc_SCRIPTS) $(openrc_SCRIPTS_intermediate)
++$(nodist_openrc_SCRIPTS): $(openrc_SCRIPTS_src) $(openrc_SCRIPTS_intermediate) Makefile
++ rm -f $@ $@.tmp
++ $(editgnudirs) $@.in > $@.tmp
++ mv $@.tmp $@
++
++endif
++EXTRA_DIST = $(openrc_SCRIPTS_src)
++
++
+ endif
+
+ LIBS = $(top_builddir)/libclamav/libclamav.la $(top_builddir)/shared/libshared.la @CLAMAV_MILTER_LIBS@ @THREAD_LIBS@
+diff --git a/clamav-milter/openrc/clamav-milter.in.in b/clamav-milter/openrc/clamav-milter.in.in
+new file mode 100644
+index 000000000..71053564a
+--- /dev/null
++++ b/clamav-milter/openrc/clamav-milter.in.in
+@@ -0,0 +1,34 @@
++#!/sbin/openrc-run
++
++# Note: the "Foreground" option in clamav-milter.conf MUST
++# be set to "no".
++command="@SBINDIR@/clamav-milter"
++
++# For now, must be manually synchronized with the PidFile
++# variable in clamav-milter.conf.
++#
++# https://bugzilla.clamav.net/show_bug.cgi?id=12595
++#
++pidfile="@RUNSTATEDIR@/${RC_SVCNAME}.pid"
++
++depend() {
++ # The milter can successfully launch without clamd, but it's not a
++ # great user experience to have the milter start accepting requests
++ # that it can't process. The "use" dependency below will start clamd
++ # before clamav-milter, so long as clamd is also present this runlevel.
++ use clamd
++}
++
++start_pre() {
++ # This exists to support the (disabled) default MilterSocket setting
++ # within clamav-milter.conf. The "clamav" user and group agree with
++ # the (disabled) default "User" and "MilterSocketGroup" settings.
++ #
++ # Creating this directory is harmless even when a local socket is
++ # not used. In fact, the clamd service that we depend on should
++ # create it as well, to hold its own local socket (if enabled).
++ checkpath --directory \
++ --mode 0755 \
++ --owner clamav:clamav \
++ "@RUNSTATEDIR@/clamav"
++}
+diff --git a/clamd/Makefile.am b/clamd/Makefile.am
+index 12b872b1f..725bc2fc1 100644
+--- a/clamd/Makefile.am
++++ b/clamd/Makefile.am
+@@ -44,6 +44,25 @@ if INSTALL_SYSTEMD_UNITS
+ systemdsystemunit_DATA = clamav-daemon.socket clamav-daemon.service
+ endif
+
++if INSTALL_OPENRC_SERVICES
++
++openrcdir = $(sysconfdir)/init.d
++
++# The next rule allows us to replace @RUNSTATEDIR@ and friends within
++# our OpenRC service scripts. This example is taken from the autoconf
++# documentation in the "Installation Directory Variables" section.
++openrc_SCRIPTS_src = openrc/clamd.in.in
++openrc_SCRIPTS_intermediate = openrc/clamd.in
++nodist_openrc_SCRIPTS = openrc/clamd
++DISTCLEANFILES = $(nodist_openrc_SCRIPTS) $(openrc_SCRIPTS_intermediate)
++$(nodist_openrc_SCRIPTS): $(openrc_SCRIPTS_src) $(openrc_SCRIPTS_intermediate) Makefile
++ rm -f $@ $@.tmp
++ $(editgnudirs) $@.in > $@.tmp
++ mv $@.tmp $@
++
++endif
++EXTRA_DIST = $(openrc_SCRIPTS_src)
++
+ LIBS = $(top_builddir)/libclamav/libclamav.la $(top_builddir)/shared/libshared.la @CLAMD_LIBS@ @THREAD_LIBS@
+ AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav -I$(top_builddir)/libclamav -I$(top_srcdir)/libclamunrar_iface @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@
+
+diff --git a/clamd/openrc/clamd.in.in b/clamd/openrc/clamd.in.in
+new file mode 100644
+index 000000000..5d38f9a84
+--- /dev/null
++++ b/clamd/openrc/clamd.in.in
+@@ -0,0 +1,33 @@
++#!/sbin/openrc-run
++
++# Note: the "Foreground" option in clamd.conf must be set to "no"
++command="@SBINDIR@/clamd"
++extra_started_commands="reload"
++
++# For now, must be manually synchronized with the PidFile variable
++# in clamd.conf.
++#
++# https://bugzilla.clamav.net/show_bug.cgi?id=12595
++#
++pidfile="@RUNSTATEDIR@/${RC_SVCNAME}.pid"
++
++start_pre() {
++ # This exists to support the (disabled) default LocalSocket setting
++ # within clamd.conf. The "clamav" user and group agree with the
++ # (disabled) default "User" and "LocalSocketGroup" settings in
++ # clamd.conf. And everything here agrees with the
++ # clamav-daemon.socket systemd service.
++ #
++ # Creating this directory is harmless even when a local socket is
++ # not used.
++ checkpath --directory \
++ --mode 0755 \
++ --owner clamav:clamav \
++ "@RUNSTATEDIR@/clamav"
++}
++
++reload() {
++ ebegin "Reloading ${RC_SVCNAME}"
++ "@BINDIR@/clamdscan" --reload
++ eend $?
++}
+diff --git a/clamonacc/Makefile.am b/clamonacc/Makefile.am
+index 181e22056..864a7fc2a 100644
+--- a/clamonacc/Makefile.am
++++ b/clamonacc/Makefile.am
+@@ -56,6 +56,25 @@ if INSTALL_SYSTEMD_UNITS
+ systemdsystemunit_DATA = clamav-clamonacc.service
+ endif
+
++if INSTALL_OPENRC_SERVICES
++
++openrcdir = $(sysconfdir)/init.d
++
++# The next rules allow us to replace @RUNSTATEDIR@ and friends within
++# our OpenRC service scripts. This example is taken from the autoconf
++# documentation in the "Installation Directory Variables" section.
++openrc_SCRIPTS_src = openrc/clamonacc.in.in
++openrc_SCRIPTS_intermediate = openrc/clamonacc.in
++nodist_openrc_SCRIPTS = openrc/clamonacc
++DISTCLEANFILES = $(nodist_openrc_SCRIPTS) $(openrc_SCRIPTS_intermediate)
++$(nodist_openrc_SCRIPTS): $(openrc_SCRIPTS_src) $(openrc_SCRIPTS_intermediate) Makefile
++ rm -f $@ $@.tmp
++ $(editgnudirs) $@.in > $@.tmp
++ mv $@.tmp $@
++
++endif
++EXTRA_DIST = $(openrc_SCRIPTS_src)
++
+ LIBS = $(top_builddir)/shared/libshared.la $(top_builddir)/libclamav/libclamav.la @CURL_LIBS@ @CLAMONACC_LIBS@ @THREAD_LIBS@
+ AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/clamonacc -I$(top_srcdir)/shared -I$(top_srcdir)/clamd -I$(top_srcdir)/libclamav -I$(top_builddir)/libclamav -I$(top_srcdir)/libclamunrar_iface @CURL_CPPFLAGS@ @SSL_CPPFLAGS@ @CLAMONACC_CPPFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@
+
+diff --git a/clamonacc/openrc/clamonacc.in.in b/clamonacc/openrc/clamonacc.in.in
+new file mode 100644
+index 000000000..844cd49dd
+--- /dev/null
++++ b/clamonacc/openrc/clamonacc.in.in
+@@ -0,0 +1,18 @@
++#!/sbin/openrc-run
++
++command="@SBINDIR@/clamonacc"
++pidfile="@RUNSTATEDIR@/${RC_SVCNAME}.pid"
++
++# clamonacc doesn't support a PID file at the moment, so we
++# run it in the foreground and let OpenRC background it.
++#
++# https://bugzilla.clamav.net/show_bug.cgi?id=12595
++#
++command_args="--foreground"
++command_background=true
++
++depend() {
++ # Unlike the milter, the on-access scanner will simply fail to start
++ # until clamd is available.
++ need clamd
++}
+diff --git a/configure.ac b/configure.ac
+index 7b2a777d4..8e0e810f8 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -79,6 +79,12 @@ if test "$enable_experimental" = "yes"; then
+ VERSION_SUFFIX="$VERSION_SUFFIX-exp"
+ fi
+
++# Autoconf 2.70 will support this, and many distros patch it in,
++# but Autoconf 2.70 hasn't actually been released yet (it's in beta).
++AS_IF([test -z "${runstatedir}"], [runstatedir='${localstatedir}/run'])
++AC_SUBST([runstatedir])
++
++
+ build_configure_args=`echo "$ac_configure_args" | sed -e 's/[\"]//g'`
+ AC_SUBST([BUILD_CONFIGURE_FLAGS], [$build_configure_args])
+
+@@ -104,6 +110,7 @@ m4_include([m4/reorganization/libs/libz.m4])
+ m4_include([m4/reorganization/libs/bzip.m4])
+ m4_include([m4/reorganization/libs/unrar.m4])
+ m4_include([m4/reorganization/libs/systemd.m4])
++m4_include([m4/reorganization/libs/openrc.m4])
+ m4_include([m4/reorganization/code_checks/ipv6.m4])
+ m4_include([m4/reorganization/code_checks/dns.m4])
+ m4_include([m4/reorganization/code_checks/fanotify.m4])
+@@ -192,7 +199,10 @@ AC_CONFIG_FILES([
+ libclamav.pc
+ platform.h
+ clamav-types.h
+- clamav-version.h])
++ clamav-version.h
++ etc/clamd.conf.sample.in
++ etc/clamav-milter.conf.sample.in
++ etc/freshclam.conf.sample.in])
+ if test "x$enable_libclamav_only" != "xyes"; then
+ AC_CONFIG_FILES([
+ clamscan/Makefile
+@@ -202,10 +212,14 @@ if test "x$enable_libclamav_only" != "xyes"; then
+ clamd/Makefile
+ clamd/clamav-daemon.service
+ clamd/clamav-daemon.socket
++ clamd/openrc/clamd.in
+ clamdscan/Makefile
+ clamsubmit/Makefile
++ clamonacc/openrc/clamonacc.in
+ clamav-milter/Makefile
++ clamav-milter/openrc/clamav-milter.in
+ freshclam/clamav-freshclam.service
++ freshclam/openrc/freshclam.in
+ freshclam/Makefile
+ sigtool/Makefile
+ clamconf/Makefile
+diff --git a/etc/Makefile.am b/etc/Makefile.am
+index 487c31429..bee68f1d0 100644
+--- a/etc/Makefile.am
++++ b/etc/Makefile.am
+@@ -18,11 +18,31 @@
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ # MA 02110-1301, USA.
+
+-EXTRA_DIST = clamd.conf.sample freshclam.conf.sample clamav-milter.conf.sample
++EXTRA_DIST = clamd.conf.sample.in.in \
++ freshclam.conf.sample.in.in \
++ clamav-milter.conf.sample.in.in
+ CFGINST = @CFGDIR@
+
+ sysconf_DATA = clamd.conf.sample freshclam.conf.sample
+
++# Custom variable to simplify the "edit" rule below.
++sysconf_DATA_intermediate = clamd.conf.sample.in freshclam.conf.sample.in
++
+ if HAVE_MILTER
+ sysconf_DATA += clamav-milter.conf.sample
++sysconf_DATA_intermediate += clamav-milter.conf.sample.in
+ endif
++
++# Otherwise these don't get cleaned up by "make distclean",
++# even though they are auto-generated.
++DISTCLEANFILES = $(sysconf_DATA) $(sysconf_DATA_intermediate)
++
++# This rule includes EVERY source/intermediate file as a dependency of
++# EVERY output file, which is clearly wrong, but it may be the best we
++# can do without duplication. At least it's the right kind of wrong,
++# and rebuilds too often rather than not often enough.
++$(sysconf_DATA): $(sysconf_DATA_intermediate) $(EXTRA_DIST) Makefile
++ rm -f $@ $@.tmp
++ $(editgnudirs) $@.in > $@.tmp
++ mv $@.tmp $@
++>>>>>>> ea2f2442b... etc: convert conf files to templates and make @VARIABLE@ substitutions.
+diff --git a/etc/clamav-milter.conf.sample b/etc/clamav-milter.conf.sample.in.in
+similarity index 98%
+rename from etc/clamav-milter.conf.sample
+rename to etc/clamav-milter.conf.sample.in.in
+index bf46b4fc5..c3c5d2000 100644
+--- a/etc/clamav-milter.conf.sample
++++ b/etc/clamav-milter.conf.sample.in.in
+@@ -17,7 +17,7 @@ Example
+ # inet6:port@[hostname|ip-address] - to specify an ipv6 socket
+ #
+ # Default: no default
+-#MilterSocket /tmp/clamav-milter.socket
++#MilterSocket unix:@RUNSTATEDIR@/clamav/clamav-milter.socket
+ #MilterSocket inet:7357
+
+ # Define the group ownership for the (unix) milter socket.
+@@ -64,7 +64,7 @@ Example
+ # also owned by root to keep other users from tampering with it.
+ #
+ # Default: disabled
+-#PidFile /var/run/clamav-milter.pid
++#PidFile @RUNSTATEDIR@/clamav-milter.pid
+
+ # Optional path to the global temporary directory.
+ # Default: system specific (usually /tmp or /var/tmp).
+@@ -91,6 +91,7 @@ Example
+ # fashion.
+ #
+ # Default: no default
++#ClamdSocket unix:@RUNSTATEDIR@/clamav/clamd.ctl
+ #ClamdSocket tcp:scanner.mydomain:7357
+
+
+diff --git a/etc/clamd.conf.sample b/etc/clamd.conf.sample.in.in
+similarity index 99%
+rename from etc/clamd.conf.sample
+rename to etc/clamd.conf.sample.in.in
+index 828dd5ad9..0e0ea4b12 100644
+--- a/etc/clamd.conf.sample
++++ b/etc/clamd.conf.sample.in.in
+@@ -74,7 +74,7 @@ Example
+ # It is recommended that the directory where this file is stored is
+ # also owned by root to keep other users from tampering with it.
+ # Default: disabled
+-#PidFile /var/run/clamd.pid
++#PidFile @RUNSTATEDIR@/clamd.pid
+
+ # Optional path to the global temporary directory.
+ # Default: system specific (usually /tmp or /var/tmp).
+@@ -93,7 +93,7 @@ Example
+
+ # Path to a local socket file the daemon will listen on.
+ # Default: disabled (must be specified by a user)
+-#LocalSocket /tmp/clamd.socket
++#LocalSocket @RUNSTATEDIR@/clamav/clamd.ctl
+
+ # Sets the group ownership on the unix socket.
+ # Default: disabled (the primary group of the user running clamd)
+diff --git a/etc/freshclam.conf.sample b/etc/freshclam.conf.sample.in.in
+similarity index 99%
+rename from etc/freshclam.conf.sample
+rename to etc/freshclam.conf.sample.in.in
+index 2f7d14618..3af3a3485 100644
+--- a/etc/freshclam.conf.sample
++++ b/etc/freshclam.conf.sample.in.in
+@@ -51,7 +51,7 @@ Example
+ # It is recommended that the directory where this file is stored is
+ # also owned by root to keep other users from tampering with it.
+ # Default: disabled
+-#PidFile /var/run/freshclam.pid
++#PidFile @RUNSTATEDIR@/freshclam.pid
+
+ # By default when started freshclam drops privileges and switches to the
+ # "clamav" user. This directive allows you to change the database owner.
+diff --git a/freshclam/Makefile.am b/freshclam/Makefile.am
+index ab6ac8f1c..6b16b3d3e 100644
+--- a/freshclam/Makefile.am
++++ b/freshclam/Makefile.am
+@@ -32,6 +32,26 @@ if INSTALL_SYSTEMD_UNITS
+ systemdsystemunit_DATA = clamav-freshclam.service
+ endif
+
++if INSTALL_OPENRC_SERVICES
++
++openrcdir = $(sysconfdir)/init.d
++
++# The next rule allows us to replace @RUNSTATEDIR@ and friends within
++# our OpenRC service scripts. This example is taken from the autoconf
++# documentation in the "Installation Directory Variables" section.
++openrc_SCRIPTS_src = openrc/freshclam.in.in
++openrc_SCRIPTS_intermediate = openrc/freshclam.in
++nodist_openrc_SCRIPTS = openrc/freshclam
++DISTCLEANFILES = $(nodist_openrc_SCRIPTS) $(openrc_SCRIPTS_intermediate)
++$(nodist_openrc_SCRIPTS): $(openrc_SCRIPTS_src) $(openrc_SCRIPTS_intermediate) Makefile
++ rm -f $@ $@.tmp
++ $(editgnudirs) $@.in > $@.tmp
++ mv $@.tmp $@
++
++endif
++EXTRA_DIST = $(openrc_SCRIPTS_src)
++
++
+ AM_CFLAGS=@WERR_CFLAGS@
+ DEFS = @DEFS@
+ AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav -I$(top_builddir)/libclamav -I$(top_srcdir)/libclamunrar_iface -I$(top_srcdir)/libfreshclam @CURL_CPPFLAGS@ @SSL_CPPFLAGS@ @FRESHCLAM_CPPFLAGS@ @ZLIB_CFLAGS@ @JSON_CPPFLAGS@ @PCRE_CPPFLAGS@
+diff --git a/freshclam/openrc/freshclam.in.in b/freshclam/openrc/freshclam.in.in
+new file mode 100644
+index 000000000..9feb73747
+--- /dev/null
++++ b/freshclam/openrc/freshclam.in.in
+@@ -0,0 +1,8 @@
++#!/sbin/openrc-run
++
++command="@BINDIR@/freshclam"
++pidfile="@RUNSTATEDIR@/${RC_SVCNAME}.pid"
++
++# Ignore the value of "PidFile" set in freshclam.conf.
++command_args="-p ${pidfile}"
++command_args_background="--daemon"
+diff --git a/m4/reorganization/libs/openrc.m4 b/m4/reorganization/libs/openrc.m4
+new file mode 100644
+index 000000000..1a73d1589
+--- /dev/null
++++ b/m4/reorganization/libs/openrc.m4
+@@ -0,0 +1,8 @@
++dnl Should we install our OpenRC service files?
++AC_ARG_ENABLE([openrc],
++ AS_HELP_STRING([--enable-openrc],
++ [Install OpenRC service files]),
++ [],
++ [enable_openrc=no])
++AM_CONDITIONAL(INSTALL_OPENRC_SERVICES,
++ [test "x$enable_openrc" = "xyes"])
diff --git a/app-antivirus/clamav/files/clamav-milter.logrotate b/app-antivirus/clamav/files/clamav-milter.logrotate
new file mode 100644
index 000000000000..24782df604b6
--- /dev/null
+++ b/app-antivirus/clamav/files/clamav-milter.logrotate
@@ -0,0 +1,25 @@
+# This script is intended to rotate the logs for clamav-milter in its
+# default configuration on Gentoo, where clamav-milter writes to its
+# own log file but does not rotate that file itself. The clamav-milter
+# daemon is capable of rotating its own logs; if you have "LogRotate
+# yes" in clamav-milter.conf then you do not need this script (and
+# should disable it). Likewise, if you are logging to syslog
+# (LogSyslog yes), this is redundant.
+#
+# This is more complicated than the clamd/freshclam scripts because
+# the milter doesn't yet reopen its log files when it receives a
+# SIGHUP. See https://bugzilla.clamav.net/show_bug.cgi?id=12615
+# for that. Instead we have to attempt OpenRC/systemd service
+# restarts on (only) the machines that support them.
+/var/log/clamav/clamav-milter.log {
+ su clamav clamav
+ missingok
+ postrotate
+ if command -v rc-service 2>/dev/null; then
+ rc-service clamav-milter status 2>/dev/null 1>&2 && rc-service clamav-milter restart 1>/dev/null
+ fi
+ if command -v systemctl 2>/dev/null; then
+ systemctl try-restart clamav-milter
+ fi
+ endscript
+}
diff --git a/app-antivirus/clamav/files/clamd.logrotate b/app-antivirus/clamav/files/clamd.logrotate
new file mode 100644
index 000000000000..68ee9b361668
--- /dev/null
+++ b/app-antivirus/clamav/files/clamd.logrotate
@@ -0,0 +1,17 @@
+# This script is intended to rotate the logs for clamd in its default
+# configuration on Gentoo, where clamd writes to its own log file but
+# does not rotate that file itself. The clamd daemon is capable of
+# rotating its own logs; if you have "LogRotate yes" in clamd.conf
+# then you do not need this script (and should disable it). Likewise,
+# if you are logging to syslog (LogSyslog yes), this is redundant.
+/var/log/clamav/clamd.log {
+ su clamav clamav
+ missingok
+ postrotate
+ if test -f /run/clamd.pid; then
+ /bin/kill -HUP $(cat /run/clamd.pid)
+ else
+ true
+ fi
+ endscript
+}
diff --git a/app-antivirus/clamav/files/freshclam.logrotate b/app-antivirus/clamav/files/freshclam.logrotate
new file mode 100644
index 000000000000..ba6b5de3ba1c
--- /dev/null
+++ b/app-antivirus/clamav/files/freshclam.logrotate
@@ -0,0 +1,17 @@
+# This script is intended to rotate the logs for freshclam in its default
+# configuration on Gentoo, where freshclam writes to its own log file but
+# does not rotate that file itself. The freshclam daemon is capable of
+# rotating its own logs; if you have "LogRotate yes" in freshclam.conf
+# then you do not need this script (and should disable it). Likewise,
+# if you are logging to syslog (LogSyslog yes), this is redundant.
+/var/log/clamav/freshclam.log {
+ su clamav clamav
+ missingok
+ postrotate
+ if test -f /run/freshclam.pid; then
+ /bin/kill -HUP $(cat /run/freshclam.pid)
+ else
+ true
+ fi
+ endscript
+}
diff --git a/app-antivirus/clamav/files/freshclamd.service-r1 b/app-antivirus/clamav/files/freshclamd.service-r1
new file mode 100644
index 000000000000..fa1e0139ddda
--- /dev/null
+++ b/app-antivirus/clamav/files/freshclamd.service-r1
@@ -0,0 +1,10 @@
+[Unit]
+Description=clamav updater
+
+[Service]
+Type=forking
+PIDFile=/run/freshclam.pid
+ExecStart=/usr/bin/freshclam -d -p /run/freshclam.pid
+
+[Install]
+WantedBy=multi-user.target