Update nodejs, sudo and users cookbooks

This commit is contained in:
Greg Karékinian
2018-04-17 13:18:09 +02:00
parent ff2f424ddb
commit 157ccdc8b7
37 changed files with 862 additions and 523 deletions

View File

@@ -19,6 +19,41 @@ module Users
fs_type(mount) == 'nfs' ? true : false
end
def keys_from_url(url)
host = url.split('/')[0..2].join('/')
path = url.split('/')[3..-1].join('/')
begin
response = Chef::HTTP.new(host).get(path)
response.split("\n")
rescue Net::HTTPServerException => e
p "request: #{host}#{path}, error: #{e}"
end
end
# Determines if the user's shell is valid on the machine, otherwise
# returns the default of /bin/sh
#
# @return [String]
def shell_is_valid?(shell_path)
return false if shell_path.nil? || !File.exist?(shell_path)
# AIX is the only OS that has the concept of 'approved shells'
return true unless platform_family?('aix')
begin
File.open('/etc/security/login.cfg') do |f|
f.each_line do |l|
l.match(/^\s*shells\s*=\s*(.*)/) do |m|
return true if m[1].split(/\s*,\s*/).any? { |entry| entry.eql? shell_path }
end
end
end
rescue
return false
end
false
end
# Validates passed id.
#
# @return [Numeric, String]
@@ -33,6 +68,8 @@ module Users
def home_basedir
if platform_family?('mac_os_x')
'/Users'
elsif platform_family?('solaris2')
'/export/home'
else
'/home'
end