Skip to content

Commit 41c3f55

Browse files
Make mode options for '-m recent' parse correctly
Options setting the mode of operation for the 'recent' match extension no longer parse from existing rule definitions with their long-option double-dashes still included. Note that these options are meant to be bang-invertible, but this module does not support that use case (and currently will explode if it encounters any such rule).
1 parent f5c266b commit 41c3f55

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/puppet/provider/firewall/iptables.rb

+4
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,10 @@ def self.rule_to_hash(line, table, counter)
585585
rpfilter_opts = values.scan(%r{-m\srpfilter(?:\s--(loose)|\s--(validmark)|\s--(accept-local)|\s--(invert))+}).flatten.compact
586586
values.sub!(%r{-m\srpfilter(?:\s--(?:loose|validmark|accept-local|invert))+}, "-m rpfilter #{rpfilter_opts.join(',')}")
587587

588+
# For recent matching, the 'recent' param takes the name of the long opt that should follow '-m recent',
589+
# which otherwise gets parsed out with the double-dashes for the long opt still present
590+
values.gsub!(%r{#{@resource_map[:recent]}\s--(set|rcheck|update|remove)}, "#{@resource_map[:recent]} \\1")
591+
588592
# on some iptables versions, --connlimit-saddr switch is added after the rule is applied
589593
values = values.gsub(%r{--connlimit-saddr}, '')
590594

0 commit comments

Comments
 (0)