Skip to content

Commit

Permalink
Dev: prun: add more possible libexec PATH for sftp-server
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasyang2022 committed Jul 16, 2024
1 parent 177c285 commit eb1bd17
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions crmsh/prun/prun.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

_DEFAULT_CONCURRENCY = 32

_SUDO_SFTP_SERVER = 'sudo PATH=/usr/lib/ssh:/usr/lib/openssh:/usr/libexec/ssh:/usr/libexec/openssh /bin/sh -c "exec sftp-server"'


class ProcessResult:
def __init__(self, returncode: int, stdout: bytes, stderr: bytes):
Expand Down Expand Up @@ -185,9 +187,10 @@ def pcopy_to_remote(

def _build_copy_task(ssh: str, script: str, host: str):
_, remote_sudoer = UserOfHost.instance().user_pair_for_ssh(host)
cmd = "sftp {} {} -o BatchMode=yes -s 'sudo PATH=/usr/lib/ssh:/usr/libexec/ssh /bin/sh -c \"exec sftp-server\"' -b - {}@{}".format(
cmd = "sftp {} {} -o BatchMode=yes -s '{}' -b - {}@{}".format(
ssh,
crmsh.constants.SSH_OPTION,
_SUDO_SFTP_SERVER,
remote_sudoer, _enclose_inet6_addr(host),
)
return Task(
Expand Down Expand Up @@ -249,9 +252,10 @@ def pfetch_from_remote(

def _build_fetch_task( ssh: str, host: str, src: str, dst: str, flags: str) -> Task:
_, remote_sudoer = UserOfHost.instance().user_pair_for_ssh(host)
cmd = "sftp {} {} -o BatchMode=yes -s 'sudo PATH=/usr/lib/ssh:/usr/libexec/ssh /bin/sh -c \"exec sftp-server\"' -b - {}@{}".format(
cmd = "sftp {} {} -o BatchMode=yes -s '{}' -b - {}@{}".format(
ssh,
crmsh.constants.SSH_OPTION,
_SUDO_SFTP_SERVER,
remote_sudoer, _enclose_inet6_addr(host),
)
os.makedirs(f"{dst}/{host}", exist_ok=True)
Expand Down

0 comments on commit eb1bd17

Please sign in to comment.