From c9d8b4c132667c9eba92ac696047892e6f65e4cf Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Wed, 13 May 2020 17:56:36 +0100 Subject: gerrit: Shell-quote ssh command arguments The Secure Shell protocol does not allow passing an argument vector, only a command line that will be interpreted by a specific program (usually a shell, but in this case Gerrit) on the remote host. OpenSSH's ssh command simply concatenates the remote command arguments with spaces between them, so we need to shell-quote them first. Closes #8. --- lorrycontroller/gerrit.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lorrycontroller') diff --git a/lorrycontroller/gerrit.py b/lorrycontroller/gerrit.py index 6ae24e3..4e77ba7 100644 --- a/lorrycontroller/gerrit.py +++ b/lorrycontroller/gerrit.py @@ -34,7 +34,8 @@ class Gerrit(object): '%s@%s' % (user, host)] def _ssh_command(self, command): - out = cliapp.runcmd(self._ssh_command_args + command) + quoted_args = [cliapp.shell_quote(x) for x in command] + out = cliapp.runcmd(self._ssh_command_args + quoted_args) if isinstance(out, bytes): out = out.decode('utf-8', errors='replace') return out -- cgit v1.2.1