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

SshConnection: do not try to sudo as root

If a command is executed "as_root", SshConnection always prepended
"sudo" invocation to the command, even if the user name is "root". This
causes problems on patforms that do not have "sudo".

This commit changes this behavior so that sudo is never used for root
users.
This commit is contained in:
Sergei Trofimov 2017-04-20 17:00:17 +01:00
parent 1ab8c25ff9
commit bd27de194c

View File

@ -228,6 +228,9 @@ class SshConnection(object):
def _execute_and_wait_for_prompt(self, command, timeout=None, as_root=False, strip_colors=True, log=True):
self.conn.prompt(0.1) # clear an existing prompt if there is one.
if self.username == 'root':
# As we're already root, there is no need to use sudo.
as_root = False
if as_root:
command = "sudo -- sh -c '{}'".format(escape_single_quotes(command))
if log: