Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query gid to prevent errors with missing users with the same id (fixes #1229) #1251

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/puppet/provider/firewall/firewall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,16 @@ def insync?(context, _name, property_name, is_hash, should_hash)
end

# If 'is' or 'should' contain anything other than digits or digit range,
# we assume that we have to do a lookup to convert to UID
is = Etc.getpwnam(is).uid unless is[%r{[0-9]+(-[0-9]+)?}] == is
should = Etc.getpwnam(should).uid unless should[%r{[0-9]+(-[0-9]+)?}] == should
# we assume that we have to do a lookup to convert to UID or GID
if property_name == :uid
is = Etc.getpwnam(is).uid unless is[%r{[0-9]+(-[0-9]+)?}] == is
should = Etc.getpwnam(should).uid unless should[%r{[0-9]+(-[0-9]+)?}] == should
end

if property_name == :gid
is = Etc.getgrnam(is).gid unless is[%r{[0-9]+(-[0-9]+)?}] == is
should = Etc.getgrnam(should).gid unless should[%r{[0-9]+(-[0-9]+)?}] == should
end

"#{is_negate}#{is}" == "#{should_negate}#{should}"
when :mac_source, :jump
Expand Down
9 changes: 9 additions & 0 deletions spec/acceptance/firewall_attributes_happy_path_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
describe 'attributes test' do
before(:all) do
pp = <<-PUPPETCODE
group { 'testgroup':
gid => '1234',
}
class { '::firewall': }
firewall { '004 - log_level and log_prefix':
chain => 'INPUT',
Expand Down Expand Up @@ -293,6 +296,12 @@ class { '::firewall': }
gid => 'root',
proto => 'all',
}
firewall { '801 - gid testgroup':
chain => 'OUTPUT',
jump => accept,
gid => 'testgroup',
proto => 'all',
}
firewall { '802 - gid root negated':
chain => 'OUTPUT',
jump => accept,
Expand Down
Loading