diff options
author | marcelloc <marcellocoutinho@gmail.com> | 2013-02-13 16:03:18 -0200 |
---|---|---|
committer | marcelloc <marcellocoutinho@gmail.com> | 2013-02-13 16:03:18 -0200 |
commit | 2388730502c5efed47ba808ff72abdedf20a3f2d (patch) | |
tree | 040ba19aa9a1958290d1da1da9f9dfef7b914628 | |
parent | 44150465a58c3574e76658655e5efce41f49c3ff (diff) | |
download | pfsense-packages-2388730502c5efed47ba808ff72abdedf20a3f2d.tar.gz pfsense-packages-2388730502c5efed47ba808ff72abdedf20a3f2d.tar.bz2 pfsense-packages-2388730502c5efed47ba808ff72abdedf20a3f2d.zip |
dansguardian - fix groups acls cheks, rename template xmls to avoid boot warnings and include more debug messages on dansguardian_ldap.php
-rwxr-xr-x | config/dansguardian/dansguardian.inc | 17 | ||||
-rw-r--r-- | config/dansguardian/dansguardian.xml | 6 | ||||
-rw-r--r-- | config/dansguardian/dansguardian_ips_header.template (renamed from config/dansguardian/dansguardian_ips_header.xml.template) | 0 | ||||
-rw-r--r-- | config/dansguardian/dansguardian_ldap.php | 12 | ||||
-rw-r--r-- | config/dansguardian/dansguardian_users_footer.template (renamed from config/dansguardian/dansguardian_users_footer.xml.template) | 0 | ||||
-rw-r--r-- | config/dansguardian/dansguardian_users_header.template | 99 | ||||
-rw-r--r-- | pkg_config.8.xml | 2 | ||||
-rw-r--r-- | pkg_config.8.xml.amd64 | 2 |
8 files changed, 121 insertions, 17 deletions
diff --git a/config/dansguardian/dansguardian.inc b/config/dansguardian/dansguardian.inc index e3a9e87c..8177fe3f 100755 --- a/config/dansguardian/dansguardian.inc +++ b/config/dansguardian/dansguardian.inc @@ -765,6 +765,7 @@ function sync_package_dansguardian($via_rpc=false,$install_process=false) { $dansguardian_groups[$group]=(preg_match("/$group/",$dansguardian_groups['group_options'])?"on":"off"); } + #create group list files $lists=array("phraseacl" => array("bannedphrase","weightedphrase","exceptionphrase"), "siteacl" => array("bannedsite","greysite","exceptionsite","exceptionfilesite","logsite"), @@ -775,16 +776,16 @@ function sync_package_dansguardian($via_rpc=false,$install_process=false) { "searchacl" => array("searchengineregexp","bannedsearchterm","weightedsearchterm","exceptionsearchterm") ); foreach ($lists as $list_key => $list_array){ + // verify groups acls to avoid errors on empty acl group options + if (!preg_match("/\w+/",$dansguardian_groups[$list_key])){ + log_error("dansguardian - Config warning, Group {$dansguardian_group_name} {$list_key} cannot be empty! Trying to load sample values"); + } foreach ($list_array as $list_value){ #read all access lists applied tho this group option foreach (explode(",",$dansguardian_groups[$list_key]) as $dacl){ if (! is_array(${$list_value})) ${$list_value}=array(); - // try to avoid errors on empty acl group options - if (!preg_match("/\d+/",$dacl)){ - log_error("dansguardian - Config error, Group {$dansguardian_group_name} {$list_key} cannot be empty! Trying to load default acl values"); - $dacl=0; - } + $dacl=(preg_match("/\w+/",$dacl)? $dacl : "sample"); $file_temp=file_get_contents(DANSGUARDIAN_DIR . "/etc/dansguardian/lists/{$list_value}list.{$dacl}")."\n"; ${$list_value}=array_merge(explode("\n",$file_temp),${$list_value}); } @@ -907,9 +908,9 @@ EOF; #Create/update filtergroupsiplist file_put_contents($dansguardian_dir."/lists/authplugins/ipgroups",$filtergroupsiplist,LOCK_EX); #Create/update userlist xml file - $ips_xml_header=file_get_contents("/usr/local/pkg/dansguardian_ips_header.xml.template"); - $user_xml_header=file_get_contents("/usr/local/pkg/dansguardian_users_header.xml.template"); - $user_xml_footer=file_get_contents("/usr/local/pkg/dansguardian_users_footer.xml.template"); + $ips_xml_header=file_get_contents("/usr/local/pkg/dansguardian_ips_header.template"); + $user_xml_header=file_get_contents("/usr/local/pkg/dansguardian_users_header.template"); + $user_xml_footer=file_get_contents("/usr/local/pkg/dansguardian_users_footer.template"); file_put_contents("/usr/local/pkg/dansguardian_users.xml",$user_xml_header.$user_xml.$user_xml_footer,LOCK_EX); file_put_contents("/usr/local/pkg/dansguardian_ips.xml",$ips_xml_header.$ips_xml.$user_xml_footer,LOCK_EX); diff --git a/config/dansguardian/dansguardian.xml b/config/dansguardian/dansguardian.xml index 26d87825..34d4156c 100644 --- a/config/dansguardian/dansguardian.xml +++ b/config/dansguardian/dansguardian.xml @@ -84,17 +84,17 @@ <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> - <item>http://www.pfsense.org/packages/config/dansguardian/dansguardian_ips_header.xml.template</item> + <item>http://www.pfsense.org/packages/config/dansguardian/dansguardian_ips_header.template</item> <prefix>/usr/local/pkg/</prefix> <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> - <item>http://www.pfsense.org/packages/config/dansguardian/dansguardian_users_header.xml.template</item> + <item>http://www.pfsense.org/packages/config/dansguardian/dansguardian_users_header.template</item> <prefix>/usr/local/pkg/</prefix> <chmod>0755</chmod> </additional_files_needed> <additional_files_needed> - <item>http://www.pfsense.org/packages/config/dansguardian/dansguardian_users_footer.xml.template</item> + <item>http://www.pfsense.org/packages/config/dansguardian/dansguardian_users_footer.template</item> <prefix>/usr/local/pkg/</prefix> <chmod>0755</chmod> </additional_files_needed> diff --git a/config/dansguardian/dansguardian_ips_header.xml.template b/config/dansguardian/dansguardian_ips_header.template index 48eb3e68..48eb3e68 100644 --- a/config/dansguardian/dansguardian_ips_header.xml.template +++ b/config/dansguardian/dansguardian_ips_header.template diff --git a/config/dansguardian/dansguardian_ldap.php b/config/dansguardian/dansguardian_ldap.php index beb57ee0..33cbee91 100644 --- a/config/dansguardian/dansguardian_ldap.php +++ b/config/dansguardian/dansguardian_ldap.php @@ -130,9 +130,11 @@ if (is_array($config['installedpackages']['dansguardiangroups']['config'])) } } if (empty($members)){ - $config['installedpackages']['dansguardianusers']['config'][0][strtolower($group['name'])] = NULL; - $apply_config++; - } + if (!is_null($config['installedpackages']['dansguardianusers']['config'][0][strtolower($group['name'])])){ + $config['installedpackages']['dansguardianusers']['config'][0][strtolower($group['name'])] = NULL; + $apply_config++; + } + } else{ $import_users = explode("\n", $members); asort($import_users); @@ -146,11 +148,13 @@ if (is_array($config['installedpackages']['dansguardiangroups']['config'])) $id++; } if ($apply_config > 0){ - print "user list from LDAP is different from current group, applying new configuration..."; + print "User list from LDAP is different from current group, applying new configuration..."; write_config(); include("/usr/local/pkg/dansguardian.inc"); sync_package_dansguardian(); print "done\n"; +}else { + print "User list from LDAP is already the same as current group, no changes made\n"; } #mount filesystem read-only diff --git a/config/dansguardian/dansguardian_users_footer.xml.template b/config/dansguardian/dansguardian_users_footer.template index 1288b919..1288b919 100644 --- a/config/dansguardian/dansguardian_users_footer.xml.template +++ b/config/dansguardian/dansguardian_users_footer.template diff --git a/config/dansguardian/dansguardian_users_header.template b/config/dansguardian/dansguardian_users_header.template new file mode 100644 index 00000000..1cc038d5 --- /dev/null +++ b/config/dansguardian/dansguardian_users_header.template @@ -0,0 +1,99 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd"> +<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?> +<packagegui> + <copyright> + <![CDATA[ +/* $Id$ */ +/* ========================================================================== */ +/* + dansguardian_users.xml + part of the dansguardian for pfSense + Copyright (C) 2012-2013 Marcello Coutinho + + 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. + */ +/* ========================================================================== */ + ]]> + </copyright> + <description>Describe your package here</description> + <requirements>Describe your package requirements here</requirements> + <faq>Currently there are no FAQ items provided.</faq> + <name>dansguardianusers</name> + <version>1.0</version> + <title>Services: Dansguardian</title> + <include_file>/usr/local/pkg/dansguardian.inc</include_file> + <tabs><tab> + <text>Daemon</text> + <url>/pkg_edit.php?xml=dansguardian.xml&id=0</url> + </tab> + <tab> + <text>General</text> + <url>/pkg_edit.php?xml=dansguardian_config.xml&id=0</url> + </tab> + <tab> + <text>Limits</text> + <url>/pkg_edit.php?xml=dansguardian_limits.xml&id=0</url> + </tab> + <tab> + <text>Blacklist</text> + <url>/pkg_edit.php?xml=dansguardian_blacklist.xml&id=0</url> + </tab> + <tab> + <text>ACLs</text> + <url>/pkg.php?xml=dansguardian_site_acl.xml</url> + </tab> + <tab> + <text>LDAP</text> + <url>/pkg.php?xml=dansguardian_ldap.xml</url> + </tab> + <tab> + <text>Groups</text> + <url>/pkg.php?xml=dansguardian_groups.xml</url> + </tab> + <tab> + <text>Users</text> + <url>/pkg_edit.php?xml=dansguardian_users.xml</url> + <active/> + </tab> + <tab> + <text>IPs</text> + <url>/pkg_edit.php?xml=dansguardian_ips.xml</url> + </tab> + <tab> + <text>Report and log</text> + <url>/pkg_edit.php?xml=dansguardian_log.xml&id=0</url> + </tab> + <tab> + <text>Sync</text> + <url>/pkg_edit.php?xml=dansguardian_sync.xml&id=0</url> + </tab> + <tab> + <text>Help</text> + <url>/dansguardian_about.php</url> + </tab> +</tabs> + <fields> diff --git a/pkg_config.8.xml b/pkg_config.8.xml index ed31f29c..028bfe30 100644 --- a/pkg_config.8.xml +++ b/pkg_config.8.xml @@ -613,7 +613,7 @@ <depends_on_package>dansguardian-2.12.0.3.tbz</depends_on_package> <depends_on_package>ca_root_nss-3.14.1.tbz</depends_on_package> <depends_on_package_pbi>dansguardian-2.12.0.3-i386.pbi</depends_on_package_pbi> - <version>2.12.0.3 pkg v.0.1.7_2</version> + <version>2.12.0.3 pkg v.0.1.7_3</version> <status>beta</status> <required_version>2.0</required_version> <configurationfile>dansguardian.xml</configurationfile> diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64 index c1f2f4f0..ef7fac47 100644 --- a/pkg_config.8.xml.amd64 +++ b/pkg_config.8.xml.amd64 @@ -600,7 +600,7 @@ <depends_on_package>dansguardian-2.12.0.3.tbz</depends_on_package> <depends_on_package>ca_root_nss-3.14.1.tbz</depends_on_package> <depends_on_package_pbi>dansguardian-2.12.0.3-amd64.pbi</depends_on_package_pbi> - <version>2.12.0.3 pkg v.0.1.7_2</version> + <version>2.12.0.3 pkg v.0.1.7_3</version> <status>beta</status> <required_version>2.0</required_version> <configurationfile>dansguardian.xml</configurationfile> |