Skip to content

Commit 0245f51

Browse files
committed
Merge pull request #479 from mhaskel/MODULES-1453
MODULES-1453 - overly aggressive gsub
2 parents 4fa0976 + ce98905 commit 0245f51

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

lib/puppet/provider/firewall/iptables.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ def update_args
438438

439439
def delete_args
440440
# Split into arguments
441-
line = properties[:line].gsub(/\-A/, '-D').split(/\s(?=(?:[^"]|"[^"]*")*$)/).map{|v| v.gsub(/"/, '')}
441+
line = properties[:line].gsub(/\-A /, '-D ').split(/\s(?=(?:[^"]|"[^"]*")*$)/).map{|v| v.gsub(/"/, '')}
442442
line.unshift("-t", properties[:table])
443443
end
444444

spec/acceptance/firewall_spec.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,4 +2207,43 @@ class { '::firewall': }
22072207
end
22082208
end
22092209

2210+
context 'log_prefix containing -A' do
2211+
it 'adds the rule' do
2212+
pp = <<-EOS
2213+
class { '::firewall': }
2214+
firewall { '700 - test':
2215+
jump => 'LOG',
2216+
log_prefix => 'FW-A-INPUT: ',
2217+
}
2218+
EOS
2219+
2220+
apply_manifest(pp, :catch_failures => true)
2221+
end
2222+
2223+
it 'should contain the rule' do
2224+
shell('iptables-save') do |r|
2225+
expect(r.stdout).to match(/-A INPUT -p tcp -m comment --comment "100 foo bar" -j LOG --log-prefix "FW-A-INPUT: "/)
2226+
end
2227+
end
2228+
2229+
it 'removes the rule' do
2230+
pp = <<-EOS
2231+
class { '::firewall': }
2232+
firewall { '700 - test':
2233+
ensure => absent,
2234+
jump => 'LOG',
2235+
log_prefix => 'FW-A-INPUT: ',
2236+
}
2237+
EOS
2238+
2239+
apply_manifest(pp, :catch_failures => true)
2240+
end
2241+
2242+
it 'should not contain the rule' do
2243+
shell('iptables-save') do |r|
2244+
expect(r.stdout).to_not match(/-A INPUT -p tcp -m comment --comment "100 foo bar" -j LOG --log-prefix "FW-A-INPUT: "/)
2245+
end
2246+
end
2247+
end
2248+
22102249
end

0 commit comments

Comments
 (0)