Commits

Ian Bicking committed 33d9442

Fix quoting with ssh/sudo, and quoting multi-line arguments

  • Participants
  • Parent commits aee722d

Comments (0)

Files changed (1)

silversupport/shell.py

 
     This will use sudo for some users, and ssh in directory in other cases.
     """
-    if isinstance(command, (list, tuple)):
-        command = ' '.join(conditional_shell_escape(i) for i in command)
     if user == 'www-data':
         # This is a bit tricky:
         user = 'www-mgr'
-        command = 'sudo -H -u www-data %s' % shell_escape(command)
+        if isinstance(command, (list, tuple)):
+            command = ' '.join(conditional_shell_escape(i) for i in command)
+        else:
+            command = conditional_shell_escape(command)
+        command = 'sudo -H -u www-data %s' % command
+    elif isinstance(command, (list, tuple)):
+        command = ' '.join(conditional_shell_escape(i) for i in command)
     ssh_args = kw.pop('ssh_args', [])
     return run(['ssh'] + ssh_args + ['-l', user, host, command], **kw)
 
     return run(['apt-get', 'install', '-q=2', '-y', '--force-yes'] + packages, **kw)
 
 
-_end_quote_re = re.compile(r"^('*)(.*?)('*)$")
+_end_quote_re = re.compile(r"^('*)(.*?)('*)$", re.S)
 _quote_re = re.compile("'+")