mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 10:10:46 +00: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:
parent
ebcb1664e7
commit
aa50b2d42d
@ -71,7 +71,7 @@ class LocalConnection(object):
|
|||||||
if self.unrooted:
|
if self.unrooted:
|
||||||
raise TargetStableError('unrooted')
|
raise TargetStableError('unrooted')
|
||||||
password = self._get_password()
|
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'
|
ignore = None if check_exit_code else 'all'
|
||||||
try:
|
try:
|
||||||
return check_output(command, shell=True, timeout=timeout, ignore=ignore)[0]
|
return check_output(command, shell=True, timeout=timeout, ignore=ignore)[0]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user