summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/resource/windows_share.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/chef/resource/windows_share.rb b/lib/chef/resource/windows_share.rb
index 93ce6148ed..9100041df0 100644
--- a/lib/chef/resource/windows_share.rb
+++ b/lib/chef/resource/windows_share.rb
@@ -242,6 +242,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
@@ -297,6 +301,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")