Skip to content

Commit

Permalink
Changed Open.open to Open.create to match SMB message names
Browse files Browse the repository at this point in the history
  • Loading branch information
jborean93 committed Feb 26, 2018
1 parent 7cb1aa7 commit 4ab9df0
Show file tree
Hide file tree
Showing 5 changed files with 254 additions and 254 deletions.
20 changes: 10 additions & 10 deletions examples/directory-management.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

# ensure directory is created
dir_open = Open(tree, dir_name)
dir_open.open(
dir_open.create(
ImpersonationLevel.Impersonation,
DirectoryAccessMask.GENERIC_READ | DirectoryAccessMask.GENERIC_WRITE,
FileAttributes.FILE_ATTRIBUTE_DIRECTORY,
Expand All @@ -37,14 +37,14 @@
# create some files in dir and query the contents as part of a compound
# request
directory_file = Open(tree, r"%s\file.txt" % dir_name)
directory_file.open(ImpersonationLevel.Impersonation,
FilePipePrinterAccessMask.GENERIC_WRITE |
FilePipePrinterAccessMask.DELETE,
FileAttributes.FILE_ATTRIBUTE_NORMAL,
ShareAccess.FILE_SHARE_READ,
CreateDisposition.FILE_OVERWRITE_IF,
CreateOptions.FILE_NON_DIRECTORY_FILE |
CreateOptions.FILE_DELETE_ON_CLOSE)
directory_file.create(ImpersonationLevel.Impersonation,
FilePipePrinterAccessMask.GENERIC_WRITE |
FilePipePrinterAccessMask.DELETE,
FileAttributes.FILE_ATTRIBUTE_NORMAL,
ShareAccess.FILE_SHARE_READ,
CreateDisposition.FILE_OVERWRITE_IF,
CreateOptions.FILE_NON_DIRECTORY_FILE |
CreateOptions.FILE_DELETE_ON_CLOSE)

compound_messages = [
directory_file.write("Hello World".encode('utf-8'), 0, send=False),
Expand Down Expand Up @@ -72,7 +72,7 @@
# delete a directory (note the dir needs to be empty to delete on close)
dir_open = Open(tree, dir_name)
delete_msgs = [
dir_open.open(
dir_open.create(
ImpersonationLevel.Impersonation,
DirectoryAccessMask.DELETE,
FileAttributes.FILE_ATTRIBUTE_DIRECTORY,
Expand Down
4 changes: 2 additions & 2 deletions examples/file-management.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
]

file_open = Open(tree, file_name)
open_info = file_open.open(
open_info = file_open.create(
ImpersonationLevel.Impersonation,
FilePipePrinterAccessMask.GENERIC_READ |
FilePipePrinterAccessMask.GENERIC_WRITE,
Expand Down Expand Up @@ -93,7 +93,7 @@
# read and delete a file in a single SMB packet instead of 3
file_open = Open(tree, file_name)
delete_msgs = [
file_open.open(
file_open.create(
ImpersonationLevel.Impersonation,
FilePipePrinterAccessMask.GENERIC_READ |
FilePipePrinterAccessMask.DELETE,
Expand Down
2 changes: 1 addition & 1 deletion smbprotocol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ def emit(self, record):
logger = logging.getLogger(__name__)
logger.addHandler(NullHandler())

__version__ = '0.0.1.dev5'
__version__ = '0.0.1.dev6'
12 changes: 6 additions & 6 deletions smbprotocol/open.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,9 +931,9 @@ def __init__(self, tree, name):
self.file_attributes = None
self.create_disposition = None

def open(self, impersonation_level, desired_access, file_attributes,
share_access, create_disposition, create_options,
create_contexts=None, send=True):
def create(self, impersonation_level, desired_access, file_attributes,
share_access, create_disposition, create_options,
create_contexts=None, send=True):
"""
This will open the file based on the input parameters supplied. Any
file open should also be called with Open.close() when it is finished.
Expand Down Expand Up @@ -998,7 +998,7 @@ def open(self, impersonation_level, desired_access, file_attributes,
self.create_disposition = create_disposition

if not send:
return create, self._open_response
return create, self._create_response

log.info("Session: %s, Tree Connect: %s - sending SMB2 Create Request "
"for file %s" % (self.tree_connect.session.username,
Expand All @@ -1009,9 +1009,9 @@ def open(self, impersonation_level, desired_access, file_attributes,
request = self.connection.send(create,
self.tree_connect.session.session_id,
self.tree_connect.tree_connect_id)
return self._open_response(request)
return self._create_response(request)

def _open_response(self, request):
def _create_response(self, request):
log.info("Session: %s, Tree Connect: %s - receiving SMB2 Create "
"Response" % (self.tree_connect.session.username,
self.tree_connect.share_name))
Expand Down
Loading

0 comments on commit 4ab9df0

Please sign in to comment.