diff options
author | Marcello Coutinho <marcellocoutinho@gmail.com> | 2014-03-05 19:37:28 -0300 |
---|---|---|
committer | Marcello Coutinho <marcellocoutinho@gmail.com> | 2014-03-05 19:37:28 -0300 |
commit | 51b49f5f1a214a565194ea2db3bb0231689309c7 (patch) | |
tree | f18246df016c21174ee8edac86afb7cdd8b54728 | |
parent | 3d0aee80237aad31d19202f517fe8f4595aca538 (diff) | |
download | pfsense-packages-51b49f5f1a214a565194ea2db3bb0231689309c7.tar.gz pfsense-packages-51b49f5f1a214a565194ea2db3bb0231689309c7.tar.bz2 pfsense-packages-51b49f5f1a214a565194ea2db3bb0231689309c7.zip |
squid3-dev - improve clamav checks and fix startup erros
-rwxr-xr-x | config/squid3/33/squid.inc | 65 | ||||
-rw-r--r-- | pkg_config.10.xml | 2 | ||||
-rw-r--r-- | pkg_config.8.xml | 2 | ||||
-rw-r--r-- | pkg_config.8.xml.amd64 | 2 |
4 files changed, 53 insertions, 18 deletions
diff --git a/config/squid3/33/squid.inc b/config/squid3/33/squid.inc index c55160bc..e13e51d1 100755 --- a/config/squid3/33/squid.inc +++ b/config/squid3/33/squid.inc @@ -5,7 +5,7 @@ Copyright (C) 2006-2009 Scott Ullrich Copyright (C) 2006 Fernando Lemos Copyright (C) 2012 Martin Fuchs - Copyright (C) 2012-2013 Marcello Coutinho + Copyright (C) 2012-2014 Marcello Coutinho Copyright (C) 2013 Gekkenhuis All rights reserved. @@ -95,6 +95,15 @@ function squid_chown_recursive($dir, $user, $group) { } } +function squid_check_clamav_user($user) + { + exec("/usr/sbin/pw usershow {$user}",$sq_ex_output,$sq_ex_return); + $user_arg=($sq_ex_return == 0?"mod":"add"); + exec("/usr/sbin/pw user{$user_arg} {$user} -G wheel -u 9595 -s /sbin/nologin",$sq_ex_output,$sq_ex_return); + if ($sq_ex_return != 0) + log_error("Squid - Could not change clamav user settings. ".serialize($sq_ex_output)); + } + /* setup cache */ function squid_dash_z() { global $config; @@ -1310,8 +1319,27 @@ function squid_resync_antivirus(){ if (preg_match("/fr/i",$squid_config['error_language'])) $clwarn="clwarn.cgi.fr_FR"; if (preg_match("/pt_br/i",$squid_config['error_language'])) - $clwarn="clwarn.cgi.pt_BR"; - copy(SQUID_LOCALBASE."/libexec/squidclamav/{$clwarn}","/usr/local/www/clwarn.cgi"); + $clwarn="clwarn.cgi.pt_BR"; + $clwarn_file="/usr/local/www/clwarn.cgi"; + copy(SQUID_LOCALBASE."/libexec/squidclamav/{$clwarn}",$clwarn_file); + + #fix perl path on clwarn.cgi + $clwarn_file_new=file_get_contents($clwarn_file); + $c_pattern[]="@/usr/\S+/perl@"; + $c_replacement[]=SQUID_LOCALBASE."/bin/perl"; + /*$c_pattern[]="@redirect \S+/clwarn.cgi@"; + $gui_proto=$config['system']['webgui']['protocol']; + $gui_port=$config['system']['webgui']['port']; + if($gui_port == "") { + $gui_port($gui_proto == "http"?"80":"443"); + } + $c_replacement[]=SQUID_LOCALBASE."redirect {$gui_proto}://127.0.0.1:{$gui_port}/clwarn.cgi"; + */ + $clwarn_file_new=preg_replace($c_pattern, $c_replacement,$clwarn_file_new); + file_put_contents($clwarn_file, $clwarn_file_new,LOCK_EX); + + #fix clwarn.cgi file permission + chmod($clwarn_file,0755); $conf = <<< EOF icap_enable on @@ -1346,7 +1374,7 @@ EOF; if (!isset($clamav_clamd_enable)) $rc_file.='clamav_clamd_enable="YES"'."\n"; file_put_contents("/etc/rc.conf.local",$rc_file,LOCK_EX); - + squid_check_clamav_user('clamav'); #patch sample files to pfsense dirs #squidclamav.conf if (!file_exists(SQUID_LOCALBASE."/etc/c-icap/squidclamav.conf.sample")) @@ -1391,9 +1419,13 @@ EOF; foreach ($dirs as $dir_path => $dir_user){ if (!is_dir($dir_path)) make_dirs($dir_path); - squid_chown_recursive($dir_path, $dir_user, $dir_user); + squid_chown_recursive($dir_path, $dir_user, "wheel"); + } + #Check clamav database + if (count(glob("/var/db/clamav/*d"))==0){ + log_error("Squid - Missing /var/db/clamav/*.cvd or *.cld files. Running freshclam on background."); + mwexec_bg(SQUID_LOCALBASE."/bin/freshclam"); } - #check startup scripts on pfsense > 2.1 if (preg_match("/usr.pbi/",SQUID_LOCALBASE)){ $rcd_files = scandir(SQUID_LOCALBASE."/etc/rc.d"); @@ -1410,7 +1442,7 @@ EOF; #check antivirus daemons #check icap if (is_process_running("c-icap")){ - mwexec('/bin/echo -n "reconfigure" > /var/run/c-icap/c-icap.ctl'); + mwexec_bg('/bin/echo -n "reconfigure" > /var/run/c-icap/c-icap.ctl'); } else{ #check c-icap user on startup file @@ -1421,13 +1453,13 @@ EOF; $cicapr[0]='c_icap_user="clamav"}'; file_put_contents($c_icap_rcfile,preg_replace($cicapm,$cicapr,$sample_file),LOCK_EX); } - mwexec("/usr/local/etc/rc.d/c-icap start"); + mwexec_bg("/usr/local/etc/rc.d/c-icap start"); } #check clamav if (is_process_running("clamd")) mwexec_bg("/usr/local/etc/rc.d/clamav-clamd reload"); else - mwexec("/usr/local/etc/rc.d/clamav-clamd start"); + mwexec_bg("/usr/local/etc/rc.d/clamav-clamd start"); } return $conf; } @@ -1533,12 +1565,12 @@ include('/usr/local/pkg/squid_reverse.inc'); function squid_resync_auth() { global $config, $valid_acls; - - if (is_array($config['installedpackages']['squidauth']['config'])) - $settings = $config['installedpackages']['squidauth']['config'][0]; - else - $settings = array(); - + $write_config=0; + if (!is_array($config['installedpackages']['squidauth']['config'])){ + $config['installedpackages']['squidauth']['config'][]=array('auth_method'=> "none"); + $write_config++; + } + $settings = $config['installedpackages']['squidauth']['config'][0]; if (is_array($config['installedpackages']['squidnac']['config'])) $settingsnac = $config['installedpackages']['squidnac']['config'][0]; else @@ -1549,6 +1581,9 @@ function squid_resync_auth() { else $settingsconfig = array(); + if ($write_config > 0) + write_config(); + $conf = ''; // SSL interception acl options part 1 diff --git a/pkg_config.10.xml b/pkg_config.10.xml index 908ebf47..483e802a 100644 --- a/pkg_config.10.xml +++ b/pkg_config.10.xml @@ -965,7 +965,7 @@ <pkginfolink>http://forum.pfsense.org/index.php/topic,48347.0.html</pkginfolink> <website>http://www.squid-cache.org/</website> <category>Network</category> - <version>3.3.10 pkg 2.2</version> + <version>3.3.10 pkg 2.2.1</version> <status>beta</status> <required_version>2.2</required_version> <maintainer>marcellocoutinho@gmail.com fernando@netfilter.com.br seth.mos@dds.nl mfuchs77@googlemail.com jimp@pfsense.org</maintainer> diff --git a/pkg_config.8.xml b/pkg_config.8.xml index c7444674..f050f718 100644 --- a/pkg_config.8.xml +++ b/pkg_config.8.xml @@ -1262,7 +1262,7 @@ <pkginfolink>http://forum.pfsense.org/index.php/topic,48347.0.html</pkginfolink> <website>http://www.squid-cache.org/</website> <category>Network</category> - <version>3.3.10 pkg 2.2</version> + <version>3.3.10 pkg 2.2.1</version> <status>beta</status> <required_version>2.0</required_version> <maintainer>marcellocoutinho@gmail.com fernando@netfilter.com.br seth.mos@dds.nl mfuchs77@googlemail.com jimp@pfsense.org</maintainer> diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64 index 6ec9dca0..7ce216b9 100644 --- a/pkg_config.8.xml.amd64 +++ b/pkg_config.8.xml.amd64 @@ -1249,7 +1249,7 @@ <pkginfolink>http://forum.pfsense.org/index.php/topic,48347.0.html</pkginfolink> <website>http://www.squid-cache.org/</website> <category>Network</category> - <version>3.3.10 pkg 2.2</version> + <version>3.3.10 pkg 2.2.1</version> <status>beta</status> <required_version>2.0</required_version> <maintainer>marcellocoutinho@gmail.com fernando@netfilter.com.br seth.mos@dds.nl mfuchs77@googlemail.com jimp@pfsense.org</maintainer> |