Skip to content

Commit b52b0eb

Browse files
author
Max Vozeler
committed
Fix handling of chain names that contain -f
1 parent 2d870c4 commit b52b0eb

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/puppet/provider/firewall/iptables.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def self.rule_to_hash(line, table, counter)
356356
# -f requires special matching:
357357
# only replace those -f that are not followed by an l to
358358
# distinguish between -f and the '-f' inside of --tcp-flags.
359-
values = values.sub(/-f(?!l)(?=.*--comment)/, '-f true')
359+
values = values.sub(/\s-f(?!l)(?=.*--comment)/, ' -f true')
360360
else
361361
values = values.sub(/#{resource_map[bool]}/, "#{resource_map[bool]} true")
362362
end

spec/fixtures/iptables/conversion_hash.rb

+8
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,14 @@
573573
:clamp_mss_to_pmtu => true,
574574
},
575575
},
576+
'mangled_chain_name_with_-f' => {
577+
:line => '-A foo-filter -p tcp -m comment --comment "068 chain name containing -f" -j ACCEPT',
578+
:params => {
579+
:name => '068 chain name containing -f',
580+
:action => 'accept',
581+
:chain => 'foo-filter',
582+
},
583+
},
576584
}
577585

578586
# This hash is for testing converting a hash to an argument line.

0 commit comments

Comments
 (0)