aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerg <dv_serg@mail.ru>2010-05-31 18:02:20 +0400
committerSerg <dv_serg@mail.ru>2010-05-31 18:02:20 +0400
commit3ef5e82b00684622f5a867f8abd04d8b428e5b86 (patch)
treec0616f5f652636809ec4b65579c446ab8ff0b619
parentb676457155b975bc17292a7adb917904e782c8ec (diff)
downloadpfsense-packages-3ef5e82b00684622f5a867f8abd04d8b428e5b86.tar.gz
pfsense-packages-3ef5e82b00684622f5a867f8abd04d8b428e5b86.tar.bz2
pfsense-packages-3ef5e82b00684622f5a867f8abd04d8b428e5b86.zip
Havp status page added
-rw-r--r--config/havp/antivirus.php401
-rw-r--r--config/havp/havp.inc144
-rw-r--r--config/havp/havp.xml13
-rw-r--r--config/havp/havp_avset.xml6
-rw-r--r--config/havp/havp_fscan.xml4
5 files changed, 516 insertions, 52 deletions
diff --git a/config/havp/antivirus.php b/config/havp/antivirus.php
new file mode 100644
index 00000000..6cb05d7c
--- /dev/null
+++ b/config/havp/antivirus.php
@@ -0,0 +1,401 @@
+<?php
+/* $Id$ */
+/*
+ antivirus.php
+ Copyright (C) 2010 Serg Dvoriancev
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``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.
+*/
+
+$pgtitle = "Antivirus: General page";
+require_once("guiconfig.inc");
+require_once("pkg-utils.inc");
+require_once("service-utils.inc");
+
+include("head.inc");
+
+if (file_exists("/usr/local/pkg/havp.inc"))
+ require_once("/usr/local/pkg/havp.inc");
+else echo "No havp.inc found";
+
+define('PATH_CLAMDB', '/var/db/clamav');
+define('PATH_HAVPLOG', '/var/log/havp/access.log');
+define('PATH_AVSTATUS', '/var/tmp/havp.status');
+
+function get_avdb_info($filename)
+{
+ $stl = "style='padding-top: 0px; padding-bottom: 0px; padding-left: 4px; padding-right: 4px; border-left: 1px solid #999999;'";
+ $r = '';
+ $path = PATH_CLAMDB . "/{$filename}";
+ if (file_exists($path)) {
+ $handle = '';
+ if ($handle = fopen($path, "r")) {
+ $fsize = sprintf("%.2f M", filesize($path)/1024/1024);
+
+ $s = fread($handle, 1024);
+ $s = explode(':', $s);
+
+ # datetime
+ $dt = explode(" ", $s[1]);
+ $s[1] = strftime("%d.%m.%Y", strtotime("{$dt[0]} {$dt[1]} {$dt[2]}"));
+ if ($s[0] == 'ClamAV-VDB')
+ $r .= "<tr class='listr'><td $stl>{$filename}</td><td $stl>{$s[1]}</td><td $stl align='right'>$fsize</td><td $stl align='right'>{$s[2]}</td><td $stl align='right'>{$s[3]}</td><td $stl>{$s[7]}</td></tr>";
+ }
+ fclose($handle);
+ }
+ return $r;
+}
+
+function get_av_statistic()
+{
+ return function_exists("havp_get_av_statistic") ? havp_get_av_statistic() : "Function 'havp_get_av_statistic' not found.";
+}
+
+function get_av_viruslog()
+{
+ return function_exists("havp_get_av_viruslog") ? havp_get_av_viruslog() : "Function 'havp_get_av_viruslog' not found.";
+}
+
+function get_scanlist()
+{
+ return function_exists("havp_get_filescanlist") ? havp_get_filescanlist() : "Function 'havp_get_filescanlist()' not found.";
+}
+
+function get_scan_log()
+{
+ $s = function_exists("havp_get_scan_log") ? havp_get_scan_log() : "Function 'havp_get_scan_log()' not found.";
+ $s = str_replace("\n", "<br>", $s);
+ return $s;
+}
+
+function pfsense_version_A()
+{
+ return function_exists("pfsense_version_") ? pfsense_version_() : 1;
+}
+
+function havp_status()
+{
+ $s = "";
+ if (HVDEF_HAVP_STATUS_FILE && file_exists(HVDEF_HAVP_STATUS_FILE))
+ $s = file_get_contents(HVDEF_HAVP_STATUS_FILE);
+ return $s;
+}
+
+function clamd_status()
+{
+ $s = "";
+ if (HVDEF_CLAM_STATUS_FILE && file_exists(HVDEF_CLAM_STATUS_FILE))
+ $s = file_get_contents(HVDEF_CLAM_STATUS_FILE);
+ return $s;
+}
+
+function avupdate_status()
+{
+ $s = "Not found.";
+ if (HVDEF_UPD_STATUS_FILE && file_exists(HVDEF_UPD_STATUS_FILE))
+ $s = file_get_contents(HVDEF_UPD_STATUS_FILE);
+ return $s;
+}
+# ------------------------------------------------------------------------------
+
+/* start service */
+if($_POST['start'] != '') {
+ #start_service($_POST['start']);
+ if (file_exists(HVDEF_HAVP_STARTUP_SCRIPT)) {
+ mwexec_bg (HVDEF_HAVP_STARTUP_SCRIPT . " start");
+ sleep(3);
+ }
+} else
+/* restart service */
+if($_POST['restart'] != '') {
+ #restart_service($_POST['restart']);
+ if (file_exists(HVDEF_HAVP_STARTUP_SCRIPT)) {
+ mwexec_bg (HVDEF_HAVP_STARTUP_SCRIPT . " restart");
+ sleep(3);
+ }
+} else
+/* stop service */
+if($_POST['stop'] != '') {
+ #stop_service($_POST['stop']);
+ if (file_exists(HVDEF_HAVP_STARTUP_SCRIPT)) {
+ mwexec_bg (HVDEF_HAVP_STARTUP_SCRIPT . " stop");
+ sleep(3);
+ }
+}
+
+/* Scan start */
+if ($_POST['scanpath'] != '') {
+ $scandir = $_POST['scanpath'];
+ if(function_exists("start_antivirus_scanner")) {
+ start_antivirus_scanner($scandir);
+ }
+ else echo "No 'start_antivirus_scanner' function found.";
+}
+
+/* Start AV Update */
+if ($_POST['startupdate'] != '') {
+ if( function_exists("havp_update_AV")) {
+ havp_update_AV();
+ }
+# else echo "No 'start_antivirus_scanner' function found.";
+}
+
+# ------------------------------------------------------------------------------
+?>
+
+<style type="text/css">
+<!--
+.avheader {
+ padding-right: 20px;
+ padding-left: 8px;
+ font-weight: bold;
+ border-bottom: 1px solid #E9E9E9;
+ font-size: 11px;
+}
+.avlist_h {
+ background-color: #BBBBBB;
+ padding-right: 16px;
+ padding-left: 6px;
+ padding-top: 2px;
+ padding-bottom: 2px;
+ font-size: 11px; font-weight:
+ bold; border-bottom: 1px solid #999999;
+}
+.avlist_lr {
+ background-color: #FFFFFF;
+ border-right: 1px solid #999999;
+ border-bottom: 1px solid #999999;
+ border-left: 1px solid #999999;
+ font-size: 11px;
+ padding-right: 6px;
+ padding-left: 6px;
+ padding-top: 4px;
+ padding-bottom: 4px;
+}
+.avlisttopic {
+ background-color: #990000;
+ padding-right: 16px;
+ padding-left: 6px;
+ padding-top: 2px;
+ padding-bottom: 2px;
+ border-right: 1px solid #999999;
+ font-size: 11px;
+ font-weight: bold;
+ color: #FFFFFF;
+}
+-->
+</style>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+
+<?php
+if (pfsense_version_A() == '1') {
+ echo "<p class=\"pgtitle\">$pgtitle</p>";
+}
+?>
+
+<form action="antivirus.php" method="post">
+<?php if ($savemsg) print_info_box($savemsg); ?>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td><div id="mainarea"><table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabcont" valign="top">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="50%" valign="top">
+
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr><td class="avlist_h">Service</td></tr>
+ <tr>
+ <td>
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td class="listlr">HTTP Antivirus Proxy ( <?php echo(havp_status()); ?> )</td>
+ <td class="listr"><center>
+ <?php
+ $running = (is_service_running("havp", $ps) or is_process_running("havp"));
+ if ($running)
+ echo "<img src=\"/themes/" . $g["theme"] . "/images/icons/icon_pass.gif\" > Running";
+ else echo "<img src=\"/themes/" . $g["theme"] . "/images/icons/icon_block.gif\"> Stopped";
+ ?>
+ </td>
+ <td class="listr">
+ <?php
+ if($running) {
+ echo "<input title='Restart Service' name='restart' type='image' value='havp' border=0 src='./themes/".$g['theme']."/images/icons/icon_service_restart.gif'>";
+ echo "&nbsp";
+ echo "<input title='Stop Service' name='stop' type='image' value='havp' border=0 src='./themes/".$g['theme']."/images/icons/icon_service_stop.gif'>";
+ } else echo "<input title='Start Service' name='start' type='image' value='havp' border=0 src='./themes/".$g['theme']."/images/icons/icon_service_start.gif'>";
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <td class="listlr">Antivirus Server ( <?php echo(clamd_status()); ?> )</td>
+ <td class="listr"><center>
+ <?php
+ $running = (is_service_running("clamd", $ps) or is_process_running("clamd"));
+ if ($running)
+ echo "<img src=\"/themes/" . $g["theme"] . "/images/icons/icon_pass.gif\" > Running";
+ else echo "<img src=\"/themes/" . $g["theme"] . "/images/icons/icon_block.gif\"> Stopped";
+ ?>
+ </td>
+ <td class="listr">&nbsp;</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr><td>&nbsp;</td></tr>
+ <tr><td class="avlist_h">Settings</td></tr>
+ <tr>
+ <td class="vncellt">
+ <a href="/pkg_edit.php?xml=havp.xml&amp;id=0">
+ <?php echo "<input height=14 title='Show Antivirus settings page' name='scan' type='image' value='scan' border=0 src='./themes/".$g['theme']."/images/icons/icon_service_start.gif'>"; ?>
+ <font size="2">&nbsp;Show Antivirus Settings</size>
+ </a>
+ </td>
+ </tr>
+ <tr><td>&nbsp;</td></tr>
+ <tr><td class="avlist_h">Update</td></tr>
+ <tr>
+ <td class="vncellt" nowrap>
+ <?php echo "<input height=14 title='Start antivirus update' name='startupdate' type='image' value='startupdate' border=0 src='./themes/".$g['theme']."/images/icons/icon_service_start.gif'>"; ?>
+ <font size="-1">&nbsp;Start update</font>
+ </td>
+ </tr>
+ <tr><td>&nbsp;</td></tr>
+ <tr><td class="avlist_h">File scanner</td></tr>
+ <tr>
+ <td class="vtable">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td class="listlr">
+ &nbsp;Path: <br>
+ <input size="60%" id="scanpath" name="scanpath" value=""><br>
+ &nbsp;Enter file path or catalog for scanning.
+ <hr>
+ <?php
+ $scanlist = get_scanlist();
+ if (is_array($scanlist))
+ foreach($scanlist as $key => $val) {
+ echo "<span onclick=\"document.getElementById('scanpath').value='{$val}';\" style=\"cursor: pointer;\">\n";
+ echo "<img src='./themes/".$g['theme']."/images/icons/icon_pass.gif'>\n";
+ echo "<u>{$key}</u>\n";
+ echo "</span>";
+ echo "<br>";
+ }
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <td class="vncellt" nowrap>
+ <?php echo "<input height=14 title='Scan selected file or catalog' name='scan' type='image' value='scan' border=0 src='./themes/".$g['theme']."/images/icons/icon_service_start.gif'>"; ?>
+ <font size="-1">&nbsp;Start Scanner</font>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td width="50%" valign="top">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr><td class="avlisttopic" colspan=2>Antivirus version info</td></tr>
+ <tr>
+ <td class="vncellt">Antivirus Server</td>
+ <td class="listr" width=75%>
+ <?php echo exec("clamd -V"); ?>
+ </td>
+ </tr>
+ <tr>
+ <td class="vncellt">HTTP Proxy</td>
+ <td class="listr" width=75%>
+ <?php echo exec("pkg_info | grep \"[h]avp\""); ?>
+ </td>
+ </tr>
+ </table>
+ <br>
+ <table width="100%" border="0" cellspacing="0" cellpadding="1" ><tbody>
+ <tr class="avlisttopic" align="center"><td>Database</td><td>Date</td><td>Size</td><td>Ver.</td><td>Signatures</td><td>Builder</td></tr>
+ <?php echo get_avdb_info("daily.cld"); ?>
+ <?php echo get_avdb_info("daily.cvd"); ?>
+ <?php echo get_avdb_info("main.cld"); ?>
+ <?php echo get_avdb_info("main.cvd"); ?>
+ <?php echo get_avdb_info("safebrowsing.cld"); ?>
+ <?php echo get_avdb_info("safebrowsing.cvd"); ?>
+ </tbody></table>
+ <br>
+ <table width="100%" border="0" cellspacing="0" cellpadding="1" ><tbody>
+ <tr><td class="avlisttopic">Update status</td></tr>
+ <tr><td class="listr" width=75%>
+ <?php echo avupdate_status(); ?>
+ </td></tr>
+ </tbody></table>
+ <br>
+ <table width="100%" border="0" cellspacing="0" cellpadding="1" ><tbody>
+ <tr><td class="avlisttopic">Scanner status</td></tr>
+ <tr>
+ <td class="listr" width=75%><?php echo get_scan_log(); ?></td>
+ </tr>
+ </tbody></table>
+ </td>
+ </tr>
+ <tr>
+ <td colspan=2>
+ <table width="100%" border="0" cellspacing="0" cellpadding="1" ><tbody>
+ <tr class="vncellt"><td class="avlist_h" colspan="4">Last Viruses</td></tr>
+ <?php
+ $count = 30;
+ $stl = "style='padding-right: 4px;'";
+ $s = get_av_viruslog();
+ krsort($s); # reverse sort
+ if (is_array($s) && !empty($s)) {
+ foreach($s as $val) {
+ if (!$count) break;
+ $ln = explode(' ', $val);
+ echo "<tr><td nowrap $stl>{$ln[0]} {$ln[1]}</td><td nowrap $stl>{$ln[2]}</td><td>{$ln[5]}</td><td nowrap>{$ln[9]}</td></tr>";
+ $count--;
+ }
+ }
+ else echo "<tr><td $stl>Not found</td></tr>";
+ ?>
+ <tr class="listr"><td class="listr" colspan="4"><?php echo get_av_statistic(); ?></td></tr>
+ </tbody></table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+</div></tr></td></table>
+</form>
+
+<?php include("fend.inc"); ?>
+
+<script type="text/javascript">
+ NiftyCheck();
+ Rounded("div#mainarea","bl br","#FFF","#eeeeee","smooth");
+</script>
+
+</body>
+</html>
diff --git a/config/havp/havp.inc b/config/havp/havp.inc
index 5a21ed0e..0c2f688b 100644
--- a/config/havp/havp.inc
+++ b/config/havp/havp.inc
@@ -113,18 +113,25 @@ define('HVDEF_STATUS_FILE', '/var/tmp/havp.status');
define('HVDEF_SCRIPT_DIR', '/usr/local/etc/rc.d');
define('HVDEF_AVCRON_SCRIPT', '/clamav-freshclam');
define('HVDEF_FILTER_RESYNC_SCRIPT', '/usr/local/pkg/pf/havp_filter_resync.sh');
-define('HVDEF_HAVP_STARTUP_SCRIPT', HVDEF_SCRIPT_DIR . '/havp');
+define('HVDEF_HAVP_STARTUP_SCRIPT', HVDEF_SCRIPT_DIR . '/havp.sh');
define('HVDEF_CLAM_STARTUP_SCRIPT', HVDEF_SCRIPT_DIR . '/clamd');
define('HVDEF_AVUPD_SCRIPT', HVDEF_SCRIPT_DIR . '/havp_avupdate');
+# status
+define('HVDEF_HAVP_STATUS_FILE', '/tmp/havp.status');
+define('HVDEF_CLAM_STATUS_FILE', '/tmp/clam.status');
+define('HVDEF_UPD_STATUS_FILE', '/tmp/havpupd.status');
+
# cron
define('HVDEF_CLAM_UPD_CRONNAME', 'havp_clam_update');
define('HVDEF_CLAM_UPD_CRONCMD', HVDEF_SCRIPT_DIR . HVDEF_AVCRON_SCRIPT . " start");
define('HVDEF_CLAM_UPD_CRONKEY', HVDEF_AVCRON_SCRIPT);
+
# user
define('HVDEF_USER', 'havp');
define('HVDEF_GROUP', 'havp');
define('HVDEF_AVUSER', HVDEF_USER);
+
# fields
define('HV_SCANTEMPFILE', 'hv_scan_tempfile');
@@ -186,12 +193,13 @@ havp_convert_pfxml_xml();
function havp_install()
{
update_status("HAVP check system..\n");
- havp_fix();
havp_check_system();
+ havp_fix();
havp_avset_resync();
havp_update_AV();
+
update_status("Start update Antivirus bases. Wait 5-20 min before use ..");
}
# ------------------------------------------------------------------------------
@@ -899,8 +907,8 @@ function havp_config_freshclam()
$conf[] = "Checks $chks";
$conf[] = "# notification";
- $conf[] = "OnUpdateExecute date \"+%d-%m-%Y %H:%M:%S Antivirus update success\" > " . HVDEF_STATUS_FILE;
- $conf[] = "OnErrorExecute date \"+%d-%m-%Y %H:%M:%S Antivirus update error\" > " . HVDEF_STATUS_FILE;
+ $conf[] = "OnUpdateExecute date \"+%d-%m-%Y %H:%M:%S Antivirus update success\" > " . HVDEF_UPD_STATUS_FILE;
+ $conf[] = "OnErrorExecute date \"+%d-%m-%Y %H:%M:%S Antivirus update error\" > " . HVDEF_UPD_STATUS_FILE;
$conf[] = "Debug " . (HV_DEBUG === 'true' ? "yes" : "no");
@@ -1122,14 +1130,6 @@ function havp_generate_rules($type = 'filter')
global $config, $havp_config;
$rules = array();
-/* # remove this code nax
- # nothing if havp not running
- if (!is_service_running('havp')) {
- if (HV_DEBUG === 'true')
- log_error("havp: Havp is installed but not started. Filter rules not created.");
- return;
- }
-*/
$proxymode = $havp_config[F_PROXYMODE];
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# =-= HAVP always listen 127.0.0.1:port =-=
@@ -1245,10 +1245,8 @@ function havp_filter_update_3()
function havp_update_AV()
{
# AV update script
- if (file_exists(HVDEF_AVUPD_SCRIPT)) {
- file_put_contents(HVDEF_AVUPD_SCRIPT, havp_AVupdate_script());
- havp_set_file_access(HVDEF_AVUPD_SCRIPT, HVDEF_AVUSER, '0755');
- }
+ file_put_contents(HVDEF_AVUPD_SCRIPT, havp_AVupdate_script());
+ havp_set_file_access(HVDEF_AVUPD_SCRIPT, HVDEF_AVUSER, '0755');
mwexec_bg(HVDEF_AVUPD_SCRIPT); # run update background
}
# ==============================================================================
@@ -1257,12 +1255,10 @@ function havp_update_AV()
# AV update script
function havp_AVupdate_script()
{
-
+$f = HVDEF_UPD_STATUS_FILE;
return <<<EOD
#!/bin/sh
-# AV update script
-# This file was automatically generated
-# by the pfSense service handler.
+date +"%d.%m.%Y %H:%M:%S Antivirus update started." > $f
/usr/local/bin/freshclam
wait
/usr/local/bin/sigtool --unpack-current daily.cvd
@@ -1282,7 +1278,7 @@ function havp_startup_script()
# rc script
$rc = array();
- $rc['file'] = basename(HVDEF_HAVP_STARTUP_SCRIPT);
+ $rc['file'] = basename(HVDEF_HAVP_STARTUP_SCRIPT);
$s[] = "# start";
$s[] = "\tif [ -z \"`{$havpchk}`\" ];then";
@@ -1290,13 +1286,14 @@ function havp_startup_script()
$clampid_dir = HVDEF_CLAM_RUNDIR;
$s[] = "\t\t# start clamd before (to be sure)";
$s[] = "\t\t" . HVDEF_CLAM_STARTUP_SCRIPT . " start";
- $s[] = "\t\twait";
+ $s[] = "\t\tsleep 2";
$s[] = "";
$s[] = "\t\t# if clamd started";
$s[] = "\t\tif [ -n \"`{$clamdchk}`\" ];then";
$s[] = "\t\t\t# Waiting CLAMD";
$s[] = "\t\t\techo -n \"Waiting CLAMD \"";
+ $s[] = "\t\t\techo 'Waiting CLAMD' > " . HVDEF_HAVP_STATUS_FILE;
$s[] = "\t\t\twhile [ \"`{$clamdchk}`\" != \"`/bin/cat {$clampid_dir}/clamd.pid`\" ];do";
$s[] = "\t\t\t\techo -n '.'";
$s[] = "\t\t\t\tsleep 1";
@@ -1306,7 +1303,8 @@ function havp_startup_script()
$s[] = "";
}
$s[] = "\t\t/usr/local/sbin/havp -c " . HVDEF_HAVP_CONFIG . " 2>/dev/null";
- $s[] = "\t\tsleep 2";
+ $s[] = "\t\twait";
+ $s[] = "\t\techo 'Started' > " . HVDEF_HAVP_STATUS_FILE;
$s[] = "\tfi";
$s[] = "";
$rc['start'] = implode("\n", $s);
@@ -1314,13 +1312,19 @@ function havp_startup_script()
$s[] = "# stop";
$s[] = "\t killall havp 2>/dev/null";
- $s[] = "\t sleep 3";
- $s[] = "\t killall -9 havp 2>/dev/null";
$s[] = "\t sleep 2";
+ $s[] = "\t killall -9 havp 2>/dev/null";
+ $s[] = "\t wait";
+ $s[] = "\t echo 'Stopped' > " . HVDEF_HAVP_STATUS_FILE;
$s[] = "";
$rc['stop'] = implode("\n", $s);
unset($s);
+ # we don't use start if package disabled
+ if ($havp_config[F_ENABLE] !== 'true') {
+ $rc['start'] = "\t echo 'Disabled' > " . HVDEF_HAVP_STATUS_FILE;
+ }
+
write_rcfile($rc);
}
# ------------------------------------------------------------------------------
@@ -1334,27 +1338,31 @@ function hv_clamd_startup_script()
# rc script
$rc = array();
$rc['file'] = basename(HVDEF_CLAM_STARTUP_SCRIPT);
+ $s[] = "\t\techo 'Starting..' > " . HVDEF_CLAM_STATUS_FILE;
$s[] = "# start";
$s[] = "\tif [ -z \"`{$clamdchk}`\" ];then";
$s[] = "\t\t/usr/local/sbin/clamd -c " . HVDEF_CLAM_CONFIG . " 2>/dev/null";
$s[] = "\t\twait";
$s[] = "\tfi";
+ $s[] = "\techo 'Started' > " . HVDEF_CLAM_STATUS_FILE;
$s[] = "";
$rc['start'] = implode("\n", $s);
unset($s);
$s[] = "#stop";
$s[] = "\t killall clamd 2>/dev/null";
- $s[] = "\t sleep 5";
+ $s[] = "\t sleep 2";
$s[] = "\t killall -9 clamd 2>/dev/null";
$s[] = "\t wait";
+ $s[] = "\t\techo 'Stopped' > " . HVDEF_CLAM_STATUS_FILE;
$s[] = "";
$rc['stop'] = implode("\n", $s);
unset($s);
- write_rcfile($rc);
+ write_rcfile($rc);
}
+
# ------------------------------------------------------------------------------
# HAVP filter resync script
function havp_filter_resync_script()
@@ -1429,7 +1437,7 @@ function mountRAMdisk($free_and_mount = true)
# ------------------------------------------------------------------------------
function umountRAMDisk()
{
- global $havp_config;
+ global $havp_config;
# detach and free all resources used by /dev/md10:
mwexec("umount -f " . HVDEF_RAMTEMP_DIR);
@@ -1480,27 +1488,12 @@ function start_antivirus_scanner($filename)
$param[] = "-l " . HVDEF_CLAMSCAN_LOG; # Save scan report to FILE
$param[] = "-r"; # Scan subdirectories recursively
$param[] = "--remove"; # Remove infected files. Be careful!
-# $param[] = "--move=DIRECTORY"; # Move infected files into DIRECTORY
-# $param[] = "--exclude=PATT"; # Don't scan file names containing PATT
-# $param[] = "--exclude-dir=PATT"; # Don't scan directories containing PATT
-# $param[] = "--include=PATT"; # Only scan file names containing PATT
-# $param[] = "--include-dir=PATT"; # Only scan directories containing PATT
-# $param[] = "--detect-pua"; # Detect Possibly Unwanted Applications
$param[] = "--detect-broken"; # Try to detect broken executable files
$param[] = "--max-filesize=10000000"; # Files larger than this will be skipped and assumed clean
$param[] = "--max-scansize=5000000"; # The maximum amount of data to scan for each container file (*)
$param[] = "--max-files=10000"; # The maximum number of files to scan for each container file (*)
$param[] = "--max-recursion=255"; # Maximum archive recursion level for container file (*)
$param[] = "--max-dir-recursion=255"; # Maximum directory recursion level
-# $param[] = "--unzip[=FULLPATH]"; # Enable support for .zip files
-# $param[] = "--unrar[=FULLPATH]"; # Enable support for .rar files
-# $param[] = "--arj[=FULLPATH]"; # Enable support for .arj files
-# $param[] = "--unzoo[=FULLPATH]"; # Enable support for .zoo files
-# $param[] = "--lha[=FULLPATH]"; # Enable support for .lha files
-# $param[] = "--jar[=FULLPATH]"; # Enable support for .jar files
-# $param[] = "--tar[=FULLPATH]"; # Enable support for .tar files
-# $param[] = "--deb[=FULLPATH to ar]"; # Enable support for .deb files
-# $param[] = "--tgz[=FULLPATH]"; # Enable support for .tar.gz, .tgz files
$param = implode(" ", $param);
if (HV_USE_CLAMD === 'true')
@@ -1515,9 +1508,10 @@ function start_antivirus_scanner($filename)
# put to log scanning file
$cont="Starting scan file {$filename}\n";
- file_put_contents(HVDEF_CLAMSCAN_LOG, $cont);
+ file_put_contents(HVDEF_CLAMSCAN_LOG, $cont);
- mwexec_bg("$param");
+ mwexec_bg("$param");
+ exec("date +\"%d.%m.%Y %H:%M:%S Starting scan file '$filename'.\" > " . HVDEF_CLAMSCAN_LOG);
}
else log_error("Antivirus: Can't starting file scanner. File '$filename' not exists.");
}
@@ -1606,16 +1600,68 @@ EOD;
}
+# ==============================================================================
+# Status, widgets
+# ==============================================================================
+function havp_get_scan_log()
+{
+ $s = '';
+ $clamscanlog = "/var/log/clamscan.log";
+ if (file_exists($clamscanlog)) {
+ $s = file_get_contents("/var/log/clamscan.log");
+ }
+ if (empty($s)) $s = "Not found.";
+ return $s;
+}
+
+function havp_get_filescanlist()
+{
+ $slist = array();
+ $slist['Squid cache path (scan you squid cache now).'] = '/var/squid';
+ $slist['Common DB path.'] = '/var/db';
+ $slist['Temp path'] = '/tmp';
+ return $slist;
+}
+
+function havp_get_av_viruslog()
+{
+ $s = array();
+ if (file_exists(HVDEF_HAVP_ACCESSLOG)) {
+ $log = file_get_contents(HVDEF_HAVP_ACCESSLOG);
+
+ $log = explode("\n", $log);
+ $count = 0;
+ foreach($log as $ln) {
+ if (substr_count(strtolower($ln), "virus clamd:"))
+ $s[] = $ln;
+ }
+ }
+
+ return $s;
+}
+
+function havp_get_av_statistic()
+{
+ $s = "Unknown.";
+ if (file_exists(HVDEF_HAVP_ACCESSLOG)) {
+ $log = file_get_contents(HVDEF_HAVP_ACCESSLOG);
+
+ $count = substr_count(strtolower($log), "virus clamd:");
+ $s = "Found $count viruses (total).";
+ }
+
+ return $s;
+}
+
# ------------------------------------------------------------------------------
# Fix
# ------------------------------------------------------------------------------
function havp_fix()
{
# remove old named scripts
- # havp/clamd start scripts can't be have '.sh' extensions -
- # exists starting problem on reboot
- unlink(HVDEF_HAVP_STARTUP_SCRIPT . ".sh");
- unlink(HVDEF_CLAM_STARTUP_SCRIPT . ".sh");
+ # now must exists 'havp.sh'/'clamd'
+ mwexec(HVDEF_SCRIPT_DIR . "/havp");
+ mwexec(HVDEF_SCRIPT_DIR . "/clamd.sh");
}
?>
diff --git a/config/havp/havp.xml b/config/havp/havp.xml
index d04c144a..c1d22a60 100644
--- a/config/havp/havp.xml
+++ b/config/havp/havp.xml
@@ -9,11 +9,11 @@
<name>Antivirus</name>
<tooltiptext>Antivirus service</tooltiptext>
<section>Services</section>
- <url>/pkg_edit.php?xml=havp.xml&amp;id=0</url>
+ <url>/antivirus.php</url>
</menu>
<service>
<name>havp</name>
- <rcfile>havp</rcfile>
+ <rcfile>havp.sh</rcfile>
<executable>havp</executable>
<description>Antivirus HTTP proxy Service</description>
</service>
@@ -32,8 +32,17 @@
<prefix>/usr/local/pkg/</prefix>
<chmod>0755</chmod>
</additional_files_needed>
+ <additional_files_needed>
+ <item>http://www.pfsense.com/packages/config/havp/antivirus.php</item>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ </additional_files_needed>
<tabs>
<tab>
+ <text>General page</text>
+ <url>/antivirus.php</url>
+ </tab>
+ <tab>
<text>HTTP proxy</text>
<url>/pkg_edit.php?xml=havp.xml&amp;id=0</url>
<active/>
diff --git a/config/havp/havp_avset.xml b/config/havp/havp_avset.xml
index 03fbf7a4..fbd23ce0 100644
--- a/config/havp/havp_avset.xml
+++ b/config/havp/havp_avset.xml
@@ -3,10 +3,14 @@
<name>havpavset</name>
<title>Antivirus: Settings</title>
<category>Status</category>
- <version>0.88_03</version>
+ <version>none</version>
<include_file>/usr/local/pkg/havp.inc</include_file>
<tabs>
<tab>
+ <text>General page</text>
+ <url>/antivirus.php</url>
+ </tab>
+ <tab>
<text>HTTP Proxy</text>
<url>/pkg_edit.php?xml=havp.xml&amp;id=0</url>
</tab>
diff --git a/config/havp/havp_fscan.xml b/config/havp/havp_fscan.xml
index 60e091a9..accd275f 100644
--- a/config/havp/havp_fscan.xml
+++ b/config/havp/havp_fscan.xml
@@ -7,6 +7,10 @@
<include_file>/usr/local/pkg/havp.inc</include_file>
<tabs>
<tab>
+ <text>General page</text>
+ <url>/antivirus.php</url>
+ </tab>
+ <tab>
<text>HTTP Proxy</text>
<url>/pkg_edit.php?xml=havp.xml&amp;id=0</url>
</tab>