From 178f34f25bdc617f70a584273b0f40a2d0cb4779 Mon Sep 17 00:00:00 2001 From: dvserg Date: Sun, 21 Nov 2010 10:35:10 +0300 Subject: HAVP firewall rules fix for 2.0, status avupdate message fix. --- config/havp/antivirus.php | 54 +++++++++++++++++++++++++++-------------------- config/havp/havp.inc | 27 +++++++++++++++++------- config/havp/havp.xml | 4 ++-- 3 files changed, 52 insertions(+), 33 deletions(-) (limited to 'config/havp') diff --git a/config/havp/antivirus.php b/config/havp/antivirus.php index 79ff31e7..fa03301e 100644 --- a/config/havp/antivirus.php +++ b/config/havp/antivirus.php @@ -42,27 +42,40 @@ 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) +function get_avdb_info() { - $stl = "style='padding-top: 0px; padding-bottom: 0px; padding-left: 4px; padding-right: 4px; border-left: 1px solid #999999;'"; - $r = ''; + $r = ''; $path = PATH_CLAMDB . "/{$filename}"; - if (file_exists($path)) { - $handle = ''; - if ($handle = fopen($path, "r")) { - $fsize = sprintf("%.2f M", filesize($path)/1024/1024); + $fl = get_dir(PATH_CLAMDB . "/"); + + array_shift($fl); + array_shift($fl); + + foreach ($fl as $fname) { + $path = PATH_CLAMDB . "/{$fname}"; + $ext = end(explode(".", $fname)); + + if ( $ext == "cvd" || $ext == "cld") { + $stl = "style='padding-top: 0px; padding-bottom: 0px; padding-left: 4px; padding-right: 4px; border-left: 1px solid #999999;'"; + 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 .= "{$filename}{$s[1]}$fsize{$s[2]}{$s[3]}{$s[7]}"; + $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 .= "{$fname}{$s[1]}$fsize{$s[2]}{$s[3]}{$s[7]}"; + } + fclose($handle); + } } - fclose($handle); } + return $r; } @@ -114,7 +127,7 @@ 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; + return str_replace( "\n", "
", $s ); } # ------------------------------------------------------------------------------ @@ -258,12 +271,7 @@ if (pfsense_version_A() == '1') { - - - - - - +
DatabaseDateSizeVer.SignaturesBuilder
diff --git a/config/havp/havp.inc b/config/havp/havp.inc index 072d90b4..02ff7c6d 100644 --- a/config/havp/havp.inc +++ b/config/havp/havp.inc @@ -120,7 +120,8 @@ 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'); +define('HVDEF_UPD_STATUS_FILE', '/tmp/havp.update.status'); +define('HVDEF_FRESHCLAM_STATUS_FILE', '/tmp/havp.freshclam.status'); # cron define('HVDEF_CLAM_UPD_CRONNAME', 'havp_clam_update'); @@ -254,6 +255,11 @@ function havp_validate_settings($post, $input_errors) else $input_errors[] = "File or path not exists '{$post[F_SCANFILEPATH]}'."; } else { + # ifaces + if (!isset($post[F_PROXYINTERFACE]) || empty($post[F_PROXYINTERFACE])) { + $post[F_PROXYINTERFACE] = "lan"; + } + # port validate $prxport = trim($post[F_PROXYPORT]); if (!empty($prxport) && !is_port($prxport)) @@ -262,8 +268,8 @@ function havp_validate_settings($post, $input_errors) # parent proxy validate $parent = trim($post[F_PARENT]); - # max download size validate - $maxval = trim($post[F_MAXDOWNLOADSIZE]); + # max download size validate + $maxval = trim($post[F_MAXDOWNLOADSIZE]); if (!empty($maxval) && !is_numericint($maxval)) # is_port - validate value $input_errors[] = 'You must enter a valid numeric value in \'Max download size\' field.'; @@ -339,7 +345,7 @@ function havp_resync() havp_reconfigure_cron(); # configure system filter - filter_configure(); + if (pfsense_version_() == '1') filter_configure(); } # ------------------------------------------------------------------------------ @@ -429,7 +435,7 @@ function havp_check_system() } else { # delete script if exists if (file_exists(HVDEF_FILTER_RESYNC_SCRIPT)) - mwexec("rm -rf " . HVDEF_FILTER_RESYNC_SCRIPT); + mwexec("rm -f " . HVDEF_FILTER_RESYNC_SCRIPT); } # mount RAMDisk @@ -907,8 +913,8 @@ function havp_config_freshclam() $conf[] = "Checks $chks"; $conf[] = "# notification"; - $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[] = "OnUpdateExecute date \"+%d-%m-%Y %H:%M:%S Antivirus update success\" > " . HVDEF_FRESHCLAM_STATUS_FILE; + $conf[] = "OnErrorExecute date \"+%d-%m-%Y %H:%M:%S Antivirus update error\" > " . HVDEF_FRESHCLAM_STATUS_FILE; $conf[] = "Debug " . (HV_DEBUG === 'true' ? "yes" : "no"); @@ -1241,6 +1247,7 @@ function havp_filter_update_3() mwexec("pfctl -f $rules_file"); } } + # ------------------------------------------------------------------------------ function havp_update_AV() { @@ -1256,14 +1263,18 @@ function havp_update_AV() function havp_AVupdate_script() { $f = HVDEF_UPD_STATUS_FILE; +$u = HVDEF_FRESHCLAM_STATUS_FILE; return << $f +date +"%d.%m.%Y %H:%M:%S Antivirus update started." > $f +date +"%d.%m.%Y %H:%M:%S Antivirus database already is updated." > $u /usr/local/bin/freshclam wait +cat $u >> $f /usr/local/bin/sigtool --unpack-current daily.cvd /usr/local/bin/sigtool --unpack-current main.cvd wait +date +"%d.%m.%Y %H:%M:%S Antivirus update end." >> $f EOD; } diff --git a/config/havp/havp.xml b/config/havp/havp.xml index 30d61ee0..c7841956 100644 --- a/config/havp/havp.xml +++ b/config/havp/havp.xml @@ -89,7 +89,7 @@ interfaces_selection - lan + lan Proxy port @@ -100,7 +100,7 @@ input 10 - 3125 + 3125 Parent proxy -- cgit v1.2.3