summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2021-08-17 11:24:28 -0700
committerGitHub <noreply@github.com>2021-08-17 11:24:28 -0700
commit9539167104bc2384616c0c1383fccf0b1d08f570 (patch)
tree3015ccbd625a7c5c6471dbc01f7055e5b25f5ac3
parent55a550eef7388eb9fd95ea40df0f55dd0adf4651 (diff)
parent065103bf6b85f319053d658f498d6056a5f3d40e (diff)
downloadchef-9539167104bc2384616c0c1383fccf0b1d08f570.tar.gz
Merge pull request #11925 from chef/mac_user
Fix failures in mac_user when not all user fields are present
-rw-r--r--lib/chef/provider/user/mac.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/chef/provider/user/mac.rb b/lib/chef/provider/user/mac.rb
index 94b0ce0b21..e0e120aa0b 100644
--- a/lib/chef/provider/user/mac.rb
+++ b/lib/chef/provider/user/mac.rb
@@ -28,7 +28,7 @@ class Chef
class Provider
class User
# A macOS user provider that is compatible with default TCC restrictions
- # in macOS 10.14. See resource/user/mac_user.rb for complete description
+ # in macOS 10.14+. See resource/user/mac_user.rb for complete description
# of the mac_user resource
class MacUser < Chef::Provider::User
include Chef::Mixin::Which
@@ -49,11 +49,11 @@ class Chef
current_resource.uid(user_plist[:uid][0])
current_resource.gid(user_plist[:gid][0])
current_resource.home(user_plist[:home][0])
- current_resource.shell(user_plist[:shell][0])
+ current_resource.shell(user_plist[:shell]&.first) # use &.first since shell can be nil
current_resource.comment(user_plist[:comment][0])
if user_plist[:is_hidden]
- current_resource.hidden(user_plist[:is_hidden][0] == "1" ? true : false)
+ current_resource.hidden(user_plist[:is_hidden]&.first == "1" ? true : false) # when not hidden the value seems to be nil so &.first to handle that
end
shadow_hash = user_plist[:shadow_hash]