From 9414d5620598e952ab8591cb065718ec725f0896 Mon Sep 17 00:00:00 2001 From: Rushikesh Jadhav Date: Mon, 16 Jun 2025 19:03:01 +0530 Subject: [PATCH] lib/host: Avoid using identical source and destination paths in execute_script scp Using the same path for both source and destination may cause scp to fail, especially when the source path (e.g. a temp path on macOS) does not exist on the remote system. Thus, resorting to use `/tmp/` and random name from `sctipt.name` on destination. Signed-off-by: Rushikesh Jadhav --- lib/host.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/host.py b/lib/host.py index d7031a9bc..746fce6f9 100644 --- a/lib/host.py +++ b/lib/host.py @@ -201,13 +201,13 @@ def execute_script(self, script_contents, shebang='sh', simple_output=True): script.write('#!/usr/bin/env ' + shebang + '\n') script.write(script_contents) script.flush() - self.scp(script.name, script.name) + self.scp(script.name, "/tmp/" + os.path.basename(script.name)) try: logging.debug(f"[{self}] # Will execute this temporary script:\n{script_contents.strip()}") - return self.ssh([script.name], simple_output=simple_output) + return self.ssh(["/tmp/" + os.path.basename(script.name)], simple_output=simple_output) finally: - self.ssh(['rm', '-f', script.name]) + self.ssh(['rm', '-f', "/tmp/" + os.path.basename(script.name)]) def _get_xensource_inventory(self) -> Dict[str, str]: output = self.ssh(['cat', '/etc/xensource-inventory'])