Permalink
Browse files

update to install the init script in the test dir in --install-test-d…

…ir mode
  • Loading branch information...
1 parent 5c3935a commit 943a5206e10c23974a9c7db54c54b4db41b1e971 @mrash committed Apr 20, 2012
Showing with 17 additions and 10 deletions.
  1. +17 −10 install.pl
View
@@ -205,7 +205,10 @@
copy $psad_conf_file, "${psad_conf_file}.orig" or die "[*] Could not ",
"copy $psad_conf_file -> $psad_conf_file.orig";
-$install_root = getcwd() . '/test/psad-install' if $install_test_dir;
+if ($install_test_dir) {
+ $install_root = getcwd() . '/test/psad-install';
+ $init_dir = $install_root . '/etc/init.d';
+}
### import paths from default psad.conf
&import_config();
@@ -241,7 +244,7 @@
$init_dir = '/etc/rc.d';
} else {
die "[*] Cannot find the init script directory, use ",
- "--init-dir <path>";
+ "--init-dir <path>" unless $install_test_dir;
}
}
@@ -573,7 +576,7 @@ ()
### get email address(es)
my $email_str = &query_email();
if ($email_str) {
- &put_string('EMAIL_ADDRESSES', $email_str,
+ &put_var('EMAIL_ADDRESSES', $email_str,
"$config{'PSAD_CONF_DIR'}/psad.conf");
}
@@ -616,7 +619,7 @@ ()
### see if the admin would like to have psad send info to
### DShield
if (&query_dshield()) {
- &put_string('ENABLE_DSHIELD_ALERTS', 'Y',
+ &put_var('ENABLE_DSHIELD_ALERTS', 'Y',
"$config{'PSAD_CONF_DIR'}/psad.conf");
}
@@ -627,7 +630,7 @@ ()
}
if ($install_syslog_fifo) {
- &put_string('SYSLOG_DAEMON', $syslog_str,
+ &put_var('SYSLOG_DAEMON', $syslog_str,
"$config{'PSAD_CONF_DIR'}/psad.conf");
if ($syslog_str ne 'ulogd') {
@@ -800,13 +803,17 @@ ()
$USRSBIN_DIR = $config{'INSTALL_ROOT'} . $USRSBIN_DIR;
$USRBIN_DIR = $config{'INSTALL_ROOT'} . $USRBIN_DIR;
- &put_string('INSTALL_ROOT', $install_root, $psad_conf_file);
+ &put_var('INSTALL_ROOT', $install_root, $psad_conf_file);
}
for my $dir ($install_root, $USRSBIN_DIR, $USRBIN_DIR) {
&full_mkdir($dir, 0755) unless -d $dir;
}
+ if ($install_test_dir) {
+ &full_mkdir($init_dir, 0755) unless -d $init_dir;
+ }
+
### resolve internal vars within variable values
&expand_vars();
@@ -1096,7 +1103,7 @@ ()
# }
### if we make it here, then the admin wants to completely enumerate the
### HOME_NET var, so we have to disable ENABLE_INTF_LOCAL_NETS
-# &put_string('ENABLE_INTF_LOCAL_NETS', 'N',
+# &put_var('ENABLE_INTF_LOCAL_NETS', 'N',
# "$config{'PSAD_CONF_DIR'}/psad.conf");
### get all interfaces; even those that are down since they may
@@ -1175,7 +1182,7 @@ ()
}
}
$home_net_str =~ s/\,\s*$//;
- &put_string('HOME_NET', $home_net_str, $file);
+ &put_var('HOME_NET', $home_net_str, $file);
return;
}
@@ -1725,7 +1732,7 @@ ()
### we are only searching for specific iptables log prefixes
- &put_string('FW_SEARCH_ALL', 'N',
+ &put_var('FW_SEARCH_ALL', 'N',
"$config{'PSAD_CONF_DIR'}/psad.conf");
my $str =
@@ -1871,7 +1878,7 @@ ()
return $ans;
}
-sub put_string() {
+sub put_var() {
my ($var, $value, $file) = @_;
open RF, "< $file" or die "[*] Could not open $file: $!";

0 comments on commit 943a520

Please sign in to comment.