diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2009-12-24 17:13:27 -0500 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2009-12-24 17:13:33 -0500 |
commit | e56e532528386113852bd26efdd80c5a203203d2 (patch) | |
tree | 46a24829b7f03005931de04266dedcbbfd29c2d4 /etc | |
parent | 2f31946fd294ded8816b9d4c7d2e2033b5e6feb8 (diff) | |
download | pfsense-e56e532528386113852bd26efdd80c5a203203d2.zip pfsense-e56e532528386113852bd26efdd80c5a203203d2.tar.gz |
Simplify logic a bit
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/filter.inc | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc index b21dc67..ca7cff5 100644 --- a/etc/inc/filter.inc +++ b/etc/inc/filter.inc @@ -2406,28 +2406,28 @@ EOD; function discover_pkg_rules($ruletype) { global $config, $g; - if(is_dir("/usr/local/pkg")) { - $files = split("\n", trim(`ls /usr/local/pkg/*.inc`)); - foreach($files as $pkg_inc) { - if($pkg_inc == "ls: No match.") - continue; - update_filter_reload_status("Checking for {$ruletype} PF hooks in package {$pkg_inc}"); - require_once($pkg_inc); - $pkg = basename($pkg_inc); - $pkg_generate_rules = "{$pkg}_generate_rules"; - if(function_exists($pkg_generate_rules)) { - update_filter_reload_status("Processing early {$ruletype} rules for package {$pkg_inc}"); - $rules .= $pkg_generate_rules("$ruletype"); - file_put_contents("{$g['tmp_path']}/rules.packages", $rules); - $status = mwexec("/sbin/pfctl -nf {$g['tmp_path']}/rules.packages"); - if ($status <> 0) { - $errorrules = "There was an error while parsing the package filter rules for {$pkg_inc}.\n"; - log_error($errorrules); - file_put_contents("{$g['tmp_path']}/rules.packages.{$pkg_inc}", "#{$errorrules}\n"); - return ""; - } else { - return $rules; - } + if(!is_dir("/usr/local/pkg")) + return ""; + $files = split("\n", trim(`ls /usr/local/pkg/*.inc`)); + foreach($files as $pkg_inc) { + if($pkg_inc == "ls: No match.") + continue; + update_filter_reload_status("Checking for {$ruletype} PF hooks in package {$pkg_inc}"); + require_once($pkg_inc); + $pkg = basename($pkg_inc); + $pkg_generate_rules = "{$pkg}_generate_rules"; + if(function_exists($pkg_generate_rules)) { + update_filter_reload_status("Processing early {$ruletype} rules for package {$pkg_inc}"); + $rules .= $pkg_generate_rules("$ruletype"); + file_put_contents("{$g['tmp_path']}/rules.packages", $rules); + $status = mwexec("/sbin/pfctl -nf {$g['tmp_path']}/rules.packages"); + if ($status <> 0) { + $errorrules = "There was an error while parsing the package filter rules for {$pkg_inc}.\n"; + log_error($errorrules); + file_put_contents("{$g['tmp_path']}/rules.packages.{$pkg_inc}", "#{$errorrules}\n"); + return ""; + } else { + return $rules; } } } |