diff --git a/smbclient/_os.py b/smbclient/_os.py index 440bd9622a0c59889c73fa678627d5158873f9a5..8f258401830637cb456fe211f8ee378a0fbd47cb 100644 --- a/smbclient/_os.py +++ b/smbclient/_os.py @@ -215,7 +215,7 @@ def link(src, dst, follow_symlinks=True, **kwargs): if src_root.lower() != dst_root.lower(): raise ValueError("Cannot hardlink a file to a different root than the src.") - raw = SMBFileIO(norm_src, mode='r', share_access='rd', + raw = SMBFileIO(norm_src, mode='r', share_access='r', desired_access=FilePipePrinterAccessMask.FILE_WRITE_ATTRIBUTES, create_options=0 if follow_symlinks else CreateOptions.FILE_OPEN_REPARSE_POINT, **kwargs) with SMBFileTransaction(raw) as transaction: @@ -523,7 +523,7 @@ def scandir(path, search_pattern="*", **kwargs): :return: An iterator of DirEntry objects in the directory. """ connection_cache = kwargs.get('connection_cache', None) - with SMBDirectoryIO(path, share_access='rd', **kwargs) as fd: + with SMBDirectoryIO(path, share_access='r', **kwargs) as fd: for dir_info in fd.query_directory(search_pattern, FileInformationClass.FILE_ID_FULL_DIRECTORY_INFORMATION): filename = dir_info['file_name'].get_value().decode('utf-16-le') if filename in [u'.', u'..']: @@ -555,7 +555,7 @@ def stat(path, follow_symlinks=True, **kwargs): st_reparse_tag: An int representing the Windows IO_REPARSE_TAG_* constants. This is set to 0 unless follow_symlinks=False and the path is a reparse point. See smbprotocol.reparse_point.ReparseTags. """ - raw = SMBRawIO(path, mode='r', share_access='rd', desired_access=FilePipePrinterAccessMask.FILE_READ_ATTRIBUTES, + raw = SMBRawIO(path, mode='r', share_access='r', desired_access=FilePipePrinterAccessMask.FILE_READ_ATTRIBUTES, create_options=0 if follow_symlinks else CreateOptions.FILE_OPEN_REPARSE_POINT, **kwargs) with SMBFileTransaction(raw) as transaction: query_info(transaction, FileBasicInformation) @@ -626,7 +626,7 @@ def stat_volume(path, **kwargs): caller_available_size: Available size for the logged user of the file system actual_available_size: Available size of the file system """ - raw = SMBRawIO(path, mode='r', share_access='rd', desired_access=FilePipePrinterAccessMask.FILE_READ_ATTRIBUTES, + raw = SMBRawIO(path, mode='r', share_access='r', desired_access=FilePipePrinterAccessMask.FILE_READ_ATTRIBUTES, **kwargs) with SMBFileTransaction(raw) as transaction: query_info(transaction, FileFsFullSizeInformation) @@ -981,7 +981,7 @@ def _delete(raw_type, path, **kwargs): # Setting a shared_access of rwd means we can still delete a file that has an existing handle open, the file will # be deleted when that handle is closed. This replicates the os.remove() behaviour when running on Windows locally. - raw = raw_type(path, mode='r', share_access='rd', + raw = raw_type(path, mode='r', share_access='r', desired_access=FilePipePrinterAccessMask.DELETE | FilePipePrinterAccessMask.FILE_WRITE_ATTRIBUTES, create_options=co, **kwargs) @@ -1040,7 +1040,7 @@ def _rename_information(src, dst, replace_if_exists=False, **kwargs): raw_args = dict(kwargs) raw_args.update({ 'mode': 'r', - 'share_access': 'rd', + 'share_access': 'r', 'create_options': CreateOptions.FILE_OPEN_REPARSE_POINT, }) @@ -1075,7 +1075,7 @@ def _rename_information(src, dst, replace_if_exists=False, **kwargs): def _set_basic_information(path, creation_time=0, last_access_time=0, last_write_time=0, change_time=0, file_attributes=0, follow_symlinks=True, **kwargs): - raw = SMBRawIO(path, mode='r', share_access='rd', desired_access=FilePipePrinterAccessMask.FILE_WRITE_ATTRIBUTES, + raw = SMBRawIO(path, mode='r', share_access='r', desired_access=FilePipePrinterAccessMask.FILE_WRITE_ATTRIBUTES, create_options=0 if follow_symlinks else CreateOptions.FILE_OPEN_REPARSE_POINT, **kwargs) with SMBFileTransaction(raw) as transaction: