diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2015-10-23 12:40:59 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-10-23 12:40:59 -0700 |
commit | 8bf1304da739d4be94edb101ad9e46c96b1d4ccd (patch) | |
tree | dd018f50f47fc4f4e56f5d0d10a4e39a97fb17f0 | |
parent | 60ce05c7af318488655344d134e4fb270f61d888 (diff) | |
parent | e6738afc43956937ac4f890f48115f205933d2cd (diff) | |
download | chef-8bf1304da739d4be94edb101ad9e46c96b1d4ccd.tar.gz |
Merge pull request #4097 from chef/lcg/3192
provider/user/dscl: Set default gid to 20
-rw-r--r-- | CHANGELOG.md | 3 | ||||
-rw-r--r-- | lib/chef/provider/user/dscl.rb | 7 | ||||
-rw-r--r-- | spec/unit/provider/user/dscl_spec.rb | 7 |
3 files changed, 14 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 97e976d484..125c9d68c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,8 @@ * [**Dave Eddy**](https://github.com/bahamas10) [pr#3187](https://github.com/chef/chef/pull/3187) overhaul solaris SMF service provider - +* [**Mikhail Zholobov**](https://github.com/legal90) + [pr#3192](https://github.com/chef/chef/pull/3192) provider/user/dscl: Set default gid to 20 * [pr#4034](https://github.com/chef/chef/pull/4034) add optional ruby-profiling with --profile-ruby * [pr#3119](https://github.com/chef/chef/pull/3119) allow removing user, even if their GID isn't resolvable 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 diff --git a/spec/unit/provider/user/dscl_spec.rb b/spec/unit/provider/user/dscl_spec.rb index 32d0812d8c..e8cf6445be 100644 --- a/spec/unit/provider/user/dscl_spec.rb +++ b/spec/unit/provider/user/dscl_spec.rb @@ -789,6 +789,13 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30") expect { provider.dscl_set_gid }.to raise_error(Chef::Exceptions::GroupIDNotFound) end end + + it "should set group ID to 20 if it's not specified" do + new_resource.gid nil + expect(provider).to receive(:run_dscl).with("create /Users/toor PrimaryGroupID '20'").ordered.and_return(true) + provider.dscl_set_gid + expect(new_resource.gid).to eq(20) + end end describe "when the user exists and chef is managing it" do |