5 # Copyright:: 2010, OpenStreetMap Foundation
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # https://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
22 administrators = node[:accounts][:administrators].to_a
24 search(:accounts, "*:*").each do |account|
26 details = node[:accounts][:users][name] || {}
29 group_members = details[:members] || account["members"] || []
30 user_home = details[:home] || account["home"] || "#{node[:accounts][:home]}/#{name}"
31 manage_user_home = details.fetch(:manage_home, account.fetch("manage_home", node[:accounts][:manage_home]))
33 group_members = group_members.collect(&:to_s).sort
37 user_shell = "/usr/sbin/nologin"
38 when "user", "administrator"
39 user_shell = details[:shell] || account["shell"] || node[:accounts][:shell]
42 available_users = if node[:etc]
43 node[:etc][:passwd].keys
49 gid account["uid"].to_i
50 members group_members & available_users
54 uid account["uid"].to_i
55 gid account["uid"].to_i
56 comment account["comment"] if account["comment"]
59 manage_home manage_user_home
62 remote_directory "/home/#{name}" do
72 cookbook = run_context.cookbook_collection[cookbook_name]
73 files = cookbook.relative_filenames_in_preferred_directory(node, :files, name.to_s)
75 rescue Chef::Exceptions::FileNotFound
80 administrators.push(name.to_s) if details[:status] == "administrator"
92 node[:accounts][:groups].each do |name, details|
95 members details[:members]
102 members administrators.sort
107 members administrators.sort
112 members administrators.sort