From a712e64f1aef9f2053907bc77985aa65aafcf6d8 Mon Sep 17 00:00:00 2001 From: Roland Hieber Date: Thu, 14 Dec 2023 14:38:36 +0100 Subject: [PATCH] shelldriver: allow login with empty password Make 'password' default to None, so when is not set, no password is entered, but the user can set "" (empty string) to support boards which prompt for a password, but accept an enter. Fixes #441 Signed-off-by: Roland Hieber [r.czerwinski@pengutronix.de: fix commit message, use better None check] Signed-off-by: Rouven Czerwinski --- CHANGES.rst | 1 + doc/configuration.rst | 3 ++- labgrid/driver/shelldriver.py | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 45ee0dea2..159cfaa0d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -29,6 +29,7 @@ Bug fixes in 23.1 test run. - ManagedFile NFS detection heuristic now does symlink resolution on the local host. +- The password for the ShellDriver can now be an empty string. Breaking changes in 23.1 ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/configuration.rst b/doc/configuration.rst index 577b78810..79f51d8a2 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -1558,7 +1558,8 @@ Arguments: - prompt (regex): shell prompt to match after logging in - login_prompt (regex): match for the login prompt - username (str): username to use during login - - password (str): optional, password to use during login + - password (str): optional, password to use during login. + Can be an empty string. - keyfile (str): optional, keyfile to upload after login, making the `SSHDriver`_ usable - login_timeout (int, default=60): timeout for login prompt detection in diff --git a/labgrid/driver/shelldriver.py b/labgrid/driver/shelldriver.py index 6689e2568..490a353b7 100644 --- a/labgrid/driver/shelldriver.py +++ b/labgrid/driver/shelldriver.py @@ -48,7 +48,7 @@ class ShellDriver(CommandMixin, Driver, CommandProtocol, FileTransferProtocol): prompt = attr.ib(validator=attr.validators.instance_of(str)) login_prompt = attr.ib(validator=attr.validators.instance_of(str)) username = attr.ib(validator=attr.validators.instance_of(str)) - password = attr.ib(default="", validator=attr.validators.instance_of(str)) + password = attr.ib(default=None, validator=attr.validators.optional(attr.validators.instance_of(str))) keyfile = attr.ib(default="", validator=attr.validators.instance_of(str)) login_timeout = attr.ib(default=60, validator=attr.validators.instance_of(int)) console_ready = attr.ib(default="", validator=attr.validators.instance_of(str)) @@ -152,7 +152,7 @@ def _await_login(self): did_login = True elif index == 2: - if self.password: + if self.password is not None: self.console.sendline(self.password) else: raise Exception("Password entry needed but no password set")