Skip to content

Commit

Permalink
pybridge: Improve beiboot error reporting for fatal login failures
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
martinpitt committed Sep 27, 2023
1 parent 98cfc0d commit 60c6729
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/cockpit/beiboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import logging
import os
import shlex
import sys
from pathlib import Path
from typing import Dict, Iterable, Optional, Sequence

Expand Down Expand Up @@ -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

Expand Down
7 changes: 5 additions & 2 deletions test/verify/check-static-login
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 60c6729

Please sign in to comment.