chef 10.34.2 → 10.34.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef/provider/user/dscl.rb +32 -28
- data/lib/chef/version.rb +1 -1
- data/spec/unit/provider/user/dscl_spec.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecf41f287945b2eb14c51894701af581df413dca
|
4
|
+
data.tar.gz: 83dab75b812fe788c2f05c59fe63f453ef151aae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7c7e1a075f8a48947294e62427aa07720a39b7ec5dc01c71cb2b93913e4578e1a6a64910c0b78792bc5feeb8d63cb2338870b4230e02727d732dc2906e1b0bc
|
7
|
+
data.tar.gz: c3c731a6a509fca74f69c785b16b6661cf4019d0d26e5da9f64371a16b69d124cdc785f16a81de543a54ad731fd2b46b43fc488e142351436651fce53c1e4ef2
|
@@ -112,18 +112,18 @@ user password using shadow hash.")
|
|
112
112
|
@current_resource = Chef::Resource::User.new(@new_resource.username)
|
113
113
|
@current_resource.username(@new_resource.username)
|
114
114
|
|
115
|
-
user_info = read_user_info
|
116
|
-
if user_info
|
117
|
-
@current_resource.uid(dscl_get(user_info, :uid))
|
118
|
-
@current_resource.gid(dscl_get(user_info, :gid))
|
119
|
-
@current_resource.home(dscl_get(user_info, :home))
|
120
|
-
@current_resource.shell(dscl_get(user_info, :shell))
|
121
|
-
@current_resource.comment(dscl_get(user_info, :comment))
|
122
|
-
@authentication_authority = dscl_get(user_info, :auth_authority)
|
123
|
-
|
124
|
-
if @new_resource.password && dscl_get(user_info, :password) == "********"
|
115
|
+
@user_info = read_user_info
|
116
|
+
if @user_info
|
117
|
+
@current_resource.uid(dscl_get(@user_info, :uid))
|
118
|
+
@current_resource.gid(dscl_get(@user_info, :gid))
|
119
|
+
@current_resource.home(dscl_get(@user_info, :home))
|
120
|
+
@current_resource.shell(dscl_get(@user_info, :shell))
|
121
|
+
@current_resource.comment(dscl_get(@user_info, :comment))
|
122
|
+
@authentication_authority = dscl_get(@user_info, :auth_authority)
|
123
|
+
|
124
|
+
if @new_resource.password && dscl_get(@user_info, :password) == "********"
|
125
125
|
# A password is set. Let's get the password information from shadow file
|
126
|
-
shadow_hash_binary = dscl_get(user_info, :shadow_hash)
|
126
|
+
shadow_hash_binary = dscl_get(@user_info, :shadow_hash)
|
127
127
|
|
128
128
|
# Calling shell_out directly since we want to give an input stream
|
129
129
|
shadow_hash_xml = convert_binary_plist_to_xml(shadow_hash_binary.string)
|
@@ -160,22 +160,26 @@ user password using shadow hash.")
|
|
160
160
|
|
161
161
|
def create_user
|
162
162
|
dscl_create_user
|
163
|
+
# set_password modifies the plist file of the user directly. So update
|
164
|
+
# the password first before making any modifications to the user.
|
165
|
+
set_password
|
163
166
|
dscl_create_comment
|
164
167
|
dscl_set_uid
|
165
168
|
dscl_set_gid
|
166
169
|
dscl_set_home
|
167
170
|
dscl_set_shell
|
168
|
-
set_password
|
169
171
|
end
|
170
172
|
|
171
173
|
def manage_user
|
174
|
+
# set_password modifies the plist file of the user directly. So update
|
175
|
+
# the password first before making any modifications to the user.
|
176
|
+
set_password if diverged_password?
|
172
177
|
dscl_create_user if diverged?(:username)
|
173
178
|
dscl_create_comment if diverged?(:comment)
|
174
179
|
dscl_set_uid if diverged?(:uid)
|
175
180
|
dscl_set_gid if diverged?(:gid)
|
176
181
|
dscl_set_home if diverged?(:home)
|
177
182
|
dscl_set_shell if diverged?(:shell)
|
178
|
-
set_password if diverged_password?
|
179
183
|
end
|
180
184
|
|
181
185
|
#
|
@@ -341,22 +345,18 @@ user password using shadow hash.")
|
|
341
345
|
:input => shadow_info.to_plist, :live_stream => shadow_info_binary)
|
342
346
|
command.run_command
|
343
347
|
|
348
|
+
if @user_info.nil?
|
349
|
+
# User is just created. read_user_info() will read the fresh information
|
350
|
+
# for the user with a cache flush. However with experimentation we've seen
|
351
|
+
# that dscl cache is not immediately updated after the creation of the user
|
352
|
+
# This is odd and needs to be investigated further.
|
353
|
+
sleep 3
|
354
|
+
@user_info = read_user_info
|
355
|
+
end
|
356
|
+
|
344
357
|
# Replace the shadow info in user's plist
|
345
|
-
user_info
|
346
|
-
|
347
|
-
|
348
|
-
#
|
349
|
-
# Before saving the user's plist file we need to wait for dscl to
|
350
|
-
# update its caches and flush them to disk. In order to achieve this
|
351
|
-
# we need to wait first for our changes to get into the dscl cache
|
352
|
-
# and then flush the cache to disk before saving password into the
|
353
|
-
# plist file. 3 seconds is the minimum experimental value for dscl
|
354
|
-
# cache to be updated. We can get rid of this sleep when we find a
|
355
|
-
# trigger to update dscl cache.
|
356
|
-
#
|
357
|
-
sleep 3
|
358
|
-
shell_out("dscacheutil '-flushcache'")
|
359
|
-
save_user_info(user_info)
|
358
|
+
dscl_set(@user_info, :shadow_hash, shadow_info_binary)
|
359
|
+
save_user_info(@user_info)
|
360
360
|
end
|
361
361
|
|
362
362
|
#
|
@@ -557,6 +557,10 @@ user password using shadow hash.")
|
|
557
557
|
def read_user_info
|
558
558
|
user_info = nil
|
559
559
|
|
560
|
+
# We flush the cache here in order to make sure that we read fresh information
|
561
|
+
# for the user.
|
562
|
+
shell_out("dscacheutil '-flushcache'")
|
563
|
+
|
560
564
|
begin
|
561
565
|
user_plist_file = "#{USER_PLIST_DIRECTORY}/#{@new_resource.username}.plist"
|
562
566
|
user_plist_info = run_plutil("convert xml1 -o - #{user_plist_file}")
|
data/lib/chef/version.rb
CHANGED
@@ -376,6 +376,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
|
|
376
376
|
let(:user_plist_file) { nil }
|
377
377
|
|
378
378
|
before do
|
379
|
+
provider.should_receive(:shell_out).with("dscacheutil '-flushcache'")
|
379
380
|
provider.should_receive(:shell_out).with("plutil -convert xml1 -o - /var/db/dslocal/nodes/Default/users/toor.plist") do
|
380
381
|
if user_plist_file.nil?
|
381
382
|
ShellCmdResult.new('Can not find the file', 'Sorry!!', 1)
|
@@ -715,7 +716,6 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
|
|
715
716
|
provider.should_receive(:read_user_info)
|
716
717
|
provider.should_receive(:dscl_set)
|
717
718
|
provider.should_receive(:sleep).with(3)
|
718
|
-
provider.should_receive(:shell_out).with("dscacheutil '-flushcache'")
|
719
719
|
provider.should_receive(:save_user_info)
|
720
720
|
provider.set_password
|
721
721
|
end
|
@@ -822,6 +822,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
|
|
822
822
|
|
823
823
|
describe "when the user exists" do
|
824
824
|
before do
|
825
|
+
provider.should_receive(:shell_out).with("dscacheutil '-flushcache'")
|
825
826
|
provider.should_receive(:shell_out).with("plutil -convert xml1 -o - /var/db/dslocal/nodes/Default/users/toor.plist") do
|
826
827
|
ShellCmdResult.new(File.read(File.join(CHEF_SPEC_DATA, "mac_users/10.9.plist.xml")), "", 0)
|
827
828
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 10.34.
|
4
|
+
version: 10.34.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Jacob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-config
|