1
0
mirror of https://github.com/ARM-software/devlib.git synced 2024-10-06 02:40:50 +01:00

host: expect shell syntax inside LocalConnection.execute

When using sudo with LocalConnection, execute the input command via 'sh
-c' to ensure any shell syntax within the command is handled properly.
This commit is contained in:
Sergei Trofimov 2019-03-07 07:53:43 +00:00 committed by Marc Bonnici
parent ebcb1664e7
commit aa50b2d42d

View File

@ -71,7 +71,7 @@ class LocalConnection(object):
if self.unrooted:
raise TargetStableError('unrooted')
password = self._get_password()
command = 'echo {} | sudo -S '.format(quote(password)) + command
command = 'echo {} | sudo -S -- sh -c '.format(quote(password)) + quote(command)
ignore = None if check_exit_code else 'all'
try:
return check_output(command, shell=True, timeout=timeout, ignore=ignore)[0]