diff --git a/exec_helpers/_ssh_client_base.py b/exec_helpers/_ssh_client_base.py index 79d092f..e88c9a4 100644 --- a/exec_helpers/_ssh_client_base.py +++ b/exec_helpers/_ssh_client_base.py @@ -409,7 +409,7 @@ def _prepare_command(self, cmd: str, chroot_path: typing.Optional[str] = None) - if not self.sudo_mode: return super()._prepare_command(cmd=cmd, chroot_path=chroot_path) if any((chroot_path, self._chroot_path)): - target_path: str = shlex.quote(chroot_path if chroot_path else self._chroot_path) + target_path: str = shlex.quote(chroot_path if chroot_path else self._chroot_path) # type: ignore return f'chroot {target_path} sudo sh -c "eval {shlex.quote(cmd)}"' return f'sudo -S sh -c "eval {shlex.quote(cmd)}"' diff --git a/exec_helpers/api.py b/exec_helpers/api.py index ca8ff21..677a366 100644 --- a/exec_helpers/api.py +++ b/exec_helpers/api.py @@ -228,7 +228,7 @@ def _prepare_command(self, cmd: str, chroot_path: typing.Optional[str] = None) - :returns: final command, includes chroot, if required """ if any((chroot_path, self._chroot_path)): - target_path: str = shlex.quote(chroot_path if chroot_path else self._chroot_path) + target_path: str = shlex.quote(chroot_path if chroot_path else self._chroot_path) # type: ignore return f'chroot {target_path} sh -c "eval {shlex.quote(cmd)}"' return cmd