Use correct state flag during initial rule setup https://github.com/webmin/webmin/issues/2264

This commit is contained in:
Jamie Cameron
2024-09-05 11:31:52 -07:00
parent c607990c48
commit 6b2a9d34bf
2 changed files with 12 additions and 8 deletions

View File

@ -83,6 +83,8 @@ if ($in{'auto'}) {
'rules' => [ ], 'rules' => [ ],
'defaults' => { } }; 'defaults' => { } };
$table->{'defaults'}->{'INPUT'} = 'DROP'; $table->{'defaults'}->{'INPUT'} = 'DROP';
my $sd = &supports_conntrack() ? "ctstate" : "state";
my $sm = $sd eq "state" ? "state" : "conntrack";
push(@{$table->{'rules'}}, push(@{$table->{'rules'}},
{ 'chain' => 'INPUT', { 'chain' => 'INPUT',
'i' => [ "!", $iface ], 'i' => [ "!", $iface ],
@ -95,13 +97,13 @@ if ($in{'auto'}) {
'j' => [ "", 'ACCEPT' ], 'j' => [ "", 'ACCEPT' ],
'cmt' => 'Accept traffic with the ACK flag set' }, 'cmt' => 'Accept traffic with the ACK flag set' },
{ 'chain' => 'INPUT', { 'chain' => 'INPUT',
'm' => [ [ "", "state" ] ], 'm' => [ [ "", $sm ] ],
'state' => [ "", "ESTABLISHED" ], $sd => [ "", "ESTABLISHED" ],
'j' => [ "", 'ACCEPT' ], 'j' => [ "", 'ACCEPT' ],
'cmt' => 'Allow incoming data that is part of a connection we established' }, 'cmt' => 'Allow incoming data that is part of a connection we established' },
{ 'chain' => 'INPUT', { 'chain' => 'INPUT',
'm' => [ [ "", "state" ] ], 'm' => [ [ "", $sm ] ],
'state' => [ "", "RELATED" ], $sd => [ "", "RELATED" ],
'j' => [ "", 'ACCEPT' ], 'j' => [ "", 'ACCEPT' ],
'cmt' => 'Allow data that is related to existing connections' }, 'cmt' => 'Allow data that is related to existing connections' },
{ 'chain' => 'INPUT', { 'chain' => 'INPUT',

View File

@ -78,6 +78,8 @@ if ($in{'auto'}) {
'rules' => [ ], 'rules' => [ ],
'defaults' => { } }; 'defaults' => { } };
$table->{'defaults'}->{'INPUT'} = 'DROP'; $table->{'defaults'}->{'INPUT'} = 'DROP';
my $sd = &supports_conntrack() ? "ctstate" : "state";
my $sm = $sd eq "state" ? "state" : "conntrack";
push(@{$table->{'rules'}}, push(@{$table->{'rules'}},
{ 'chain' => 'INPUT', { 'chain' => 'INPUT',
'i' => [ "!", $iface ], 'i' => [ "!", $iface ],
@ -90,13 +92,13 @@ if ($in{'auto'}) {
'j' => [ "", 'ACCEPT' ], 'j' => [ "", 'ACCEPT' ],
'cmt' => 'Accept traffic with the ACK flag set' }, 'cmt' => 'Accept traffic with the ACK flag set' },
{ 'chain' => 'INPUT', { 'chain' => 'INPUT',
'm' => [ [ "", "state" ] ], 'm' => [ [ "", $sm ] ],
'state' => [ "", "ESTABLISHED" ], $sd => [ "", "ESTABLISHED" ],
'j' => [ "", 'ACCEPT' ], 'j' => [ "", 'ACCEPT' ],
'cmt' => 'Allow incoming data that is part of a connection we established' }, 'cmt' => 'Allow incoming data that is part of a connection we established' },
{ 'chain' => 'INPUT', { 'chain' => 'INPUT',
'm' => [ [ "", "state" ] ], 'm' => [ [ "", $sm ] ],
'state' => [ "", "RELATED" ], $sd => [ "", "RELATED" ],
'j' => [ "", 'ACCEPT' ], 'j' => [ "", 'ACCEPT' ],
'cmt' => 'Allow data that is related to existing connections' }, 'cmt' => 'Allow data that is related to existing connections' },
{ 'chain' => 'INPUT', { 'chain' => 'INPUT',