summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2018-05-17 12:22:29 +0100
committerGitHub <noreply@github.com>2018-05-17 12:22:29 +0100
commitadcae56ec81b5c4f1d80329a59a45c72db701b02 (patch)
treeef155d7913f8d9121a583841b99781dfbc9d569c
parenta074d491722bf665da843e76672ffbadf92e3661 (diff)
parent2c9a6248d51de056719df546272a7b27cb590e95 (diff)
downloadchef-adcae56ec81b5c4f1d80329a59a45c72db701b02.tar.gz
Merge pull request #4903 from nmcspadden/mac_uid
UID now starts at 501, uses createhomedir instead
-rw-r--r--lib/chef/provider/user/dscl.rb11
-rw-r--r--spec/unit/provider/user/dscl_spec.rb11
2 files changed, 6 insertions, 16 deletions
diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb
index 50d255db8b..79a2c73339 100644
--- a/lib/chef/provider/user/dscl.rb
+++ b/lib/chef/provider/user/dscl.rb
@@ -214,7 +214,7 @@ user password using shadow hash.")
#
# Sets the user id for the user using dscl.
# If a `uid` is not specified, it finds the next available one starting
- # from 200 if `system` is set, 500 otherwise.
+ # from 200 if `system` is set, 501 otherwise.
#
def dscl_set_uid
# XXX: mutates the new resource
@@ -229,11 +229,11 @@ user password using shadow hash.")
#
# Find the next available uid on the system. starting with 200 if `system` is set,
- # 500 otherwise.
+ # 501 otherwise.
#
def get_free_uid(search_limit = 1000)
uid = nil
- base_uid = new_resource.system ? 200 : 500
+ base_uid = new_resource.system ? 200 : 501
next_uid_guess = base_uid
users_uids = run_dscl("list", "/Users", "uid")
while next_uid_guess < search_limit + base_uid
@@ -326,10 +326,7 @@ user password using shadow hash.")
end
def ditto_home
- skel = "/System/Library/User Template/English.lproj"
- raise(Chef::Exceptions::User, "can't find skel at: #{skel}") unless ::File.exist?(skel)
- shell_out_compact!("ditto", skel, new_resource.home)
- ::FileUtils.chown_R(new_resource.username, new_resource.gid.to_s, new_resource.home)
+ shell_out_compact!("/usr/sbin/createhomedir", "-c", "-u", "#{new_resource.username}")
end
def move_home
diff --git a/spec/unit/provider/user/dscl_spec.rb b/spec/unit/provider/user/dscl_spec.rb
index 956c32664d..1019a9ae0f 100644
--- a/spec/unit/provider/user/dscl_spec.rb
+++ b/spec/unit/provider/user/dscl_spec.rb
@@ -283,15 +283,8 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
provider.dscl_set_home
end
- it "should raise an exception when the systems user template dir (skel) cannot be found" do
- allow(::File).to receive(:exist?).and_return(false, false, false)
- expect { provider.dscl_set_home }.to raise_error(Chef::Exceptions::User)
- end
-
- it "should run ditto to copy any missing files from skel to the new home dir" do
- expect(::File).to receive(:exist?).with("/System/Library/User\ Template/English.lproj").and_return(true)
- expect(FileUtils).to receive(:chown_R).with("toor", "", "/Users/toor")
- expect(provider).to receive(:shell_out!).with("ditto", "/System/Library/User Template/English.lproj", "/Users/toor")
+ it "should run createhomedir to create the user's new home folder" do
+ expect(provider).to receive(:shell_out!).with("/usr/sbin/createhomedir", "-c", "-u", "toor")
provider.ditto_home
end