diff options
author | Stuart Preston <stuart@chef.io> | 2018-11-20 09:23:21 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-20 09:23:21 +0000 |
commit | 7bb983c8358a05361bef4f77832d2f51978dd15a (patch) | |
tree | b870452531819fff443dfd270a6284fc2ac0868f | |
parent | 403bf5a725cac444656606942de95920db7242eb (diff) | |
parent | 49090a10beaccfafe76fa2ddf4a609cecfc3a4bb (diff) | |
download | chef-7bb983c8358a05361bef4f77832d2f51978dd15a.tar.gz |
Merge pull request #7956 from chef/smb_share
windows_share: Fix idempotency by removing the "everyone" access
-rw-r--r-- | lib/chef/resource/windows_share.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/chef/resource/windows_share.rb b/lib/chef/resource/windows_share.rb index e45a3589e6..50fd1c3ca9 100644 --- a/lib/chef/resource/windows_share.rb +++ b/lib/chef/resource/windows_share.rb @@ -241,6 +241,10 @@ class Chef Chef::Log.debug("Running '#{share_cmd}' to create the share") powershell_out!(share_cmd) + + # New-SmbShare adds the "Everyone" user with read access no matter what so we need to remove it + # before we add our permissions + revoke_user_permissions(["Everyone"]) end # determine what users in the current state don't exist in the desired state @@ -296,6 +300,8 @@ class Chef false end + # revoke user permissions from a share + # @param [Array] users def revoke_user_permissions(users) revoke_command = "Revoke-SmbShareAccess -Name '#{new_resource.share_name}' -AccountName \"#{users.join(',')}\" -Force" Chef::Log.debug("Running '#{revoke_command}' to revoke share permissions") |