From cc4bb035e088be5f70b558b9b334abc8c9cb338f Mon Sep 17 00:00:00 2001 From: Yalla-One Date: Tue, 11 May 2010 20:01:55 +0200 Subject: system/clamav: Added to 12.0 repository --- system/clamav/README | 58 +++++++++++++ system/clamav/clamav.SlackBuild | 163 +++++++++++++++++++++++++++++++++++++ system/clamav/clamav.info | 8 ++ system/clamav/clamd.conf.patch | 67 +++++++++++++++ system/clamav/doinst.sh | 81 ++++++++++++++++++ system/clamav/freshclam.conf.patch | 66 +++++++++++++++ system/clamav/rc.clamav | 58 +++++++++++++ system/clamav/slack-desc | 19 +++++ 8 files changed, 520 insertions(+) create mode 100644 system/clamav/README create mode 100644 system/clamav/clamav.SlackBuild create mode 100644 system/clamav/clamav.info create mode 100644 system/clamav/clamd.conf.patch create mode 100644 system/clamav/doinst.sh create mode 100644 system/clamav/freshclam.conf.patch create mode 100644 system/clamav/rc.clamav create mode 100644 system/clamav/slack-desc (limited to 'system') diff --git a/system/clamav/README b/system/clamav/README new file mode 100644 index 0000000000..67a4f9c5a9 --- /dev/null +++ b/system/clamav/README @@ -0,0 +1,58 @@ +Clam AntiVirus is a GPL anti-virus toolkit for UNIX. The main purpose +of this software is the integration with mail servers (attachment +scanning). The package provides a flexible and scalable multi-threaded +daemon, a command line scanner, and a tool for automatic updating via +Internet. + +This build script should build a package that "just works" after install. +You will need to specify a two-letter country code (such as "us") as an +argument to the COUNTRY variable when running the build script (this will +default to "us" if nothing is specified). For example: + COUNTRY=nl ./clamav.SlackBuild + +The package contains a start/stop script: /etc/rc.d/rc.clamav. +I would suggest calling this script from /etc/rc.d/rc.M just +before Sendmail is started with code like: + +# Starting ClamAV daemons +if [ -x /etc/rc.d/rc.clamav ]; then + /etc/rc.d/rc.clamav start +fi + +The start/stop script will start: clamd, freshclam and clamav-milter. + +** ClamAV, Amavisd-new and SpamAssassin ** +You might want to use amavisd-new to act as an intermediary between Sendmail +and ClamAV (and possible SpamAssassin too). Amavisd-new can be downloaded at +http://www.ijs.si/software/amavisd/ + +For clamd to be able to scan messages, when called by Amavisd-new, you must +add "clamav" to the "amavis" group (provided that clamd.conf contains the +"User clamav" directive), e.g. run: + + # usermod -G $(id -Gn clamav | tr ' ' ','),amavis clamav + +Be sure to enable "AllowSupplementaryGroups" in clamd.conf and restart clamd. +Also, to enable Amavisd-new to scan ClamAV's log files and produce nice +statistics, the reverse must be done too; add user "amavis" to the group +"clamav" as follows: + + # usermod -G $(id -Gn amavis | tr ' ' ','),clamav amavis + +Add the rc.amavisd script to your /etc/rc.d/rc.M script between the start of +clamav and sendmail, so that the relevant section looks like this: + +# Starting ClamAV daemon: +if [ -x /etc/rc.d/rc.clamav ]; then + /etc/rc.d/rc.clamav start +fi + +# Starting Amavisd daemon: +if [ -x /etc/rc.d/rc.amavisd ]; then + /etc/rc.d/rc.amavisd start +fi + +# Start the sendmail daemon: +if [ -x /etc/rc.d/rc.sendmail ]; then + . /etc/rc.d/rc.sendmail start +fi diff --git a/system/clamav/clamav.SlackBuild b/system/clamav/clamav.SlackBuild new file mode 100644 index 0000000000..828ba1a78b --- /dev/null +++ b/system/clamav/clamav.SlackBuild @@ -0,0 +1,163 @@ +#!/bin/sh +# Copyright (c) 2006,2007 Eric Hameleers +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ----------------------------------------------------------------------------- + +# Modified to SBo format with the help of Yalla-One +# Version bump and various other changes by Robby Workman +# No additional license terms added + +PRGNAM=clamav +VERSION=0.91.2 +ARCH=${ARCH:-i486} +BUILD=${BUILD:-1} +TAG=${TAG:-_SBo} +CWD=$(pwd) +TMP=${TMP:-/tmp/SBo} +PKG="$TMP/package-$PRGNAM" +OUTPUT=${OUTPUT:-/tmp} + +# Two letter country code +# See http://www.iana.org/cctld/cctld-whois.htm for options +COUNTRY=${COUNTRY:-us} + +# Read "README.slackware" for compatibility with amavisd-new +CLAMUSR=${CLAMUSR:-clamav} +CLAMGRP=${CLAMGRP:-clamav} +CLAMUID=${CLAMUID:-210} +CLAMGID=${CLAMGID:-210} + +if [ "$ARCH" = "i486" ]; then + SLKCFLAGS="-O2 -march=i486 -mtune=i686" +elif [ "$ARCH" = "i686" ]; then + SLKCFLAGS="-O2 -march=i686 -mtune=i686" +fi + +# Check for ClamAV user and group availability +DO_EXIT=0 +if ! grep ^${CLAMGRP}: /etc/group 2>&1 > /dev/null; then + cat << EOF + + You must have a ${CLAMGRP} group to run this script. + # groupadd -g ${CLAMGID} ${CLAMGRP} + +EOF + DO_EXIT=1 +elif ! grep ^${CLAMUSR}: /etc/passwd 2>&1 > /dev/null; then + cat << EOF + + Must have a ${CLAMUSR} user to run this script. + # useradd -u ${CLAMUID} -d /dev/null -s /bin/false -g ${CLAMGRP} ${CLAMUSR} + +EOF + DO_EXIT=1 +fi +[ $DO_EXIT -eq 1 ] && exit + +rm -rf $PKG +mkdir -p $TMP $PKG $OUTPUT +cd $TMP || exit 1 +rm -rf $PRGNAM-$VERSION +tar xvf $CWD/$PRGNAM-$VERSION.tar.gz || exit 1 +cd $PRGNAM-$VERSION || exit 1 +chown -R root:root . +chmod -R u+w,go+r-w,a-s . + +CFLAGS="$SLKCFLAGS" \ +CXXFLAGS="$SLKCFLAGS" \ +LDFLAGS="$SLKLDFLAGS" \ +./configure \ + --prefix=/usr \ + --libdir=/usr/lib \ + --localstatedir=/var \ + --sysconfdir=/etc \ + --mandir=/usr/man \ + --with-user=${CLAMUSR} \ + --with-group=${CLAMGRP} \ + --with-dbdir=/usr/share/clamav \ + --with-libcurl \ + --with-tcpwrappers \ + --enable-milter \ + --enable-id-check \ + --disable-static + +make || exit 1 + +# Patch the configuration files +cd etc +patch < $CWD/clamd.conf.patch +patch < $CWD/freshclam.conf.patch +cd - + +make install DESTDIR=$PKG || exit 1 + +# Prepare the config files: +cd $PKG/etc +mv clamd.conf clamd.conf.new +mv freshclam.conf freshclam.conf.new +cd - + +# Specify the desired mirror in the update config file +# http://www.iana.org/cctld/cctld-whois.htm +sed -i "s/COUNTRY/$COUNTRY/g" $PKG/etc/freshclam.conf.new + +# Where to store the pid file: +mkdir -p $PKG/var/run/clamav + +# Our rc script: +mkdir -p $PKG/etc/rc.d/ +cp $CWD/rc.clamav $PKG/etc/rc.d/rc.clamav.new +chown root:root $PKG/etc/rc.d/rc.clamav.new +chmod 754 $PKG/etc/rc.d/rc.clamav.new + +cp $CWD/README README.slackware +cp -a clamav-milter/INSTALL INSTALL.milter +DOCS="AUTHORS BUGS COPYING ChangeLog FAQ INSTALL NEWS README UPGRADE \ + docs/*.pdf docs/html examples INSTALL.milter README.slackware" + +mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION +cp -a $DOCS $PKG/usr/doc/$PRGNAM-$VERSION || true +chmod -R a-w $PKG/usr/doc/$PRGNAM-$VERSION/* + +# Compress the man page(s) +find $PKG/usr/man -type f -name "*.?" -exec gzip -9f {} \; + +# Strip binaries +( cd $PKG + find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null + find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null +) + +# Ownership, rights: +chown -R root:root $PKG +chmod -R o-w $PKG + +mkdir -p $PKG/install +cat $CWD/slack-desc > $PKG/install/slack-desc +cat $CWD/doinst.sh >> $PKG/install/doinst.sh + +# Substitute in the actual user/group parameters used +sed -i s/_SUB_CLAMUSR/$CLAMUSR/ $PKG/install/doinst.sh +sed -i s/_SUB_CLAMGRP/$CLAMGRP/ $PKG/install/doinst.sh +sed -i s/_SUB_CLAMUID/$CLAMUID/ $PKG/install/doinst.sh +sed -i s/_SUB_CLAMGID/$CLAMGID/ $PKG/install/doinst.sh + +cd $PKG +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.tgz diff --git a/system/clamav/clamav.info b/system/clamav/clamav.info new file mode 100644 index 0000000000..94f6db19e6 --- /dev/null +++ b/system/clamav/clamav.info @@ -0,0 +1,8 @@ +PRGNAM="clamav" +VERSION="0.91.2" +HOMEPAGE="http://www.clamav.net/" +DOWNLOAD="http://downloads.sourceforge.net/clamav/clamav-0.91.2.tar.gz" +MD5SUM="2a7265d17cfa80c32858978f16a3f47b" +MAINTAINER="Yalla-One" +EMAIL="yallaone@gmail.com" +APPROVED="BP{k}" diff --git a/system/clamav/clamd.conf.patch b/system/clamav/clamd.conf.patch new file mode 100644 index 0000000000..607f18259d --- /dev/null +++ b/system/clamav/clamd.conf.patch @@ -0,0 +1,67 @@ +--- clamd.conf.orig 2007-07-24 11:22:34.000000000 +0200 ++++ clamd.conf 2007-07-24 11:29:08.000000000 +0200 +@@ -5,7 +5,7 @@ + + + # Comment or remove the line below. +-Example ++#Example + + # Uncomment this option to enable logging. + # LogFile must be writable for the user running daemon. +@@ -40,12 +40,12 @@ + + # Use system logger (can work together with LogFile). + # Default: no +-#LogSyslog yes ++LogSyslog yes + + # Specify the type of syslog messages - please refer to 'man syslog' + # for facility names. + # Default: LOG_LOCAL6 +-#LogFacility LOG_MAIL ++LogFacility LOG_MAIL + + # Enable verbose logging. + # Default: no +@@ -54,7 +54,7 @@ + # This option allows you to save a process identifier of the listening + # daemon (main thread). + # Default: disabled +-#PidFile /var/run/clamd.pid ++PidFile /var/run/clamav/clamd.pid + + # Optional path to the global temporary directory. + # Default: system specific (usually /tmp or /var/tmp). +@@ -69,11 +69,11 @@ + + # Path to a local socket file the daemon will listen on. + # Default: disabled (must be specified by a user) +-LocalSocket /tmp/clamd.socket ++LocalSocket /var/run/clamav/clamd.socket + + # Remove stale socket after unclean shutdown. + # Default: no +-#FixStaleSocket yes ++FixStaleSocket yes + + # TCP port address. + # Default: no +@@ -142,14 +142,14 @@ + # Run as another user (clamd must be started by root to make this option + # working). + # Default: don't drop privileges +-#User clamav ++User clamav + + # Initialize supplementary group access (clamd must be started by root). + # Default: no +-#AllowSupplementaryGroups no ++AllowSupplementaryGroups yes + + # Stop daemon when libclamav reports out of memory condition. +-#ExitOnOOM yes ++ExitOnOOM yes + + # Don't fork into background. + # Default: no diff --git a/system/clamav/doinst.sh b/system/clamav/doinst.sh new file mode 100644 index 0000000000..0764576fed --- /dev/null +++ b/system/clamav/doinst.sh @@ -0,0 +1,81 @@ +# Read "README.slackware" for compatibility with amavisd-new + +# These values are set in the build script and sed'ed into this +CLAMUSR=_SUB_CLAMUSR +CLAMGRP=_SUB_CLAMGRP +CLAMUID=_SUB_CLAMUID +CLAMGID=_SUB_CLAMGID + +# Handle the incoming configuration files: +config() { + for infile in $1; do + NEW="$infile" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + # If there's no config file by that name, mv it over: + if [ ! -r $OLD ]; then + mv $NEW $OLD + elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then + # toss the redundant copy + rm $NEW + fi + # Otherwise, we leave the .new copy for the admin to consider... + done +} + +config etc/freshclam.conf.new +config etc/clamd.conf.new +config etc/rc.d/rc.clamav.new + +# Create log files +# We don't do this inside the package because we don't want the package +# to remove them if clamav is uninstalled +touch var/log/clamd.log +touch var/log/freshclam.log + +# Check for presence of $CLAMUSR and $CLAMGRP on target system +DO_EXIT=0 +if ! grep ^${CLAMGRP}: etc/group 2>&1 > /dev/null; then + cat << EOF + + You must have a ${CLAMGRP} group present for this post-installation + script to complete. First, do this: + + # groupadd -g ${CLAMGID} ${CLAMGRP} + + Then, do *one* of the following: + (1) Run "upgradepkg --reinstall clamav-*tgz" or + (2) Change to the directory '/' (using "cd /") and run the script /var/log/scripts/clamav-* manually. +EOF + DO_EXIT=1 +elif ! grep ^${CLAMUSR}: etc/passwd 2>&1 > /dev/null; then + cat << EOF + + You must have a ${CLAMUSR} user present for this post-installation + script to complete. First, do this: + + # useradd -u ${CLAMUID} -d /dev/null -s /bin/false -g ${CLAMGRP} ${CLAMUSR} + + Then, do *one* of the following: + (1) Run "upgradepkg --reinstall clamav-*tgz" or + (2) Change to the directory '/' (using "cd /") and run the script /var/log/scripts/clamav-* manually. +EOF + DO_EXIT=1 +fi +[ $DO_EXIT -eq 1 ] && exit +# Only way to create and use the correct uid and gid on the target system, +# is to use chroot: +chroot . </dev/null + +# Restore the correct permissions +chown ${CLAMUSR} usr/sbin/clamav-milter +chmod 4700 usr/sbin/clamav-milter +chown -R ${CLAMUSR}:${CLAMGRP} var/run/clamav +chmod 771 var/run/clamav +chown ${CLAMUSR}:${CLAMGRP} var/log/clamd.log +chmod 660 var/log/clamd.log +chown ${CLAMUSR}:${CLAMGRP} var/log/freshclam.log +chmod 660 var/log/freshclam.log +chown -R ${CLAMUSR}:${CLAMGRP} usr/share/clamav +chmod -R 770 usr/share/clamav +EOR + diff --git a/system/clamav/freshclam.conf.patch b/system/clamav/freshclam.conf.patch new file mode 100644 index 0000000000..c90a961940 --- /dev/null +++ b/system/clamav/freshclam.conf.patch @@ -0,0 +1,66 @@ +--- freshclam.conf.orig 2007-02-11 10:54:46.000000000 +0100 ++++ freshclam.conf 2007-02-14 09:46:29.000000000 +0100 +@@ -5,12 +5,12 @@ + + + # Comment or remove the line below. +-Example ++#Example + + # Path to the database directory. + # WARNING: It must match clamd.conf's directive! + # Default: hardcoded (depends on installation options) +-#DatabaseDirectory /var/lib/clamav ++#DatabaseDirectory /usr/share/clamav + + # Path to the log file (make sure it has proper permissions) + # Default: disabled +@@ -22,25 +22,25 @@ + + # Use system logger (can work together with UpdateLogFile). + # Default: no +-#LogSyslog yes ++LogSyslog yes + + # Specify the type of syslog messages - please refer to 'man syslog' + # for facility names. + # Default: LOG_LOCAL6 +-#LogFacility LOG_MAIL ++LogFacility LOG_MAIL + + # This option allows you to save the process identifier of the daemon + # Default: disabled +-#PidFile /var/run/freshclam.pid ++PidFile /var/run/clamav/freshclam.pid + + # By default when started freshclam drops privileges and switches to the + # "clamav" user. This directive allows you to change the database owner. + # Default: clamav (may depend on installation options) +-#DatabaseOwner clamav ++DatabaseOwner clamav + + # Initialize supplementary group access (freshclam must be started by root). + # Default: no +-#AllowSupplementaryGroups yes ++AllowSupplementaryGroups yes + + # Use DNS to verify virus database version. Freshclam uses DNS TXT records + # to verify database and software versions. With this directive you can change +@@ -52,7 +52,7 @@ + + # Uncomment the following line and replace XY with your country + # code. See http://www.iana.org/cctld/cctld-whois.htm for the full list. +-#DatabaseMirror db.XY.clamav.net ++DatabaseMirror db.COUNTRY.clamav.net + + # database.clamav.net is a round-robin record which points to our most + # reliable mirrors. It's used as a fall back in case db.XY.clamav.net is +@@ -92,7 +92,7 @@ + + # Send the RELOAD command to clamd. + # Default: no +-#NotifyClamd /path/to/clamd.conf ++NotifyClamd /etc/clamd.conf + + # Run command after successful database update. + # Default: disabled diff --git a/system/clamav/rc.clamav b/system/clamav/rc.clamav new file mode 100644 index 0000000000..5197a1c4de --- /dev/null +++ b/system/clamav/rc.clamav @@ -0,0 +1,58 @@ +#!/bin/sh +# Start/stop/restart clamav. +# $Id: rc.clamav,v 1.1 2007/02/14 10:29:03 root Exp root $ +# Author: Eric Hameleers +# --------------------------------------------------------------------------- +# Slightly modified by Robby Workman +# to replace backticks ( s/`command`/$(command)/ ) + +# Set to '1' if you want milter support: +MILTER=0 + +# Start clamav: +clamav_start() { + if [ -x /usr/sbin/clamd ]; then + echo -n "Starting clamd daemon: /usr/sbin/clamd " + /usr/sbin/clamd + echo "." + # Give clamd a chance to create the socket + sleep 1 + echo -n "Starting freshclam daemon: /usr/bin/freshclam -d -l /var/log/freshclam.log " + /usr/bin/freshclam -d -l /var/log/freshclam.log + echo "." + if [ "$MILTER" == "1" ]; then + echo -n "Starting clamav-milter daemon: /usr/sbin/clamav-milter -dblo --max-children=2 local:/var/run/clamav/clmilter.sock " + /usr/sbin/clamav-milter -dblo --max-children=2 local:/var/run/clamav/clmilter.sock + echo "." + fi + fi +} + +# Stop clamav: +clamav_stop() { + kill $(cat /var/run/clamav/clamd.pid) + #killall freshclam + kill $(cat /var/run/clamav/freshclam.pid) + [ "$MILTER" == "1" ] && killall clamav-milter +} + +# Restart clamav: +clamav_restart() { + clamav_stop + sleep 1 + clamav_start +} + +case "$1" in +'start') + clamav_start + ;; +'stop') + clamav_stop + ;; +'restart') + clamav_restart + ;; +*) + echo "usage $0 start|stop|restart" +esac diff --git a/system/clamav/slack-desc b/system/clamav/slack-desc new file mode 100644 index 0000000000..c23acc2a4f --- /dev/null +++ b/system/clamav/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. Line +# up the first '|' above the ':' following the base package name, and the '|' +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':'. + + |-----handy-ruler------------------------------------------------------| +clamav: clamav (a GPL-ed virus scanner) +clamav: +clamav: Clam AntiVirus is a GPL anti-virus toolkit for UNIX. The main purpose +clamav: of this software is the integration with mail servers (attachment +clamav: scanning). The package provides a flexible and scalable multi-threaded +clamav: daemon, a command line scanner, and a tool for automatic updating via +clamav: Internet. +clamav: Most importantly, the virus database is kept up to date . +clamav: For setup, see README.slackware in the /usr/doc/clamav-* directory. +clamav: +clamav: clamav info at http://www.clamav.net/ -- cgit v1.2.3