Skip to content

Fix managing build-in chain on iptables nft #1261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions lib/puppet/provider/firewallchain/firewallchain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ class Puppet::Provider::Firewallchain::Firewallchain
$chain_delete_command = '-X'
# Command to set chain policy, works on inbuilt chains only
$chain_policy_command = '-P'
# Command to list specific table so it will generate necessary output for iptables-save
# The retrieval of in-built chains may get confused by `iptables-save` tendency to not return table information
# for tables that have not yet been interacted with.
$table_list_command = '-L'
# Check if the given chain name references a built in one
$built_in_regex = %r{^(?:INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING)$}

Expand Down Expand Up @@ -104,7 +100,7 @@ def create(context, name, should)
context.notice("Creating Chain '#{name}' with #{should.inspect}")
# If a built-in chain is not present we assume that corresponding table has not been interacted with
if $built_in_regex.match(should[:chain])
Puppet::Provider.execute([$base_command[should[:protocol]], should[:table], $table_list_command].join(' '))
Puppet::Provider.execute([$base_command[should[:protocol]], should[:table], $chain_policy_command, should[:chain], should[:policy].upcase].join(' '))
else
Puppet::Provider.execute([$base_command[should[:protocol]], should[:table], $chain_create_command, should[:chain]].join(' '))
end
Expand Down