diff options
author | Pat Cox <pcox@fb.com> | 2015-01-05 15:48:22 -0800 |
---|---|---|
committer | Pat Cox <pcox@fb.com> | 2015-01-12 14:26:57 -0800 |
commit | bcba63cca1ebf057fbd97a04ec4b368ebe9028a6 (patch) | |
tree | 4c95f6c3fa99d58bde528dbcf6d86e4c8f11f84c /lib/chef/provider | |
parent | 4dda161d7afa3887f4910b948f677a074ab58a56 (diff) | |
download | chef-bcba63cca1ebf057fbd97a04ec4b368ebe9028a6.tar.gz |
bugfix dscl provider
We need to compare with the UID, not a GUID. So we need to map the
correct field for comparison.
Also fix a bug in determining used uids.
This fixes this exception when the specified uid is actually in use by the
correct user:
Chef::Exceptions::RequestedUIDUnavailable: uid 48 is already in use
Diffstat (limited to 'lib/chef/provider')
-rw-r--r-- | lib/chef/provider/user/dscl.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb index 39746f0018..f8c0f6cb01 100644 --- a/lib/chef/provider/user/dscl.rb +++ b/lib/chef/provider/user/dscl.rb @@ -239,8 +239,16 @@ user password using shadow hash.") # def uid_used?(uid) return false unless uid - users_uids = run_dscl("list /Users uid") - !! ( users_uids =~ Regexp.new("#{Regexp.escape(uid.to_s)}\n") ) + users_uids = run_dscl("list /Users uid").split("\n") + uid_map = users_uids.inject({}) do |tmap, tuid| + x = tuid.split + tmap[x[1]] = x[0] + tmap + end + if uid_map[uid.to_s] + return true unless uid_map[uid.to_s] == @new_resource.username.to_s + end + return false end # @@ -535,7 +543,7 @@ user password using shadow hash.") # A simple map of Chef's terms to DSCL's terms. DSCL_PROPERTY_MAP = { - :uid => "generateduid", + :uid => "uid", :gid => "gid", :home => "home", :shell => "shell", |