mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-30 09:40:46 +00:00
target: Check command output sanity
Check that no element in the chain adds any unwanted content to stdout or stderr when running a command. This is especially important as PAM modules can just write arbitrary messages to stdout when using sudo, such as password expiry notification. There unfortunately seems to be no way of silencing it, but we can at least catch it before it triggers errors down the line.
This commit is contained in:
parent
dabee29350
commit
499ea4753c
@ -535,9 +535,17 @@ class Target(object):
|
||||
"""
|
||||
Check that the connection works without obvious issues.
|
||||
"""
|
||||
out = await self.execute.asyn('true', as_root=False)
|
||||
if out.strip():
|
||||
raise TargetStableError('The shell seems to not be functional and adds content to stderr: {}'.format(out))
|
||||
async def check(**kwargs):
|
||||
out = await self.execute.asyn('true', **kwargs)
|
||||
if out:
|
||||
raise TargetStableError('The shell seems to not be functional and adds content to stderr: {!r}'.format(out))
|
||||
|
||||
await check(as_root=False)
|
||||
# If we are rooted, we usually run with sudo. Unfortunately, PAM
|
||||
# modules can write random text to stdout such as:
|
||||
# Your password will expire in XXX days.
|
||||
if self.is_rooted:
|
||||
await check(as_root=True)
|
||||
|
||||
def disconnect(self):
|
||||
connections = self._conn.get_all_values()
|
||||
|
Loading…
x
Reference in New Issue
Block a user