mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00:00
devlib: Remove sudo prompt
Since the prompt is added to stdout, remove the one-space-prompt that currently corrupts stdout when a command is ran with sudo. That non-empty prompt was added as Windows Subsystem for Linux version 1 (WSL1) has a broken sudo implementation that chokes on an empty prompt. Considering this is not a platform that is normally suported by devlib, we re-introduce that empty prompt.
This commit is contained in:
parent
6a6d9f30dd
commit
dabee29350
@ -112,6 +112,8 @@ class LocalConnection(ConnectionBase):
|
|||||||
if self.unrooted:
|
if self.unrooted:
|
||||||
raise TargetStableError('unrooted')
|
raise TargetStableError('unrooted')
|
||||||
password = self._get_password()
|
password = self._get_password()
|
||||||
|
# Empty prompt with -p '' to avoid adding a leading space to the
|
||||||
|
# output.
|
||||||
command = "echo {} | sudo -k -p '' -S -- sh -c {}".format(quote(password), quote(command))
|
command = "echo {} | sudo -k -p '' -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:
|
||||||
@ -136,8 +138,8 @@ class LocalConnection(ConnectionBase):
|
|||||||
if self.unrooted:
|
if self.unrooted:
|
||||||
raise TargetStableError('unrooted')
|
raise TargetStableError('unrooted')
|
||||||
password = self._get_password()
|
password = self._get_password()
|
||||||
# The sudo prompt will add a space on stderr, but we cannot filter
|
# Empty prompt with -p '' to avoid adding a leading space to the
|
||||||
# it out here
|
# output.
|
||||||
command = "echo {} | sudo -k -p '' -S -- sh -c {}".format(quote(password), quote(command))
|
command = "echo {} | sudo -k -p '' -S -- sh -c {}".format(quote(password), quote(command))
|
||||||
|
|
||||||
# Make sure to get a new PGID so PopenBackgroundCommand() can kill
|
# Make sure to get a new PGID so PopenBackgroundCommand() can kill
|
||||||
|
@ -61,6 +61,7 @@ from devlib.utils.types import boolean
|
|||||||
from devlib.connection import ConnectionBase, ParamikoBackgroundCommand, SSHTransferHandle
|
from devlib.connection import ConnectionBase, ParamikoBackgroundCommand, SSHTransferHandle
|
||||||
|
|
||||||
|
|
||||||
|
# Empty prompt with -p '' to avoid adding a leading space to the output.
|
||||||
DEFAULT_SSH_SUDO_COMMAND = "sudo -k -p '' -S -- sh -c {}"
|
DEFAULT_SSH_SUDO_COMMAND = "sudo -k -p '' -S -- sh -c {}"
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user