Wait for shell prompt after 'Last login:' banner on fresh serial login
After sending the password, read_until_quiet returned as soon as the 'Last login:' banner went quiet — before the actual shell prompt arrived. Since 'Last login:' proves the password was accepted, do a second read (up to 10s) specifically to catch the delayed prompt. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -135,6 +135,15 @@ def _login_serial_console(ser: SerialPort) -> tuple:
|
|||||||
ok("Logged in to IOM console.")
|
ok("Logged in to IOM console.")
|
||||||
return True, password
|
return True, password
|
||||||
|
|
||||||
|
# "Last login:" in the response confirms the password was accepted —
|
||||||
|
# the shell prompt just hasn't arrived yet (slow shell init or motd).
|
||||||
|
# Give it up to 10 more seconds to appear.
|
||||||
|
if "last login" in response.lower():
|
||||||
|
response += _ANSI_RE.sub("", ser.read_until_quiet(quiet_period=1.5, timeout=10.0))
|
||||||
|
if _at_shell_prompt(response):
|
||||||
|
ok("Logged in to IOM console.")
|
||||||
|
return True, password
|
||||||
|
|
||||||
error(f"Login failed. Console response: {response.strip()[:120]}")
|
error(f"Login failed. Console response: {response.strip()[:120]}")
|
||||||
return False, ""
|
return False, ""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user