Merge pull request 'Miscellaneous ssh fixes.' (#3487) from misc-fixes into main

Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/3487
This commit is contained in:
Mic92
2025-05-04 08:51:31 +00:00
2 changed files with 18 additions and 14 deletions

View File

@@ -124,6 +124,9 @@ class Host:
if extra_env is None:
extra_env = {}
if opts is None:
opts = RunOpts()
# If we are not root and we need to become root, prepend sudo
sudo = ""
if become_root and self.user != "root":
@@ -134,11 +137,10 @@ class Host:
for k, v in extra_env.items():
env_vars.append(f"{shlex.quote(k)}={shlex.quote(v)}")
if opts is None:
opts = RunOpts()
else:
opts.needs_user_terminal = True
if opts.prefix is None:
opts.prefix = self.command_prefix
# always set needs_user_terminal to True because ssh asks for passwords
opts.needs_user_terminal = True
if opts.cwd is not None:
msg = "cwd is not supported for remote commands"