Permalink
Browse files

override -O option for fwcheck_psad.pl

  • Loading branch information...
1 parent 9d7bdc7 commit 459035b1173f2136db05adbc33d1d56cb6ab8207 @mrash committed Apr 18, 2012
Showing with 22 additions and 4 deletions.
  1. +20 −4 fwcheck_psad.pl
  2. +1 −0 psad
  3. +1 −0 test/conf/normal_root_override.conf
View
@@ -38,9 +38,10 @@
### config hash
my %config = ();
+my $override_config_str = '';
### commands hash
-my %cmds;
+my %cmds = ();
### fw search string array
my @fw_search = ();
@@ -65,6 +66,7 @@
'no-fw-search-all' => \$no_fw_search_all, # looking for specific log
# prefixes
'Lib-dir=s' => \$psad_lib_dir,# Specify path to psad lib directory.
+ 'Override-config=s' => \$override_config_str,
'test-mode' => \$test_mode, # Used by the test suite.
'help' => \$help, # Display help.
));
@@ -82,9 +84,14 @@
unless -e $fw_file;
}
+### import any override config files first
+&import_override_configs() if $override_config_str;
+
### import psad.conf
&import_config($config_file);
+$enable_ipv6 = 1 if $config{'ENABLE_IPV6_DETECTION'} eq 'Y';
+
### import FW_MSG_SEARCH strings
&import_fw_search($config_file);
@@ -474,6 +481,16 @@ ()
return;
}
+sub import_override_configs() {
+ my @override_configs = split /,/, $override_config_str;
+ for my $file (@override_configs) {
+ die "[*] Override config file $file does not exist"
+ unless -e $file;
+ &import_config($file);
+ }
+ return;
+}
+
sub import_config() {
my $conf_file = shift;
@@ -489,14 +506,13 @@ ()
my $val = $2;
if ($val =~ m|/.+| and $varname =~ /^\s*(\S+)Cmd$/) {
### found a command
- $cmds{$1} = $val;
+ $cmds{$1} = $val unless defined $cmds{$1};
} else {
- $config{$varname} = $val;
+ $config{$varname} = $val unless defined $config{$varname};
}
}
}
- $enable_ipv6 = 1 if $config{'ENABLE_IPV6_DETECTION'} eq 'Y';
return;
}
View
@@ -8318,6 +8318,7 @@ sub fw_analyze_mode() {
$opts .= " --fw-file $fw_file" if $fw_file;
$opts .= " -L $lib_dir" if $lib_dir;
$opts .= " --test-mode" if $test_mode;
+ $opts .= " -O $override_config_str" if $override_config_str;
$opts .= " --no-fw-search-all" if $config{'FW_SEARCH_ALL'} eq 'N';
$exit_status = (system "$cmds{'fwcheck_psad'} $opts") >> 8;
}
@@ -0,0 +1 @@
+INSTALL_ROOT /;

0 comments on commit 459035b

Please sign in to comment.