Skip to content

Commit

Permalink
Merge pull request #1308 from rohieb/shelldriver-empty-password
Browse files Browse the repository at this point in the history
shelldriver: allow login with empty password
  • Loading branch information
Emantor committed Dec 15, 2023
2 parents 49455a9 + a712e64 commit 54f4229
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
3 changes: 2 additions & 1 deletion doc/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions labgrid/driver/shelldriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,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))
Expand Down Expand Up @@ -150,7 +150,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")
Expand Down

0 comments on commit 54f4229

Please sign in to comment.