summaryrefslogtreecommitdiff
path: root/lib/chef/provider/user
diff options
context:
space:
mode:
authorMikhail Zholobov <legal90@gmail.com>2015-04-05 19:46:06 +0300
committerLamont Granquist <lamont@scriptkiddie.org>2015-10-23 12:39:00 -0700
commitd246a05fe763e34c0b9fac698d88a45f4daa1a94 (patch)
tree90f34da0388a23e177a7634f5fd5d5e45ecc3d10 /lib/chef/provider/user
parent60ce05c7af318488655344d134e4fb270f61d888 (diff)
downloadchef-d246a05fe763e34c0b9fac698d88a45f4daa1a94.tar.gz
provider/user/dscl: Set default gid to 20
gid should always be defined to create user account properly on OS X. "staff" (gid 20) is a default group for regular user accounts.
Diffstat (limited to 'lib/chef/provider/user')
-rw-r--r--lib/chef/provider/user/dscl.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb
index 0c0c85e18b..d9e235d4b1 100644
--- a/lib/chef/provider/user/dscl.rb
+++ b/lib/chef/provider/user/dscl.rb
@@ -257,10 +257,13 @@ user password using shadow hash.")
#
# Sets the group id for the user using dscl. Fails if a group doesn't
- # exist on the system with given group id.
+ # exist on the system with given group id. If `gid` is not specified, it
+ # sets a default Mac user group "staff", with id 20.
#
def dscl_set_gid
- unless @new_resource.gid && @new_resource.gid.to_s.match(/^\d+$/)
+ if @new_resource.gid.nil?
+ @new_resource.gid(20)
+ elsif !@new_resource.gid.to_s.match(/^\d+$/)
begin
possible_gid = run_dscl("read /Groups/#{@new_resource.gid} PrimaryGroupID").split(" ").last
rescue Chef::Exceptions::DsclCommandFailed => e