Skip to content

Commit a712e64

Browse files
rohiebEmantor
authored andcommitted
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 <rhi@pengutronix.de> [r.czerwinski@pengutronix.de: fix commit message, use better None check] Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
1 parent c4a0867 commit a712e64

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Bug fixes in 23.1
2929
test run.
3030
- ManagedFile NFS detection heuristic now does symlink resolution on the
3131
local host.
32+
- The password for the ShellDriver can now be an empty string.
3233

3334
Breaking changes in 23.1
3435
~~~~~~~~~~~~~~~~~~~~~~~~~

doc/configuration.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,8 @@ Arguments:
15581558
- prompt (regex): shell prompt to match after logging in
15591559
- login_prompt (regex): match for the login prompt
15601560
- username (str): username to use during login
1561-
- password (str): optional, password to use during login
1561+
- password (str): optional, password to use during login.
1562+
Can be an empty string.
15621563
- keyfile (str): optional, keyfile to upload after login, making the
15631564
`SSHDriver`_ usable
15641565
- login_timeout (int, default=60): timeout for login prompt detection in

labgrid/driver/shelldriver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ShellDriver(CommandMixin, Driver, CommandProtocol, FileTransferProtocol):
4848
prompt = attr.ib(validator=attr.validators.instance_of(str))
4949
login_prompt = attr.ib(validator=attr.validators.instance_of(str))
5050
username = attr.ib(validator=attr.validators.instance_of(str))
51-
password = attr.ib(default="", validator=attr.validators.instance_of(str))
51+
password = attr.ib(default=None, validator=attr.validators.optional(attr.validators.instance_of(str)))
5252
keyfile = attr.ib(default="", validator=attr.validators.instance_of(str))
5353
login_timeout = attr.ib(default=60, validator=attr.validators.instance_of(int))
5454
console_ready = attr.ib(default="", validator=attr.validators.instance_of(str))
@@ -152,7 +152,7 @@ def _await_login(self):
152152
did_login = True
153153

154154
elif index == 2:
155-
if self.password:
155+
if self.password is not None:
156156
self.console.sendline(self.password)
157157
else:
158158
raise Exception("Password entry needed but no password set")

0 commit comments

Comments
 (0)