Merge pull request #1798 from cmstew/cmstew-amazon-linux-clamd-patch

cmstew amazon linux clamd patch
This commit is contained in:
Serghey Rodin 2021-10-28 23:07:04 +03:00 committed by GitHub
commit 70748e302e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 9 deletions

View file

@ -63,6 +63,7 @@ case $service in
spamd) dst=$($BIN/v-list-sys-spamd-config plain);;
spamassassin) dst=$($BIN/v-list-sys-spamd-config plain);;
clamd) dst=$($BIN/v-list-sys-clamd-config plain);;
clamd.scan) dst=$($BIN/v-list-sys-clamd-config plain);;
cron) dst='/etc/crontab';;
crond) dst='/etc/crontab';;
fail2ban) dst='/etc/fail2ban/jail.local';;

View file

@ -23,7 +23,7 @@ software="nginx httpd mod_ssl mod_ruid2 mod_fcgid mod_extract_forwarded
php php-common php-cli php-bcmath php-gd php-imap php-mbstring php-mcrypt
php-mysql php-pdo php-soap php-tidy php-xml php-xmlrpc php-fpm php-pgsql
awstats webalizer vsftpd proftpd bind bind-utils bind-libs exim dovecot
clamd spamassassin mysql mysql-server phpMyAdmin postgresql
clamd clamav-update spamassassin mysql mysql-server phpMyAdmin postgresql
postgresql-server postgresql-contrib phpPgAdmin e2fsprogs openssh-clients
ImageMagick curl mc screen ftp zip unzip flex sqlite pcre sudo bc jwhois
mailx lsof tar telnet rrdtool net-tools ntp GeoIP freetype fail2ban
@ -530,7 +530,7 @@ service exim stop > /dev/null 2>&1
cp -r /etc/exim/* $vst_backups/exim >/dev/null 2>&1
# Backup ClamAV configuration
service clamd stop > /dev/null 2>&1
service clamd.scan stop > /dev/null 2>&1
cp /etc/clamd.conf $vst_backups/clamd >/dev/null 2>&1
cp -r /etc/clamd.d $vst_backups/clamd >/dev/null 2>&1
@ -648,7 +648,6 @@ if [ "$exim" != 'no' ]; then
check_result $? "yum install failed"
fi
#----------------------------------------------------------#
# Configure system #
#----------------------------------------------------------#
@ -790,7 +789,7 @@ fi
if [ "$exim" = 'yes' ]; then
echo "MAIL_SYSTEM='exim'" >> $VESTA/conf/vesta.conf
if [ "$clamd" = 'yes' ]; then
echo "ANTIVIRUS_SYSTEM='clamav'" >> $VESTA/conf/vesta.conf
echo "ANTIVIRUS_SYSTEM='clamd.scan'" >> $VESTA/conf/vesta.conf
fi
if [ "$spamd" = 'yes' ]; then
echo "ANTISPAM_SYSTEM='spamassassin'" >> $VESTA/conf/vesta.conf
@ -1147,10 +1146,12 @@ if [ "$clamd" = 'yes' ]; then
useradd clam -s /sbin/nologin -d /var/lib/clamav 2>/dev/null
gpasswd -a clam exim
gpasswd -a clam mail
cp -f $vestacp/clamav/clamd.conf /etc/
cp -r /etc/clamd.d $vst_backups/clamd >/dev/null 2>&1
cp -f $vestacp/clamav/clamd.conf /etc/clamd.conf
ln -sf /etc/clamd.conf /etc/clamd.d/scan.conf
cp -f $vestacp/clamav/freshclam.conf /etc/
mkdir -p /var/log/clamav /var/run/clamav
chown clam:clam /var/log/clamav /var/run/clamav
mkdir -p /var/log/clamav /var/run/clamav /var/run/clamd.scan
chown clam:clam /var/log/clamav /var/run/clamav /var/run/clamd.scan
chown -R clam:clam /var/lib/clamav
if [ "$release" -ge '7' ]; then
cp -f $vestacp/clamav/clamd.service /usr/lib/systemd/system/
@ -1161,8 +1162,8 @@ if [ "$clamd" = 'yes' ]; then
sed -i "s/nofork/foreground/" /usr/lib/systemd/system/clamd.service
systemctl daemon-reload
fi
chkconfig clamd on
service clamd start
chkconfig clamd.scan on
service clamd.scan start
#check_result $? "clamd start failed"
fi

View file

@ -0,0 +1,46 @@
<?php
error_reporting(NULL);
$TAB = 'SERVER';
// Main include
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
// Check user
if ($_SESSION['user'] != 'admin') {
header("Location: /list/user");
exit;
}
// Check POST request
if (!empty($_POST['save'])) {
// Check token
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
header('location: /login/');
exit();
}
// Set restart flag
$v_restart = 'yes';
if (empty($_POST['v_restart'])) $v_restart = 'no';
// Update config
if (!empty($_POST['v_config'])) {
exec ('mktemp', $mktemp_output, $return_var);
$new_conf = $mktemp_output[0];
$fp = fopen($new_conf, 'w');
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config']));
fclose($fp);
exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." clamd.scan ".$v_restart, $output, $return_var);
check_return_code($return_var,$output);
unset($output);
unlink($new_conf);
}
// Set success message
if (empty($_SESSION['error_msg'])) {
$_SESSION['ok_msg'] = __('Changes has been saved.');
}
}
$v_config_path = shell_exec(VESTA_CMD.'v-list-sys-clamd-config plain');
$v_service_name = strtoupper('clamav');
// Read config
$v_config = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path);
// Render page
render_page($user, $TAB, 'edit_server_service');
// Flush session messages
unset($_SESSION['error_msg']);
unset($_SESSION['ok_msg']);