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: