summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authordamien <damien@mandriva.com>2001-03-24 07:48:04 +0000
committerdamien <damien@mandriva.com>2001-03-24 07:48:04 +0000
commitadce7bdcaaf2c6c11d487e614055534ef2a6d108 (patch)
tree8b77e2695969deb281207dc67fd3efba88128159 /perl-install
parent45e2c4a8a65a60291e176a5606707216fb8a3490 (diff)
downloaddrakx-adce7bdcaaf2c6c11d487e614055534ef2a6d108.tar
drakx-adce7bdcaaf2c6c11d487e614055534ef2a6d108.tar.gz
drakx-adce7bdcaaf2c6c11d487e614055534ef2a6d108.tar.bz2
drakx-adce7bdcaaf2c6c11d487e614055534ef2a6d108.tar.xz
drakx-adce7bdcaaf2c6c11d487e614055534ef2a6d108.zip
corrected bad exited. reincorporated some ugly code, need fixing
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/tinyfirewall.pm38
1 files changed, 33 insertions, 5 deletions
diff --git a/perl-install/tinyfirewall.pm b/perl-install/tinyfirewall.pm
index 20ab08d36..54d9d4e82 100644
--- a/perl-install/tinyfirewall.pm
+++ b/perl-install/tinyfirewall.pm
@@ -58,9 +58,32 @@ my %settings;
my $config_file = "/etc/Bastille/bastille-firewall.cfg";
my $default_config_file = "/usr/share/Bastille/bastille-firewall.cfg"; # set this later
sub ReadConfig {
- -e $config_file or cp($default_config_file, $config_file);
+ -e $config_file or commands::cp($default_config_file, $config_file);
add2hash(\%settings, { getVarsFromSh("$config_file") });
}
+sub SaveConfig {
+ my $tmp_file = tmpnam();
+ open CONFIGFILE, "$config_file"
+ or die "Can't open $config_file: $!\n";
+ open TMPFILE, ">$tmp_file"
+ or die "Can't open $tmp_file for writing: $!\n";
+ while (my $line = <CONFIGFILE>)
+ {
+ if ($line =~ m/^(.+)\s*\=\s*\"(.*)\"/)
+ {
+ my ($variable, $value) = ($1, $2);
+ my $newvalue = $settings{$variable};
+ $line =~ s/\".*\"/\"$newvalue\"/
+ if (exists $settings{$variable});
+ }
+ print TMPFILE $line;
+ }
+ close CONFIGFILE;
+ close TMPFILE;
+ rename ($config_file, $config_file . ".orig");
+ system ("/bin/cp $tmp_file $config_file");
+ system ("/bin/rm $tmp_file");
+}
sub DoInterface {
my ($in)=@_;
$::isWizard=1;
@@ -93,11 +116,16 @@ sub DoInterface {
} else { $settings{DHCP_IFACES} = "" } };
my $quit = sub {
$_[0] or $in->exit(0);
- cp("-f", $config_file, $config_file . ".orig");
- my $tmp_file = tmpnam();
+ SaveConfig();
+ $in->exit(0);
+ return;
+ $_[0] or $in->exit(0);
+ commands::cp("-f", $config_file, $config_file . ".orig");
substInFile {
- /^(.+)\s*\=/;
- s/\".*\"/\"$settings{$1}\"/
+ if(/^(.+)\s*\=/) {
+ $a=$settings{$1};
+ s/\".*\"/\"$a\"/;
+ }
} $config_file;
map { system($_) } ("/bin/cp /usr/share/Bastille/bastille-ipchains /usr/share/Bastille/bastille-netfilter /sbin",
"/bin/cp /usr/share/Bastille/bastille-firewall /etc/rc.d/init.d/",