[libcxx-commits] [PATCH] D99242: [libcxx] [test] Quote env variables that are set with a shell "export" in ssh.py

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Mar 24 14:20:41 PDT 2021


mstorsjo updated this revision to Diff 333120.
mstorsjo added a comment.

Updated to prefer shlex.quote if available.

Amended the commit message to include this:

> This safeguards against cases if some of the env vars contain chars
> that are problematic for shells. (In cases of cross testing for
> windows, the PATH variable can end up specified with semicolon
> separators - even if specifying a PATH overall doesn't even make sense
> when cross testing, but this makes ssh.py not break on such a variable.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99242/new/

https://reviews.llvm.org/D99242

Files:
  libcxx/utils/ssh.py


Index: libcxx/utils/ssh.py
===================================================================
--- libcxx/utils/ssh.py
+++ libcxx/utils/ssh.py
@@ -23,6 +23,11 @@
 import tarfile
 import tempfile
 
+try:
+   from shlex import quote as cmd_quote
+except ImportError:
+   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 +112,7 @@
         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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99242.333120.patch
Type: text/x-patch
Size: 896 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210324/fc33443f/attachment.bin>


More information about the libcxx-commits mailing list