chef 10.34.2-x86-mingw32 → 10.34.4-x86-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a2617a738e333ca179eb95c47f8ba58e6017b2a
4
- data.tar.gz: 87225009201fdd2af966671c6bf4ee44b943ef97
3
+ metadata.gz: c156bc3164b9ecaf6193e607ca53f1743937681d
4
+ data.tar.gz: 0956a5768a42f7996d8dd95b55fcf5d98562d854
5
5
  SHA512:
6
- metadata.gz: 34b1c8445e1e4ca651891c55e06db595b6efcdb257c1bbac5af0d66adcefc0425c082613eb13af0011f213c0b049d94837b9f21fde368e5aa871c9fc49b73d35
7
- data.tar.gz: d0acbd447af839fe5868e96fdce04c1bb98a54bd794f8a9ee7c9e37eb9ad486b74caf65c2ccd6ed9cceea6fa4ba93fb20cd5d0fdf2c7756135c602c53ebc0c6b
6
+ metadata.gz: 66d1407ba36dc9f147d04cd9dfc34dc3df635b5b476a0b43a1bf3918d3d5e6066866bc674b641720cf6e54a58c37baa9eb87d51cd10ab34f24da2dd57e4208bf
7
+ data.tar.gz: a4a37dc74549254fe89b956fc9050ee424b419ded39df6c6d39d0de861a8034d9b3fc49ab3b398c3447078c971cf21e4c923f6b86865bfce9e105127f889b6e6
@@ -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 = read_user_info
346
- dscl_set(user_info, :shadow_hash, shadow_info_binary)
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}")
@@ -17,7 +17,7 @@
17
17
 
18
18
  class Chef
19
19
  CHEF_ROOT = File.dirname(File.expand_path(File.dirname(__FILE__)))
20
- VERSION = '10.34.2'
20
+ VERSION = '10.34.4'
21
21
  end
22
22
 
23
23
  # NOTE: the Chef::Version class is defined in version_class.rb
@@ -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.2
4
+ version: 10.34.4
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-21 00:00:00.000000000 Z
11
+ date: 2014-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-config