Skip to content

Commit 2a74cdb

Browse files
(MODULES-11580) Do not combine stderr and stdout when scanning rules
- We get the output of 'ip(6)tables-save' and parse the contents to get the iptables rules. - When stderr is combined with stdout, the output of the command can be unexpected causing issues when parsing. - This commit disables the combination of stdout and stderr for this reason. - Setting 'failonfail' makes sure that any error returned by 'ip(6)tables-save' command is reported as failure to the user without attempting to parse its output.
1 parent f2b3c6d commit 2a74cdb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/puppet/provider/firewall/firewall.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ def self.get_rules(context, basic, protocols = ['IPv4', 'IPv6'])
472472
# For each protocol
473473
protocols.each do |protocol|
474474
# Retrieve String containing all information
475-
iptables_list = Puppet::Provider.execute($list_command[protocol])
475+
iptables_list = Puppet::Provider.execute('iptables-save', combine: false, failonfail: true)
476476
# Scan String to retrieve all Rules
477477
iptables_list.scan($table_regex).each do |table|
478478
table_name = table[0].scan($table_name_regex)[0][0]

0 commit comments

Comments
 (0)