From e01c7f37a29ccc3e8a660c3c9995fd077948cc5d Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Mon, 3 Nov 2008 18:30:18 -0800 Subject: fix for bug 3717: enforce interface restrictions --- scripts/VyattaNatRule.pm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/VyattaNatRule.pm b/scripts/VyattaNatRule.pm index a5a96ae..a648035 100644 --- a/scripts/VyattaNatRule.pm +++ b/scripts/VyattaNatRule.pm @@ -148,6 +148,10 @@ sub rule_str { $can_use_port = 0; } if (($self->{_type} eq "source") || ($self->{_type} eq "masquerade")) { + return (undef, 'cannot specify inbound interface with ' + . '"masquerade" or "source" rules') + if (defined($self->{_inbound_if})); + if ($self->{_exclude}) { $rule_str .= "-j RETURN"; } elsif ($self->{_type} eq "masquerade") { @@ -186,9 +190,6 @@ sub rule_str { $to_src .= "$start-$stop"; } - return (undef, 'cannot specify inbound interface with "masquerade"') - if (defined($self->{_inbound_if}) && ($self->{_type} eq "masquerade")); - if (($to_src ne "") && ($self->{_type} eq "masquerade")) { return (undef, "cannot specify outside IP address with \"masquerade\""); } @@ -227,6 +228,10 @@ sub rule_str { } } elsif ($self->{_type} eq "destination") { # type is destination + return (undef, + 'cannot specify outbound interface with "destination" rules') + if (defined($self->{_outbound_if})); + if ($self->{_exclude}) { $rule_str .= "-j RETURN"; } else { -- cgit v1.2.3