Skip to content

Commit

Permalink
Relax passgen UID/GID logic (#275)
Browse files Browse the repository at this point in the history
* Relax passgen UID/GID logic

* Bump versioned assets
  • Loading branch information
op-ct authored Jul 8, 2022
1 parent 56f0d53 commit d1cd591
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
* Thu Jul 07 2022 Chris Tessmer <[email protected]> - 4.10.4
- Fixed
- If the user/group Puppet's settings doesn't exist on the OS,
passgen's file ownership falls back to the owner of the compiler's process

* Fri Jun 24 2022 Trevor Vaughan <[email protected]> - 4.10.3
- Fixed
- Allow `assert_optional_dependency` to handle extended version strings
Expand Down
24 changes: 21 additions & 3 deletions lib/puppet/functions/simplib/passgen/legacy/passgen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,26 @@ def passgen(identifier, modifier_hash={})
scope = closure_scope

settings = {}
settings['user'] = modifier_hash['user'] || Puppet.settings[:user]
settings['group'] = modifier_hash['group'] || Puppet.settings[:group]

user = modifier_hash['user'] || Puppet.settings[:user]
group = modifier_hash['group'] || Puppet.settings[:group]
begin
Etc.getpwnam(user)
rescue ArgumentError
debug_msg = "simpkv::passgen (legacy): Puppet user '#{user}' not found on system, "
user = Etc.getpwuid(Process.uid).name
debug_msg += "defaulting to process owner uid (#{user})"
end
begin
Etc.getgrnam(group)
rescue ArgumentError
debug_msg = "simpkv::passgen (legacy): Puppet group '#{group}' not found on system, "
group = Etc.getgrgid(Process.gid).name
debug_msg += "defaulting to process owner gid (#{group})"
end
settings['user'] = user
settings['group'] = group

settings['keydir'] = File.join(Puppet.settings[:vardir], 'simp',
'environments', scope.lookupvar('::environment'),
'simp_autofiles', 'gen_passwd'
Expand Down Expand Up @@ -355,4 +373,4 @@ def lockdown_stored_password_perms(settings)
fail(err_msg)
end
end
end
end
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simp-simplib",
"version": "4.10.3",
"version": "4.10.4",
"author": "SIMP Team",
"summary": "A collection of common SIMP functions, facts, and types",
"license": "Apache-2.0",
Expand Down

0 comments on commit d1cd591

Please sign in to comment.