diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2019-07-02 15:09:07 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2019-07-02 15:09:07 -0700 |
commit | 7a1a6c8ef26c787e4b6dd1602f3d158b37e81720 (patch) | |
tree | 1e390cd535b38368d091cbb33e5d419408d5ce00 /lib/chef/provider/user | |
parent | 77f8739a4741e2370e40ec39345a92a6ea393a1a (diff) | |
download | chef-7a1a6c8ef26c787e4b6dd1602f3d158b37e81720.tar.gz |
fix Layout/EmptyLineAfterGuardClause
i like this one, gives visual priority to returns or raises that are
buried in the middle of things.
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/provider/user')
-rw-r--r-- | lib/chef/provider/user/aix.rb | 3 | ||||
-rw-r--r-- | lib/chef/provider/user/dscl.rb | 5 | ||||
-rw-r--r-- | lib/chef/provider/user/linux.rb | 1 | ||||
-rw-r--r-- | lib/chef/provider/user/pw.rb | 1 | ||||
-rw-r--r-- | lib/chef/provider/user/solaris.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/user/windows.rb | 1 |
6 files changed, 13 insertions, 0 deletions
diff --git a/lib/chef/provider/user/aix.rb b/lib/chef/provider/user/aix.rb index 230bc6183e..8a170d276a 100644 --- a/lib/chef/provider/user/aix.rb +++ b/lib/chef/provider/user/aix.rb @@ -32,6 +32,7 @@ class Chef add_password manage_home return if universal_options.empty? && usermod_options.empty? + shell_out!("usermod", universal_options, usermod_options, new_resource.username) end @@ -107,6 +108,7 @@ class Chef def add_password return unless current_resource.password != new_resource.password && new_resource.password + logger.trace("#{new_resource.username} setting password to #{new_resource.password}") command = "echo '#{new_resource.username}:#{new_resource.password}' | chpasswd -e" shell_out!(command) @@ -115,6 +117,7 @@ class Chef # Aix specific handling to update users home directory. def manage_home return unless updating_home? && new_resource.manage_home + # -m option does not work on aix, so move dir. if ::File.directory?(current_resource.home) logger.trace("Changing users home directory from #{current_resource.home} to #{new_resource.home}") diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb index 1ec80af039..147de19a65 100644 --- a/lib/chef/provider/user/dscl.rb +++ b/lib/chef/provider/user/dscl.rb @@ -230,6 +230,7 @@ in 'password', with the associated 'salt' and 'iterations'.") # def uid_used?(uid) return false unless uid + users_uids = run_dscl("list", "/Users", "uid").split("\n") uid_map = users_uids.each_with_object({}) do |tuid, tmap| x = tuid.split @@ -562,6 +563,7 @@ in 'password', with the associated 'salt' and 'iterations'.") # def dscl_set(user_hash, key, value) raise "Unknown dscl key #{key}" unless DSCL_PROPERTY_MAP.keys.include?(key) + user_hash[DSCL_PROPERTY_MAP[key]] = [ value ] user_hash end @@ -571,6 +573,7 @@ in 'password', with the associated 'salt' and 'iterations'.") # def dscl_get(user_hash, key) raise "Unknown dscl key #{key}" unless DSCL_PROPERTY_MAP.keys.include?(key) + # DSCL values are set as arrays value = user_hash[DSCL_PROPERTY_MAP[key]] value.nil? ? value : value.first @@ -585,12 +588,14 @@ in 'password', with the associated 'salt' and 'iterations'.") return "" if ( args.first =~ /^delete/ ) && ( result.exitstatus != 0 ) raise(Chef::Exceptions::DsclCommandFailed, "dscl error: #{result.inspect}") unless result.exitstatus == 0 raise(Chef::Exceptions::DsclCommandFailed, "dscl error: #{result.inspect}") if result.stdout =~ /No such key: / + result.stdout end def run_plutil(*args) result = shell_out("plutil", "-#{args[0]}", args[1..-1]) raise(Chef::Exceptions::PlistUtilCommandFailed, "plutil error: #{result.inspect}") unless result.exitstatus == 0 + if result.stdout.encoding == Encoding::ASCII_8BIT result.stdout.encode("utf-8", "binary", undef: :replace, invalid: :replace, replace: "?") else diff --git a/lib/chef/provider/user/linux.rb b/lib/chef/provider/user/linux.rb index a9a3e23cd9..d27dbcabd4 100644 --- a/lib/chef/provider/user/linux.rb +++ b/lib/chef/provider/user/linux.rb @@ -93,6 +93,7 @@ class Chef # checking "does not exist" has to come before exit code handling since centos and ubuntu differ in exit codes if passwd_s.stderr =~ /does not exist/ return false if whyrun_mode? + raise Chef::Exceptions::User, "User #{new_resource.username} does not exist when checking lock status for #{new_resource}" end diff --git a/lib/chef/provider/user/pw.rb b/lib/chef/provider/user/pw.rb index d03b7647ec..bc2991249b 100644 --- a/lib/chef/provider/user/pw.rb +++ b/lib/chef/provider/user/pw.rb @@ -77,6 +77,7 @@ class Chef field_list.sort_by { |a| a[0] }.each do |field, option| field_symbol = field.to_sym next unless current_resource.send(field_symbol) != new_resource.send(field_symbol) + if new_resource.send(field_symbol) logger.trace("#{new_resource} setting #{field} to #{new_resource.send(field_symbol)}") opts << option diff --git a/lib/chef/provider/user/solaris.rb b/lib/chef/provider/user/solaris.rb index 796d3b87cc..57893d23d5 100644 --- a/lib/chef/provider/user/solaris.rb +++ b/lib/chef/provider/user/solaris.rb @@ -37,6 +37,7 @@ class Chef def manage_user manage_password return if universal_options.empty? && usermod_options.empty? + shell_out!("usermod", universal_options, usermod_options, new_resource.username) end @@ -112,6 +113,7 @@ class Chef def manage_password return unless current_resource.password != new_resource.password && new_resource.password + logger.trace("#{new_resource} setting password to #{new_resource.password}") write_shadow_file end diff --git a/lib/chef/provider/user/windows.rb b/lib/chef/provider/user/windows.rb index 8a070f0d47..892759e93f 100644 --- a/lib/chef/provider/user/windows.rb +++ b/lib/chef/provider/user/windows.rb @@ -110,6 +110,7 @@ class Chef field_symbol = field.to_sym next unless current_resource.send(field_symbol) != new_resource.send(field_symbol) next unless new_resource.send(field_symbol) + unless field_symbol == :password logger.trace("#{new_resource} setting #{field} to #{new_resource.send(field_symbol)}") end |