mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00: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:
parent
1ab8c25ff9
commit
bd27de194c
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user