Skip to content

Commit 38e4345

Browse files
cmusikamitkarsale
authored andcommitted
Query gid to prevent errors with missing users with the same id (fixes #1229)
1 parent 69db7ef commit 38e4345

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

lib/puppet/provider/firewall/firewall.rb

+10-3
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,16 @@ def insync?(context, _name, property_name, is_hash, should_hash)
376376
end
377377

378378
# If 'is' or 'should' contain anything other than digits or digit range,
379-
# we assume that we have to do a lookup to convert to UID
380-
is = Etc.getpwnam(is).uid unless is[%r{[0-9]+(-[0-9]+)?}] == is
381-
should = Etc.getpwnam(should).uid unless should[%r{[0-9]+(-[0-9]+)?}] == should
379+
# we assume that we have to do a lookup to convert to UID or GID
380+
if property_name == :uid
381+
is = Etc.getpwnam(is).uid unless is[%r{[0-9]+(-[0-9]+)?}] == is
382+
should = Etc.getpwnam(should).uid unless should[%r{[0-9]+(-[0-9]+)?}] == should
383+
end
384+
385+
if property_name == :gid
386+
is = Etc.getgrnam(is).gid unless is[%r{[0-9]+(-[0-9]+)?}] == is
387+
should = Etc.getgrnam(should).gid unless should[%r{[0-9]+(-[0-9]+)?}] == should
388+
end
382389

383390
"#{is_negate}#{is}" == "#{should_negate}#{should}"
384391
when :mac_source, :jump

spec/acceptance/firewall_attributes_happy_path_spec.rb

+9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
describe 'attributes test' do
1313
before(:all) do
1414
pp = <<-PUPPETCODE
15+
group { 'testgroup':
16+
gid => '1234',
17+
}
1518
class { '::firewall': }
1619
firewall { '004 - log_level and log_prefix':
1720
chain => 'INPUT',
@@ -293,6 +296,12 @@ class { '::firewall': }
293296
gid => 'root',
294297
proto => 'all',
295298
}
299+
firewall { '801 - gid testgroup':
300+
chain => 'OUTPUT',
301+
jump => accept,
302+
gid => 'testgroup',
303+
proto => 'all',
304+
}
296305
firewall { '802 - gid root negated':
297306
chain => 'OUTPUT',
298307
jump => accept,

0 commit comments

Comments
 (0)