mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-25 17:45:55 +02:00
lib.ec.ssh: Don't quote shell operators
Naively join()ing a command list to be executed remotely via SSH also quotes shell operators which doesn't work, of course. Work around that. The workaround will not always work but covers lots of cases. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
61c1a628a1
commit
84375cd482
4 changed files with 50 additions and 7 deletions
|
|
@ -3,12 +3,13 @@ from __future__ import annotations
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
import paramiko # type: ignore # error: Library stubs not installed for "paramiko"
|
||||
import shlex
|
||||
|
||||
from ...log import *
|
||||
from ...ExecContext import Result
|
||||
from ..SSHClient import SSHClient as Base
|
||||
|
||||
from .util import join_cmd
|
||||
|
||||
class Paramiko(Base):
|
||||
|
||||
def __init__(self, *args, **kwargs) -> None:
|
||||
|
|
@ -45,9 +46,9 @@ class Paramiko(Base):
|
|||
|
||||
async def _run_ssh(self, cmd: list[str], cmd_input: str|None, *args, **kwargs) -> Result:
|
||||
try:
|
||||
stdin, stdout, stderr = self.__ssh.exec_command(shlex.join(cmd), timeout=self.__timeout)
|
||||
stdin, stdout, stderr = self.__ssh.exec_command(join_cmd(cmd), timeout=self.__timeout)
|
||||
except Exception as e:
|
||||
log(ERR, f'Command failed for {self.uri}: "{shlex.join(cmd)}"')
|
||||
log(ERR, f'Command failed for {self.uri}: "{join_cmd(cmd)}"')
|
||||
raise
|
||||
if cmd_input is not None:
|
||||
stdin.write(cmd_input)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue