Commit f5b30d19 authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Add -t option to specify the firewall type.

parent 37749d5f
...@@ -26,11 +26,12 @@ use English; ...@@ -26,11 +26,12 @@ use English;
my $datafile = "fw-rules"; my $datafile = "fw-rules";
my $optlist = "eMIf:"; my $optlist = "eMIf:t:";
my $domysql = 0; my $domysql = 0;
my $doiptables = 1; my $doiptables = 1;
my $expand = 0; my $expand = 0;
my $qualifiers = 0; my $qualifiers = 0;
my $type = "iptables-vlan";
my @lines; my @lines;
sub usage() sub usage()
...@@ -41,8 +42,10 @@ sub usage() ...@@ -41,8 +42,10 @@ sub usage()
" -q include qualifiers\n". " -q include qualifiers\n".
" -M generate mysql commands\n". " -M generate mysql commands\n".
" -I generate iptables commands\n". " -I generate iptables commands\n".
" -t type defaults to iptables-vlan\n".
"\n". "\n".
" Valid configs are: open, closed, basic, elabinelab\n"; " Valid configs are: open, closed, basic, elabinelab\n".
" Valid types are: iptables-vlan, iptables-dom0\n";
exit(1); exit(1);
} }
...@@ -83,11 +86,11 @@ sub expandfwvars($) ...@@ -83,11 +86,11 @@ sub expandfwvars($)
return $rule; return $rule;
} }
sub doconfig($) sub doconfig($$)
{ {
my ($config) = @_; my ($config,$type) = @_;
my $ruleno = 1; my $ruleno = 1;
my ($type, $style, $enabled); my ($style, $enabled);
if ($doiptables) { if ($doiptables) {
print "# $config\n"; print "# $config\n";
...@@ -95,7 +98,6 @@ sub doconfig($) ...@@ -95,7 +98,6 @@ sub doconfig($)
print "iptables -X\n"; print "iptables -X\n";
} }
if ($domysql) { if ($domysql) {
$type = "iptables-vlan";
$style = lc($config); $style = lc($config);
# XXX # XXX
$style = "emulab" if ($style eq "elabinelab"); $style = "emulab" if ($style eq "elabinelab");
...@@ -159,6 +161,9 @@ if (defined($options{"e"})) { ...@@ -159,6 +161,9 @@ if (defined($options{"e"})) {
if (defined($options{"f"})) { if (defined($options{"f"})) {
$datafile = $options{"f"}; $datafile = $options{"f"};
} }
if (defined($options{"t"})) {
$type = $options{"t"};
}
if (defined($options{"q"})) { if (defined($options{"q"})) {
$qualifiers = 1; $qualifiers = 1;
} }
...@@ -169,6 +174,6 @@ if (@ARGV == 0) { ...@@ -169,6 +174,6 @@ if (@ARGV == 0) {
@lines = `cat $datafile`; @lines = `cat $datafile`;
foreach my $config (@ARGV) { foreach my $config (@ARGV) {
$config = uc($config); $config = uc($config);
doconfig($config); doconfig($config,$type);
} }
exit(0); exit(0);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment