On some broken Virtuozzo containers, /lib/modules/$(uname -r)/modules.dep is
absent. This causes iptables-save to give some "FATAL" errors. This patch
fixes the parser to ignore them instead of generating garbage rules that make
for errors in the puppet agent run.
# String#lines would be nice, but we need to support Ruby 1.8.5
iptables_save.split("\n").each do |line|
- unless line =~ /^\#\s+|^\:\S+|^COMMIT/
+ unless line =~ /^\#\s+|^\:\S+|^COMMIT|^FATAL/
if line =~ /^\*/
table = line.sub(/\*/, "")
else
end
end
+ it 'should ignore lines with fatal errors' do
+ provider.expects(:execute).with(['/sbin/iptables-save']).returns("FATAL: Could not load /lib/modules/2.6.18-028stab095.1/modules.dep: No such file or directory")
+
+ provider.instances.length.should == 0
+ end
+
# Load in ruby hash for test fixtures.
load 'spec/fixtures/iptables/conversion_hash.rb'