Skip to content

Commit

Permalink
add kwarg for desired delete access to a directory
Browse files Browse the repository at this point in the history
  • Loading branch information
dwelch-r7 committed Mar 7, 2024
1 parent 131a7ac commit c934283
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions lib/ruby_smb/smb2/tree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,30 +178,20 @@ def open_directory(directory: nil, disposition: RubySMB::Dispositions::FILE_OPEN
# @return [RubySMB::SMB2::Packet::CreateRequest] the request packet to send to the server
def open_directory_packet(directory: nil, disposition: RubySMB::Dispositions::FILE_OPEN,
impersonation: RubySMB::ImpersonationLevels::SEC_IMPERSONATE,
read: true, write: false, delete: false)
read: true, write: false, delete: false, desired_delete: false)
create_request = RubySMB::SMB2::Packet::CreateRequest.new
create_request = set_header_fields(create_request)

create_request.impersonation_level = impersonation
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.desired_access.delete_access = 1 if desired_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
Expand Down

0 comments on commit c934283

Please sign in to comment.