Skip to content

Commit d38b91a

Browse files
author
Morgan Haskel
committed
MODULES-1552 - Issues parsing -m (tcp|udp) rules
The parser was arbitrarily requiring `--(d|s)port` or `-m multiport` with `-m tcp` or `-m udp`.
1 parent e735291 commit d38b91a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/puppet/provider/firewall/iptables.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def self.rule_to_hash(line, table, counter)
233233
# the actual rule will have the ! mark before the option.
234234
values = values.gsub(/(!)\s*(-\S+)\s*(\S*)/, '\2 "\1 \3"')
235235
# The match extension for tcp & udp are optional and throws off the @resource_map.
236-
values = values.gsub(/-m (tcp|udp) (--(s|d)port|-m multiport)/, '\2')
236+
values = values.gsub(/-m (tcp|udp)/, '')
237237
# '--pol ipsec' takes many optional arguments; we cheat again by adding " around them
238238
values = values.sub(/
239239
--pol\sipsec

spec/acceptance/resource_cmd_spec.rb

+15
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,21 @@
133133
end
134134
end
135135

136+
context 'accepts rules with -m (tcp|udp) without dport/sport' do
137+
before :all do
138+
iptables_flush_all_tables
139+
shell('iptables -A INPUT -s 10.0.0.0/8 -p udp -m udp -j ACCEPT')
140+
end
141+
142+
it do
143+
shell('puppet resource firewall') do |r|
144+
r.exit_code.should be_zero
145+
# don't check stdout, testing preexisting rules, output is normal
146+
r.stderr.should be_empty
147+
end
148+
end
149+
end
150+
136151
# version of iptables that ships with el5 doesn't work with the
137152
# ip6tables provider
138153
if default['platform'] !~ /el-5/

0 commit comments

Comments
 (0)