auth dialog: keep typed text when the polkit helper ends before asking
CI / test (push) Successful in 2m1s
CI / test (push) Successful in 2m1s
If polkit-agent-helper-1 exited (or the socket service refused) before sending a PAM prompt, the dialog counted it as a wrong password, wiped the field and restarted the helper immediately, in a tight loop, so typing seemed to do nothing. Now such an early end keeps what was typed, shows why, and retries after 1s/2s/4s (then on Enter). Every helper event and route is logged as "chandra: polkit helper ..." (never the typed text). Adds an end-to-end test that types through handle_input with a real xkbcommon keymap, including Shift, across a helper that dies at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hgkRPrAzXECBUGmNEE
This commit is contained in:
4 files changed
+237
-4
No files matched your search
@@ -91,6 +91,10 @@ pub(all) enum DialogEffect {
|
||||
Answer(FixedArray[Byte])
|
||||
/// Run the helper again (another user picked, or the last attempt failed).
|
||||
Restart
|
||||
/// The helper ended before anything was answered (it couldn't run, PAM refused at once, the
|
||||
/// account is locked): run it again later, not at once, or a helper that fails straight away
|
||||
/// restarts in a loop and wipes the field under the user's fingers.
|
||||
RetryLater
|
||||
/// The user dismissed the dialog.
|
||||
Cancelled
|
||||
/// The helper said SUCCESS.
|
||||
@@ -161,6 +165,8 @@ pub(all) struct AuthDialog {
|
||||
mut focus : Focus
|
||||
/// Enter came before PAM's prompt: answer as soon as it does.
|
||||
mut submit_queued : Bool
|
||||
/// An answer went to the helper in this attempt (a failure then means a wrong answer).
|
||||
mut answered : Bool
|
||||
/// Face unlock in this attempt (NoFace when no face module spoke).
|
||||
mut face : FaceState
|
||||
/// When face unlock started looking (monotonic ms; the scan animation's clock).
|
||||
@@ -186,6 +192,7 @@ pub fn AuthDialog::new(req : AuthRequest, desc : Description) -> AuthDialog {
|
||||
shake_at: 0UL,
|
||||
focus: Field,
|
||||
submit_queued: false,
|
||||
answered: false,
|
||||
face: NoFace,
|
||||
face_at: 0UL,
|
||||
}
|
||||
@@ -261,6 +268,7 @@ fn AuthDialog::submit(self : AuthDialog) -> DialogEffect {
|
||||
} else {
|
||||
self.phase = Checking
|
||||
self.error = ""
|
||||
self.answered = true
|
||||
Answer(self.take_answer())
|
||||
}
|
||||
Starting | Waiting => {
|
||||
@@ -318,7 +326,20 @@ pub fn AuthDialog::helper(self : AuthDialog, ev : HelperEvent, now : UInt64) ->
|
||||
Nothing
|
||||
}
|
||||
Success => Authorized
|
||||
Failure if !self.answered => {
|
||||
// Nothing was asked or answered: not a wrong password. Keep what was typed.
|
||||
if self.error == "" {
|
||||
self.error = "The authentication service stopped before asking for a password."
|
||||
}
|
||||
self.phase = Starting
|
||||
self.info = ""
|
||||
if self.face == Scanning {
|
||||
self.face = NoFace
|
||||
}
|
||||
RetryLater
|
||||
}
|
||||
Failure => {
|
||||
self.answered = false
|
||||
self.failures = self.failures + 1
|
||||
self.shake_at = if now == 0UL { 1UL } else { now }
|
||||
if self.error == "" {
|
||||
@@ -373,6 +394,7 @@ fn AuthDialog::cycle_user(self : AuthDialog, delta : Int) -> DialogEffect {
|
||||
self.face = NoFace
|
||||
self.phase = Starting
|
||||
self.submit_queued = false
|
||||
self.answered = false
|
||||
Restart
|
||||
}
|
||||
|
||||
|
||||
@@ -101,6 +101,14 @@ pub(all) enum HelperRoute {
|
||||
Program(String)
|
||||
} derive(Eq, Debug)
|
||||
|
||||
///| A route, for the log.
|
||||
fn route_text(r : HelperRoute) -> String {
|
||||
match r {
|
||||
Socket(p) => "socket " + p
|
||||
Program(p) => p
|
||||
}
|
||||
}
|
||||
|
||||
///| One run of the helper: the connection and the bytes read but not yet a whole line.
|
||||
pub struct HelperSession {
|
||||
mut fd : Int
|
||||
@@ -114,8 +122,11 @@ pub struct HelperSession {
|
||||
pub fn HelperSession::start_any(routes : Array[HelperRoute], user : String, cookie : String) -> HelperSession? {
|
||||
for r in routes {
|
||||
match HelperSession::start(r, user, cookie) {
|
||||
Some(s) => return Some(s)
|
||||
None => ()
|
||||
Some(s) => {
|
||||
@sys.log("chandra: polkit helper for " + user + " via " + route_text(r))
|
||||
return Some(s)
|
||||
}
|
||||
None => @sys.log("chandra: polkit helper not reachable via " + route_text(r))
|
||||
}
|
||||
}
|
||||
None
|
||||
|
||||
Reference in new issue
Block a user