From dde99bef34177ac3f96feb1b0d1e107a2a45618c Mon Sep 17 00:00:00 2001 From: Dean Welch Date: Thu, 29 Feb 2024 17:44:33 +0000 Subject: [PATCH] Use correct permissions for read/write/delete directories --- lib/ruby_smb/smb2/tree.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/ruby_smb/smb2/tree.rb b/lib/ruby_smb/smb2/tree.rb index ee860878c..a6c6e0e61 100644 --- a/lib/ruby_smb/smb2/tree.rb +++ b/lib/ruby_smb/smb2/tree.rb @@ -186,11 +186,22 @@ def open_directory_packet(directory: nil, disposition: RubySMB::Dispositions::FI create_request.create_options.directory_file = 1 create_request.file_attributes.directory = 1 create_request.desired_access.list = 1 - create_request.share_access.read_access = 1 if read - create_request.share_access.write_access = 1 if write - create_request.share_access.delete_access = 1 if delete create_request.create_disposition = disposition + if read + create_request.share_access.read_access = 1 + create_request.desired_access.read_attr = 1 + end + + if write + create_request.share_access.write_access = 1 + end + + if delete + create_request.share_access.delete_access = 1 + create_request.desired_access.delete_access = 1 + end + if directory.nil? || directory.empty? create_request.name = "\x00" create_request.name_length = 0