Skip to content

Commit d1cd591

Browse files
authored
Relax passgen UID/GID logic (#275)
* Relax passgen UID/GID logic * Bump versioned assets
1 parent 56f0d53 commit d1cd591

3 files changed

Lines changed: 27 additions & 4 deletions

File tree

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
* Thu Jul 07 2022 Chris Tessmer <chris.tessmer@onyxpoint.com> - 4.10.4
2+
- Fixed
3+
- If the user/group Puppet's settings doesn't exist on the OS,
4+
passgen's file ownership falls back to the owner of the compiler's process
5+
16
* Fri Jun 24 2022 Trevor Vaughan <tvaughan@sicura.us> - 4.10.3
27
- Fixed
38
- Allow `assert_optional_dependency` to handle extended version strings

lib/puppet/functions/simplib/passgen/legacy/passgen.rb

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,26 @@ def passgen(identifier, modifier_hash={})
6161
scope = closure_scope
6262

6363
settings = {}
64-
settings['user'] = modifier_hash['user'] || Puppet.settings[:user]
65-
settings['group'] = modifier_hash['group'] || Puppet.settings[:group]
64+
65+
user = modifier_hash['user'] || Puppet.settings[:user]
66+
group = modifier_hash['group'] || Puppet.settings[:group]
67+
begin
68+
Etc.getpwnam(user)
69+
rescue ArgumentError
70+
debug_msg = "simpkv::passgen (legacy): Puppet user '#{user}' not found on system, "
71+
user = Etc.getpwuid(Process.uid).name
72+
debug_msg += "defaulting to process owner uid (#{user})"
73+
end
74+
begin
75+
Etc.getgrnam(group)
76+
rescue ArgumentError
77+
debug_msg = "simpkv::passgen (legacy): Puppet group '#{group}' not found on system, "
78+
group = Etc.getgrgid(Process.gid).name
79+
debug_msg += "defaulting to process owner gid (#{group})"
80+
end
81+
settings['user'] = user
82+
settings['group'] = group
83+
6684
settings['keydir'] = File.join(Puppet.settings[:vardir], 'simp',
6785
'environments', scope.lookupvar('::environment'),
6886
'simp_autofiles', 'gen_passwd'
@@ -355,4 +373,4 @@ def lockdown_stored_password_perms(settings)
355373
fail(err_msg)
356374
end
357375
end
358-
end
376+
end

metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simp-simplib",
3-
"version": "4.10.3",
3+
"version": "4.10.4",
44
"author": "SIMP Team",
55
"summary": "A collection of common SIMP functions, facts, and types",
66
"license": "Apache-2.0",

0 commit comments

Comments
 (0)