forked from OSchip/llvm-project
[libcxx] [test] Quote env variables that are set with a shell "export" in ssh.py
This safeguards against cases if some of the env vars contain chars that are problematic for shells, e.g. if called with --env "X=Y;Z". (In cases of cross testing for windows, the PATH variable can end up specified with semicolon separators - even if specifying a PATH when cross testing in such differing environments might not make sense or do anything - but this makes ssh.py not break on such a variable.) Differential Revision: https://reviews.llvm.org/D99242
This commit is contained in:
parent
a88556733a
commit
b8b23aa80e
|
@ -23,6 +23,12 @@ import sys
|
|||
import tarfile
|
||||
import tempfile
|
||||
|
||||
try:
|
||||
from shlex import quote as cmd_quote
|
||||
except ImportError:
|
||||
# for Python 2 compatibility
|
||||
from pipes import quote as cmd_quote
|
||||
|
||||
def ssh(args, command):
|
||||
cmd = ['ssh', '-oBatchMode=yes']
|
||||
if args.extra_ssh_args is not None:
|
||||
|
@ -107,7 +113,7 @@ def main():
|
|||
commandLine = (pathOnRemote(x) if isTestExe(x) else x for x in commandLine)
|
||||
remoteCommands.append('cd {}'.format(tmp))
|
||||
if args.env:
|
||||
remoteCommands.append('export {}'.format(' '.join(args.env)))
|
||||
remoteCommands.append('export {}'.format(cmd_quote(' '.join(args.env))))
|
||||
remoteCommands.append(subprocess.list2cmdline(commandLine))
|
||||
|
||||
# Finally, SSH to the remote host and execute all the commands.
|
||||
|
|
Loading…
Reference in New Issue