Skip to content

Commit 61e2241

Browse files
(maint) Merge up 9746d17 to main
Generated by CI * commit '9746d178a8533beaf4c63e6d32a1c813cb00b869': (packaging) Updating manpage file for 6.x (PUP-10857) Cache final result instead of file content (PUP-10857) Find groups locally with useradd provider (maint) Fix local gid for useradd provider (maint) Fix property list retrieval for Array Conflicts: man/man8/puppet-key.8 man/man8/puppet-man.8 man/man8/puppet-status.8
2 parents a0edb30 + 9746d17 commit 61e2241

23 files changed

+147
-40
lines changed

lib/puppet/property/list.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def retrieve
4747
#ok, some 'convention' if the list property is named groups, provider should implement a groups method
4848
tmp = provider.send(name) if provider
4949
if tmp && tmp != :absent
50-
return tmp.split(delimiter)
50+
return tmp.instance_of?(Array) ? tmp : tmp.split(delimiter)
5151
else
5252
return :absent
5353
end

lib/puppet/provider/group/groupadd.rb

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,21 @@ def purge_members
130130
private
131131

132132
def findgroup(key, value)
133-
group_file = "/etc/group"
133+
group_file = '/etc/group'
134134
group_keys = [:group_name, :password, :gid, :user_list]
135-
index = group_keys.index(key)
136-
@group_content ||= File.read(group_file)
137-
@group_content.each_line do |line|
138-
group = line.split(":")
139-
if group[index] == value
140-
return Hash[group_keys.zip(group)]
135+
136+
unless @groups
137+
unless Puppet::FileSystem.exist?(group_file)
138+
raise Puppet::Error.new("Forcelocal set for group resource '#{resource[:name]}', but #{group_file} does not exist")
139+
end
140+
141+
@groups = []
142+
Puppet::FileSystem.each_line(group_file) do |line|
143+
group = line.chomp.split(':')
144+
@groups << Hash[group_keys.zip(group)]
141145
end
142146
end
143-
false
147+
148+
@groups.find { |param| param[key] == value } || false
144149
end
145150
end

lib/puppet/provider/user/useradd.rb

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,37 @@ def uid
5959
get(:uid)
6060
end
6161

62+
def gid
63+
return localgid if @resource.forcelocal?
64+
get(:gid)
65+
end
66+
6267
def comment
6368
return localcomment if @resource.forcelocal?
6469
get(:comment)
6570
end
6671

72+
def groups
73+
return localgroups if @resource.forcelocal?
74+
get(:groups)
75+
end
76+
6777
def finduser(key, value)
68-
passwd_file = "/etc/passwd"
78+
passwd_file = '/etc/passwd'
6979
passwd_keys = [:account, :password, :uid, :gid, :gecos, :directory, :shell]
70-
index = passwd_keys.index(key)
71-
@passwd_content ||= File.read(passwd_file)
72-
@passwd_content.each_line do |line|
73-
user = line.split(":")
74-
if user[index] == value
75-
return Hash[passwd_keys.zip(user)]
80+
81+
unless @users
82+
unless Puppet::FileSystem.exist?(passwd_file)
83+
raise Puppet::Error.new("Forcelocal set for user resource '#{resource[:name]}', but #{passwd_file} does not exist")
84+
end
85+
86+
@users = []
87+
Puppet::FileSystem.each_line(passwd_file) do |line|
88+
user = line.chomp.split(':')
89+
@users << Hash[passwd_keys.zip(user)]
7690
end
7791
end
78-
false
92+
@users.find { |param| param[key] == value } || false
7993
end
8094

8195
def local_username
@@ -88,16 +102,49 @@ def localuid
88102
false
89103
end
90104

105+
def localgid
106+
user = finduser(:account, resource[:name])
107+
return user[:gid] if user
108+
false
109+
end
110+
91111
def localcomment
92112
user = finduser(:account, resource[:name])
93113
user[:gecos]
94114
end
95115

116+
def localgroups
117+
@groups_of ||= {}
118+
group_file = '/etc/group'
119+
user = resource[:name]
120+
121+
return @groups_of[user] if @groups_of[user]
122+
123+
@groups_of[user] = []
124+
125+
unless Puppet::FileSystem.exist?(group_file)
126+
raise Puppet::Error.new("Forcelocal set for user resource '#{user}', but #{group_file} does not exist")
127+
end
128+
129+
Puppet::FileSystem.each_line(group_file) do |line|
130+
data = line.chomp.split(':')
131+
if data.last.split(',').include?(user)
132+
@groups_of[user] << data.first
133+
end
134+
end
135+
136+
@groups_of[user]
137+
end
138+
96139
def shell=(value)
97140
check_valid_shell
98141
set(:shell, value)
99142
end
100143

144+
def groups=(value)
145+
set(:groups, value)
146+
end
147+
101148
verify :gid, "GID must be an integer" do |value|
102149
value.is_a? Integer
103150
end

man/man8/puppet-agent.8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.\" generated with Ronn/v0.7.3
22
.\" http://github.com/rtomayko/ronn/tree/0.7.3
33
.
4-
.TH "PUPPET\-AGENT" "8" "January 2021" "Puppet, Inc." "Puppet manual"
4+
.TH "PUPPET\-AGENT" "8" "February 2021" "Puppet, Inc." "Puppet manual"
55
.
66
.SH "NAME"
77
\fBpuppet\-agent\fR \- The puppet agent daemon

man/man8/puppet-apply.8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.\" generated with Ronn/v0.7.3
22
.\" http://github.com/rtomayko/ronn/tree/0.7.3
33
.
4-
.TH "PUPPET\-APPLY" "8" "January 2021" "Puppet, Inc." "Puppet manual"
4+
.TH "PUPPET\-APPLY" "8" "February 2021" "Puppet, Inc." "Puppet manual"
55
.
66
.SH "NAME"
77
\fBpuppet\-apply\fR \- Apply Puppet manifests locally

man/man8/puppet-catalog.8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.\" generated with Ronn/v0.7.3
22
.\" http://github.com/rtomayko/ronn/tree/0.7.3
33
.
4-
.TH "PUPPET\-CATALOG" "8" "January 2021" "Puppet, Inc." "Puppet manual"
4+
.TH "PUPPET\-CATALOG" "8" "February 2021" "Puppet, Inc." "Puppet manual"
55
.
66
.SH "NAME"
77
\fBpuppet\-catalog\fR \- Compile, save, view, and convert catalogs\.

man/man8/puppet-config.8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.\" generated with Ronn/v0.7.3
22
.\" http://github.com/rtomayko/ronn/tree/0.7.3
33
.
4-
.TH "PUPPET\-CONFIG" "8" "January 2021" "Puppet, Inc." "Puppet manual"
4+
.TH "PUPPET\-CONFIG" "8" "February 2021" "Puppet, Inc." "Puppet manual"
55
.
66
.SH "NAME"
77
\fBpuppet\-config\fR \- Interact with Puppet\'s settings\.

man/man8/puppet-describe.8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.\" generated with Ronn/v0.7.3
22
.\" http://github.com/rtomayko/ronn/tree/0.7.3
33
.
4-
.TH "PUPPET\-DESCRIBE" "8" "January 2021" "Puppet, Inc." "Puppet manual"
4+
.TH "PUPPET\-DESCRIBE" "8" "February 2021" "Puppet, Inc." "Puppet manual"
55
.
66
.SH "NAME"
77
\fBpuppet\-describe\fR \- Display help about resource types

man/man8/puppet-device.8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.\" generated with Ronn/v0.7.3
22
.\" http://github.com/rtomayko/ronn/tree/0.7.3
33
.
4-
.TH "PUPPET\-DEVICE" "8" "January 2021" "Puppet, Inc." "Puppet manual"
4+
.TH "PUPPET\-DEVICE" "8" "February 2021" "Puppet, Inc." "Puppet manual"
55
.
66
.SH "NAME"
77
\fBpuppet\-device\fR \- Manage remote network devices

man/man8/puppet-doc.8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.\" generated with Ronn/v0.7.3
22
.\" http://github.com/rtomayko/ronn/tree/0.7.3
33
.
4-
.TH "PUPPET\-DOC" "8" "January 2021" "Puppet, Inc." "Puppet manual"
4+
.TH "PUPPET\-DOC" "8" "February 2021" "Puppet, Inc." "Puppet manual"
55
.
66
.SH "NAME"
77
\fBpuppet\-doc\fR \- Generate Puppet references

0 commit comments

Comments
 (0)