initial commit of file from CVS for smeserver-clamav on Mon 10 Jul 08:35:52 BST 2023

This commit is contained in:
Brian Read
2023-07-10 08:35:52 +01:00
parent bfd6d39c86
commit 8a58bd853d
142 changed files with 1456 additions and 2 deletions

18
root/sbin/clamdscan Normal file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
# wrapper for clamdscan to force the --fdpass parameter to avoir failure because of
# no permission to access
allargs=$@
toadd=" --fdpass "
#parse args
while [ "$#" -gt 0 ]; do
case "$1" in
--fdpass) toadd="" ;;
--stream) toadd="" ;;
esac
shift
done
#we return to systemd systemctl command unless this is one of the command we want to handle
/usr/bin/clamdscan $toadd ${allargs[*]}

View File

@@ -0,0 +1,29 @@
#!/bin/sh
#----------------------------------------------------------------------
# Copyright (C) 2005 Gordon Rowell <gordonr@gormand.com.au>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License or more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#----------------------------------------------------------------------
ServerHostName=$(/sbin/e-smith/db configuration get SystemName)
DomainName=$(/sbin/e-smith/db configuration get DomainName)
/usr/bin/tac /var/log/freshclam/current | \
/bin/sed -n '/Downloading/d;1,/process started/p;/process started/q' | \
/usr/bin/tac | \
/usr/local/bin/tai64nlocal | \
/bin/mail -s "freshclam: Update failed on $ServerHostName.$DomainName" admin
exit 0

View File

@@ -0,0 +1,23 @@
#!/bin/sh
#----------------------------------------------------------------------
# Copyright (C) 2005 Gordon Rowell <gordonr@gormand.com.au>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License or more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#----------------------------------------------------------------------
#tac /var/log/freshclam/current | sed -n '/Downloading/d;1,/process started/p;/process started/q' | tac | tai64nlocal | \
# mail -s 'freshclam: Virus patterns updated' admin
exit 0

View File

@@ -0,0 +1,71 @@
#!/usr/bin/perl -w
#----------------------------------------------------------------------
# Clam Antivirus virus scanner filesystem scanning.
#
# copyright (C) 2004 Shad L. Lords <slords@mail.com>
# Copyright (C) 2005 Gordon Rowell <gordonr@gormand.com.au>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License or more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#----------------------------------------------------------------------
use strict;
use esmith::ConfigDB;
my $db = esmith::ConfigDB->open_ro or die "Couldn't open ConfigDB";
my $filesystems = $db->get_prop("clamav", "FilesystemScanFilesystems") || '/';
my $MailReport = $db->get_prop("clamav", "FilesystemScanReportTo") || 'admin';
my $clamscan_opts = " --recursive --infected --stdout" .
" --log /var/log/clamd/clamscan.log";
my $quarantine_dir = $db->get_prop("clamav", "QuarantineDirectory") ||
"/var/spool/clamav/quarantine";
my @exclude = split /,/, ($db->get_prop("clamav", "FilesystemScanExclude") ||
"/proc,/sys,/usr/share/doc");
push @exclude, $quarantine_dir;
$clamscan_opts .= " --exclude=$_" for (@exclude);
$clamscan_opts .= " --no-html"
if ($db->get_prop("clamav", "ScanHTML") || "yes") eq "no";
$clamscan_opts .= " --no-mail"
if ($db->get_prop("clamav", "ScanMail") || "yes") eq "no";
$clamscan_opts .= " --move=$quarantine_dir"
if ($db->get_prop("clamav", "Quarantine") || "disabled") eq "enabled";
$clamscan_opts .= " --official-db-only=yes"
if ($db->get_prop("clamav", "FilesystemScanUnofficialSigs") || 'no') ne "yes";
open CLAMSCAN, "-|", "nice /usr/bin/clamscan $clamscan_opts $filesystems 2> /var/log/clamd/smeserver-clamscan.log";
my @report = <CLAMSCAN>;
close CLAMSCAN;
my $hostname = $db->get_value("SystemName") . "." .
$db->get_value("DomainName");
my $date = localtime;
open MAIL, "| /bin/mail " .
"-s \"[$hostname] Clam Antivirus Scan Results - $date\" $MailReport";
print MAIL @report;
close MAIL;