Button to apply saved rules

This commit is contained in:
Jamie Cameron
2015-06-08 22:50:34 -07:00
parent f4bb5a843a
commit f2d77a7bee
4 changed files with 27 additions and 6 deletions

View File

@@ -7,8 +7,6 @@
# XXX detect use of firewalld in iptables modules
# XXX locking and logging
# XXX default action for a zone
# XXX actually apply rules
# XXX bootup script
BEGIN { push(@INC, ".."); };
use strict;
@@ -126,5 +124,13 @@ my $out = &backquote_logged("$config{'firewall_cmd'} ".
return $? ? $out : undef;
}
# apply_firewalld()
# Make the current saved config active
sub apply_firewalld
{
my $out = &backquote_logged("$config{'firewall_cmd'} --reload 2>&1");
return $? ? $out : undef;
}
1;

View File

@@ -82,13 +82,16 @@ print &ui_buttons_start();
my $ok = &is_firewalld_running();
if ($ok) {
print &ui_buttons_row("restart.cgi", $text{'index_restart'},
$text{'index_restartdesc'});
$text{'index_restartdesc'},
[ [ "zone", $zone->{'name'} ] ]);
print &ui_buttons_row("stop.cgi", $text{'index_stop'},
$text{'index_stopdesc'});
$text{'index_stopdesc'},
[ [ "zone", $zone->{'name'} ] ]);
}
else {
print &ui_buttons_row("start.cgi", $text{'index_start'},
$text{'index_startdesc'});
$text{'index_startdesc'},
[ [ "zone", $zone->{'name'} ] ]);
}
# Enable at boot

View File

@@ -5,7 +5,7 @@ index_bootupdesc=Change this option to control whether your firewall is activate
index_apply=Apply Configuration
index_applydesc=Click this button to make the firewall configuration listed above active. Any firewall rules currently in effect will be flushed and replaced
index_restart=Apply Configuration
index_restartdesc=Activate all the rules listed above for all zones.
index_restartdesc=Activate all the allowed services and ports listed above, in all zones. Any active rules that were not permanently created will be replaced.
index_start=Start FirewallD
index_startdesc=Start the FirewallD server and apply the rules listed above.
index_stop=Stop FirewallD

12
firewalld/restart.cgi Normal file
View File

@@ -0,0 +1,12 @@
#!/usr/local/bin/perl
# Activate all saved firewalld rules
use strict;
use warnings;
require './firewalld-lib.pl';
our (%text);
&error_setup($text{'restart_err'});
my $err = &apply_firewalld();
&error($err) if ($err);
&webmin_log("restart");
&redirect("index.cgi?zone=".&urlize($in{'zone'}));