From f7ff12a35788904140b2879f93cbd47eab9cd61d Mon Sep 17 00:00:00 2001 From: ms Date: Tue, 1 May 2007 22:04:01 +0000 Subject: [PATCH] Clamav-Fixes. Clamavctrl gebaut & Initscript geschrieben. git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@513 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8 --- config/rootfiles/packages/clamav | 2 ++ lfs/clamav | 1 + src/initscripts/init.d/clamav | 41 +++++++++++++++++++++++++++++ src/misc-progs/Makefile | 5 +++- src/misc-progs/clamavctrl.c | 44 ++++++++++++++++++++++++++++++++ 5 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 src/initscripts/init.d/clamav create mode 100644 src/misc-progs/clamavctrl.c diff --git a/config/rootfiles/packages/clamav b/config/rootfiles/packages/clamav index 73ce52f718..4e9b0aa10a 100644 --- a/config/rootfiles/packages/clamav +++ b/config/rootfiles/packages/clamav @@ -27,3 +27,5 @@ usr/share/clamav/main.cvd #var/ipfire/clamav var/ipfire/clamav/clamd.conf var/ipfire/clamav/freshclam.conf +etc/rc.d/init.d/clamav +/usr/local/bin/clamavctrl diff --git a/lfs/clamav b/lfs/clamav index af72c899cd..782e43a257 100644 --- a/lfs/clamav +++ b/lfs/clamav @@ -80,5 +80,6 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) cd $(DIR_APP) && ./configure --prefix=/usr --sysconfdir=/var/ipfire/clamav cd $(DIR_APP) && make $(MAKETUNING) cd $(DIR_APP) && make install + chown nobody.nobody /usr/share/clamav -R @rm -rf $(DIR_APP) @$(POSTBUILD) diff --git a/src/initscripts/init.d/clamav b/src/initscripts/init.d/clamav new file mode 100644 index 0000000000..b11b8b0c7b --- /dev/null +++ b/src/initscripts/init.d/clamav @@ -0,0 +1,41 @@ +#!/bin/sh +# Begin $rc_base/init.d/clamav + +. /etc/sysconfig/rc +. $rc_functions + +case "$1" in + start) + boot_mesg "Starting Clamav Definition Updater..." + loadproc /usr/bin/freshclam -d -c 10 + + boot_mesg "Starting Clamav Daemon..." + loadproc /usr/sbin/clamd + ;; + + stop) + boot_mesg "Stopping Clamav Definition Updater..." + killproc /usr/bin/freshclam + + boot_mesg "Stopping Clamav Daemon..." + killproc /usr/sbin/clamd + ;; + + restart) + $0 stop + sleep 1 + $0 start + ;; + + status) + statusproc /usr/sbin/clamd + statusproc /usr/bin/freshclam + ;; + + *) + echo "Usage: $0 {start|stop|restart|status}" + exit 1 + ;; +esac + +# End $rc_base/init.d/clamav diff --git a/src/misc-progs/Makefile b/src/misc-progs/Makefile index 3dd951e2f7..7302cffd7c 100644 --- a/src/misc-progs/Makefile +++ b/src/misc-progs/Makefile @@ -11,7 +11,7 @@ SUID_PROGS = setdmzholes setportfw setfilters setxtaccess \ restartsyslogd logwatch openvpnctrl timecheckctrl \ restartwireless getipstat qosctrl launch-ether-wake \ redctrl extrahdctrl sambactrl upnpctrl tripwirectrl \ - smartctrl + smartctrl clamavctrl install : all install -m 755 $(PROGS) /usr/local/bin @@ -61,6 +61,9 @@ tripwirectrl: tripwirectrl.c setuid.o ../install+setup/libsmooth/varval.o smartctrl: smartctrl.c setuid.o ../install+setup/libsmooth/varval.o $(COMPILE) -I../install+setup/libsmooth/ smartctrl.c setuid.o ../install+setup/libsmooth/varval.o -o $@ +clamavctrl: clamavctrl.c setuid.o ../install+setup/libsmooth/varval.o + $(COMPILE) -I../install+setup/libsmooth/ clamavctrl.c setuid.o ../install+setup/libsmooth/varval.o -o $@ + launch-ether-wake: launch-ether-wake.c setuid.o ../install+setup/libsmooth/varval.o $(COMPILE) -I../install+setup/libsmooth/ launch-ether-wake.c setuid.o ../install+setup/libsmooth/varval.o -o $@ diff --git a/src/misc-progs/clamavctrl.c b/src/misc-progs/clamavctrl.c new file mode 100644 index 0000000000..09f5398720 --- /dev/null +++ b/src/misc-progs/clamavctrl.c @@ -0,0 +1,44 @@ +/* This file is part of the IPFire Firewall. + * + * This program is distributed under the terms of the GNU General Public + * Licence. See the file COPYING for details. + * + */ + +#include +#include +#include +#include +#include +#include +#include "setuid.h" + +int main(int argc, char *argv[]) { + + if (!(initsetuid())) + exit(1); + + if (argc < 2) { + fprintf(stderr, "\nNo argument given.\n\nclamavctrl (start|stop|restart)\n\n"); + exit(1); + } + + if (strcmp(argv[1], "start") == 0) { + safe_system("/etc/rc.d/init.d/clamav start"); + } else if (strcmp(argv[1], "stop") == 0) { + safe_system("/etc/rc.d/init.d/clamav stop"); + } else if (strcmp(argv[1], "restart") == 0) { + safe_system("/etc/rc.d/init.d/clamav restart"); + } else if (strcmp(argv[1], "enable") == 0) { + safe_system("ln -fs ../init.d/clamav /etc/rc.d/rc3.d/S20clamav >/dev/null 2>&1"); + safe_system("ln -fs ../init.d/clamav /etc/rc.d/rc0.d/K80clamav >/dev/null 2>&1"); + safe_system("ln -fs ../init.d/clamav /etc/rc.d/rc6.d/K80clamav >/dev/null 2>&1"); + } else if (strcmp(argv[1], "disable") == 0) { + safe_system("rm -f /etc/rc.d/rc*.d/*clamav >/dev/null 2>&1"); + } else { + fprintf(stderr, "\nBad argument given.\n\nclamavctrl (start|stop|restart)\n\n"); + exit(1); + } + + return 0; +} -- 2.39.2