From 60c67290e66371554c275d98dde3f17691156d2e Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 27 Sep 2023 09:04:35 +0200 Subject: [PATCH] pybridge: Improve beiboot error reporting for fatal login failures After all SSH authentication attemps fail, e.g. entering the wrong password three times, ferny aborts with an InteractionError. Translate that to a proper `authentication-failed` protocol error. Merely exiting the problem gets interpreted as "Internal error" which is unfriendly. --- src/cockpit/beiboot.py | 6 ++++-- test/verify/check-static-login | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/cockpit/beiboot.py b/src/cockpit/beiboot.py index 8270397d84a8..2de5d8b21e2d 100644 --- a/src/cockpit/beiboot.py +++ b/src/cockpit/beiboot.py @@ -22,7 +22,6 @@ import logging import os import shlex -import sys from pathlib import Path from typing import Dict, Iterable, Optional, Sequence @@ -312,8 +311,11 @@ async def run(args) -> None: bridge.write_control(**message) bridge.ssh_peer.thaw_endpoint() except ferny.InteractionError as exc: - sys.exit(str(exc)) + logger.debug("ferny.InteractionError: %s", exc) + bridge.write_control(command='init', problem='authentication-failed', message=str(exc)) + return except CockpitProblem as exc: + logger.debug("CockpitProblem: %s", exc) bridge.write_control(command='init', problem=exc.problem, **exc.kwargs) return diff --git a/test/verify/check-static-login b/test/verify/check-static-login index 532fde715304..9f88fca3bcf5 100755 --- a/test/verify/check-static-login +++ b/test/verify/check-static-login @@ -1014,8 +1014,11 @@ Command = {self.libexecdir}/cockpit-beiboot b.wait_text("#conversation-prompt", f"admin@{my_ip}'s password: ") b.set_val("#conversation-input", "wrong") b.click("#login-button") - # FIXME: better error message - b.wait_in_text("#login-fatal-message", "Internal error in login process") + b.wait_in_text("#login-error-message", "Authentication failed") + m.execute(f"! pgrep -af '[s]sh.*{my_ip}' >&2") + m.execute("! pgrep -af '[c]ockpit-beiboot' >&2") + # goes back to normal login form + b.wait_visible('#login-user-input') # colliding usernames; user names in "Connect to:" are *not* supported, # but pin down the behaviour