...
This commit is contained in:
parent
0661caf9da
commit
2341a27f63
@ -406,19 +406,19 @@ def get_remote_command(
|
||||
# login shell with -c. If the user has a non POSIX login shell it might
|
||||
# have different escaping semantics and syntax, so the command it should
|
||||
# execute has to be as simple as possible, basically of the form
|
||||
# interpreter -c wrapper_cmd escaped_bootstrap_script
|
||||
# The wrapper_cmd is responsible for unescaping the bootstrap script and
|
||||
# interpreter -c unwrap_script escaped_bootstrap_script
|
||||
# The unwrap_script is responsible for unescaping the bootstrap script and
|
||||
# executing it.
|
||||
if is_python:
|
||||
es = standard_b64encode(sh_script.encode('utf-8')).decode('ascii')
|
||||
wrapper_cmd = '''"import base64, sys; eval(compile(base64.standard_b64decode(sys.argv[-1]), 'bootstrap.py', 'exec'))"'''
|
||||
unwrap_script = '''"import base64, sys; eval(compile(base64.standard_b64decode(sys.argv[-1]), 'bootstrap.py', 'exec'))"'''
|
||||
else:
|
||||
# We cant rely on base64 being available on the remote system, so instead
|
||||
# we quote the bootstrap script by replacing ' and \ with \v and \f and
|
||||
# surrounding with '
|
||||
es = "'" + sh_script.replace("'", '\v').replace('\\', '\f') + "'"
|
||||
wrapper_cmd = r"""'eval "$(echo "$0" | tr \\\v\\\f \\\047\\\134)"' """
|
||||
return [interpreter, '-c', wrapper_cmd, es]
|
||||
unwrap_script = r"""'eval "$(echo "$0" | tr \\\v\\\f \\\047\\\134)"' """
|
||||
return [interpreter, '-c', unwrap_script, es]
|
||||
|
||||
|
||||
def main(args: List[str]) -> NoReturn:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user