From 5d425c807db1a2417d6deecacf083b00d4f607d3 Mon Sep 17 00:00:00 2001 From: jordan Date: Tue, 19 Nov 2024 22:39:43 +0100 Subject: [PATCH] Fix file deletion --- smbclientng/core/InteractiveShell.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/smbclientng/core/InteractiveShell.py b/smbclientng/core/InteractiveShell.py index 187593d..3958601 100644 --- a/smbclientng/core/InteractiveShell.py +++ b/smbclientng/core/InteractiveShell.py @@ -862,12 +862,19 @@ def command_rm(self, arguments, command): # SMB share needed : Yes for path_to_file in arguments: - # Wildcard + # Check if the path is absolute + # Fullpath is required to check if path is a file + if ntpath.isabs(path_to_file): + full_path = ntpath.normpath(path_to_file) + else: + # Relative path, construct full path + full_path = ntpath.normpath(ntpath.join(self.sessionsManager.current_session.smb_cwd, path_to_file)) + # Wildcard handling if '*' in path_to_file: self.sessionsManager.current_session.rm(path=path_to_file) # File elif self.sessionsManager.current_session.path_exists(path_to_file): - if self.sessionsManager.current_session.path_isfile(path_to_file): + if self.sessionsManager.current_session.path_isfile(full_path): try: self.sessionsManager.current_session.rm(path=path_to_file) except Exception as e: