Face unlock window steps aside while Apply asks for the password
CI / test (push) Canceled after 3m23s

After Apply the window kept the keyboard and the pointer and its dimmed card
covered the screen, so a password dialog that isn't Chandra's own (another
polkit agent's window) couldn't be reached. While Apply waits, the window now
shows only a note at the top and takes no input. A refused or cancelled
password brings it back with the snaps and marks kept (chandra-face camera
restarts the camera instead of exiting) and says so.

Test: snaps, Enter, the password dialog gets typing (Space no longer snaps
underneath) and the Authenticate click, then the root step finishes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hhiJfJNAYqWzQiuKMf
This commit is contained in:
Claude committed 2026-11-26 04:05:11 +00:00
1 parent f2b2618104
commit 2c2ce3f913
8 files changed
+150 -8

No files matched your search

+80
View File
@@ -563,3 +563,83 @@ let real_keymap : String =
#|};
#|
#|};
///| `settle`, composing frames too (the Face unlock window and Settings follow their tool there).
fn fsettle(comp : @host.ChandraCompositor, a : MockAuthority, cond : () -> Bool) -> Bool {
for i = 0; i < 300; i = i + 1 {
a.bus.pump()
comp.step()
ignore(comp.compose_frame())
if cond() {
return true
}
@sys.sleep_ms(10)
}
false
}
///|
test "Face unlock window: snaps, Apply, then the password dialog gets the keyboard and the click" {
let bus = match auth_bus("faceapply") {
Some(b) => b
None => return
}
let a = MockAuthority::new(bus)
let hpath = "/tmp/chandra-auth-helper-faceapply-" + @sys.getpid().to_string()
let listen = @sys.unix_listen(hpath)
let comp = auth_comp("faceapply", bus, hpath)
comp.server.set_keymap(@utf8.encode(real_keymap))
assert_true(fsettle(comp, a, fn() { comp.polkit.map(p => p.registered()).unwrap_or(false) }))
let dir = "/tmp/chandra-face-apply-" + @sys.getpid().to_string()
let tool = fake_face_tool(dir)
ignore(@sys.write_file_bytes(dir + "/wait", b""))
comp.shell.set_face_tool(["/bin/sh", tool])
assert_true(comp.shell.open_settings(Session))
assert_true(fsettle(comp, a, fn() { face_texts(comp).contains("Desk") }))
face_click(comp, "Add or remove faces…", 10U)
assert_true(fsettle(comp, a, fn() { comp.shell.face.window.map(w => w.picture != 0U).unwrap_or(false) }))
let w = comp.shell.face.window.unwrap()
face_key(comp, 57U, 20U)
assert_true(fsettle(comp, a, fn() { w.snaps.length() == 1 }))
face_key(comp, 57U, 30U)
assert_true(fsettle(comp, a, fn() { w.snaps.length() == 2 }))
// Enter: Apply; the root step asks polkit, which asks us. Meanwhile the window steps aside:
// no dimming card, no input of its own (another agent's password window must be reachable).
face_key(comp, 28U, 40U)
assert_true(w.applying)
ignore(comp.compose_frame())
comp.handle_input(@nested.InputEvent::Key(57U, true), 1U)
comp.handle_input(@nested.InputEvent::Key(57U, false), 1U)
assert_eq(w.snaps.length(), 2)
a.begin("f1", run0_details)
assert_true(fsettle(comp, a, fn() { comp.auth_dialog() is Some(_) }))
let d = comp.auth_dialog().unwrap()
let (h, _) = helper_accept(listen, comp, a)
helper_say(h, "PAM_PROMPT_ECHO_OFF Password: ")
assert_true(fsettle(comp, a, fn() { d.phase == Prompt }))
auth_shot(comp, "18-face-apply-password")
// Typing goes to the password dialog, not to the window under it (Space would snap).
auth_type(comp, "Secret9")
comp.handle_input(@nested.InputEvent::Key(57U, true), 1U)
comp.handle_input(@nested.InputEvent::Key(57U, false), 1U)
assert_eq(d.typed(), 8)
assert_eq(w.snaps.length(), 2)
// The Authenticate button takes the click.
ignore(comp.compose_frame())
let allow = comp.auth.unwrap().hits.filter(x => x.1 == Allow)[0].0
comp.handle_input(@nested.InputEvent::PointerMove((allow.x + 4).to_double(), (allow.y + 4).to_double()), 1U)
comp.handle_input(@nested.InputEvent::PointerButton(272U, true), 2U)
comp.handle_input(@nested.InputEvent::PointerButton(272U, false), 3U)
assert_true(fsettle(comp, a, fn() { d.phase == Checking }))
assert_eq(helper_lines(h, 1), "Secret9 ")
helper_say(h, "SUCCESS")
assert_true(fsettle(comp, a, fn() { comp.auth_dialog() is None && a.answers.length() == 1 }))
// The root step goes on; the window closes with what it said.
ignore(@sys.write_file_bytes(dir + "/go", b""))
assert_true(fsettle(comp, a, fn() { comp.shell.face.window is None }))
assert_eq(comp.shell.face.message, "Added Face 2 and removed 1 face")
@sys.close_fd(h)
@sys.close_fd(listen)
@sys.unlink(hpath)
comp.close()
}
+3 -2
View File
@@ -1972,8 +1972,9 @@ pub fn ChandraCompositor::desired_cursor(self : ChandraCompositor) -> UInt {
Some(ui) => return self.auth_cursor(ui)
None => ()
}
if self.shell.face.window is Some(_) {
return if self.face_window_hit() is Some(_) { 4U } else { 1U }
match self.shell.face.window {
Some(w) if !w.applying => return if self.face_window_hit() is Some(_) { 4U } else { 1U }
_ => ()
}
match self.shot {
Some(o) => return self.overlay_cursor(o)
+13
View File
@@ -32,6 +32,12 @@ fn fake_face_tool(dir : String) -> String {
#| drop) kept=$((kept-1)); pic ;;
#| apply)
#| echo "info Waiting for the password…"
#| # With "$S/wait": hold on until the test's password dialog has been answered.
#| if [ -e "$S/wait" ]; then t=0; while [ ! -e "$S/go" ] && [ $t -lt 200 ]; do sleep 0.05; t=$((t+1)); done; fi
#| # With "$S/refuse": the password was not given; the camera goes on.
#| if [ -e "$S/refuse" ]; then
#| echo "error Nothing changed: the administrator password wasn't given"; echo "applied 1"; pic; continue
#| fi
#| for id in $(echo "$arg" | tr ',' ' '); do
#| grep -v "^face $id " "$S/faces" > "$S/faces.new"; mv "$S/faces.new" "$S/faces"
#| done
@@ -146,6 +152,13 @@ test "the Face unlock window: live picture, snaps, a face marked for removal, on
ignore(@sys.write_file_bytes(shots + "/17-face-window.png", @renderer.encode_png_compressed(comp.compose_frame())))
}
assert_eq(comp.shell.face.faces.length(), 1)
// A refused password keeps the window, the snap and the mark, and says why.
ignore(@sys.write_file_bytes(dir + "/refuse", b""))
face_key(comp, 28U, 35U)
assert_true(face_settle(comp, fn() { !w.applying && w.error }))
assert_eq(w.message, "Nothing changed: the administrator password wasn't given")
assert_eq((w.snaps.length(), w.remove), (1, ["1"]))
@sys.unlink(dir + "/refuse")
// Enter applies: one run for the snap and the removal; the window closes, Settings shows it.
face_key(comp, 28U, 40U)
assert_true(face_settle(comp, fn() { comp.shell.face.window is None }))
+18 -2
View File
@@ -58,8 +58,11 @@ fn ChandraCompositor::face_window_activate(self : ChandraCompositor, h : FaceHit
///| Input while the window is up: all of it goes to the window.
fn ChandraCompositor::face_window_input(self : ChandraCompositor, ev : @nested.InputEvent) -> Bool {
if self.shell.face.window is None {
return false
match self.shell.face.window {
// While Apply waits for the password the window steps aside: the password dialog (ours,
// or another agent's window) must get the keyboard and the pointer.
Some(w) if !w.applying => ()
_ => return false
}
match ev {
Key(code, pressed) => {
@@ -113,6 +116,19 @@ fn ChandraCompositor::face_window_ops(self : ChandraCompositor) -> Array[@scene.
}
}
let p = self.theme.palette
if win.applying {
// Out of the way of the password dialog: a note at the top, no dimming, no input.
self.face_hits.clear()
let fs = self.theme.font_size
let text = "Face unlock: " + win.message
let tw = @renderer.text_width(text, fs - 1, false, false) + 32
let r = @scene.Rect::new((self.output_w - tw) / 2, 12, tw, fs + 18)
let opaque = @scene.Rgba::new(p.surface_popup.r.to_int(), p.surface_popup.g.to_int(), p.surface_popup.b.to_int(), 255)
ops.push(@scene.DrawOp::FillRect(r, opaque, r.h / 2))
ops.push(@scene.DrawOp::StrokeRect(r, p.border, 1, r.h / 2))
ops.push(@scene.DrawOp::Text(r.x + tw / 2, r.y + r.h / 2, text, fs - 1, p.foreground, @scene.TextAlign::Center, false))
return ops
}
let (err_c, _) = auth_colors(p)
let fs = self.theme.font_size
let rad = self.theme.radius + 2