Skip to content

Verify enrollment and management sleep inhibitors through logind - #28

Open
denisvmedia wants to merge 1 commit into
macintog:mainfrom
denisvmedia:ubuntu-sleep-inhibitor
Open

denisvmedia wants to merge 1 commit into
macintog:mainfrom
denisvmedia:ubuntu-sleep-inhibitor

Conversation

@denisvmedia

Copy link
Copy Markdown

On Ubuntu, systemd-inhibit --list --json=short fails because the command does not support that JSON option. Native enrollment stops before capture (the desktop shows only "Enrollment stopped"), and identity-management operations such as rollback fail with "sleep inhibitor could not be established".

This change queries logind's structured ListInhibitors method through busctl --system --json=short instead. The reply must have the a(ssssuu) shape with well-typed rows, and a row must match the same live child PID, the exact operation label, the sleep scope and block mode. The child must still be alive after the query. Inhibitor acquisition, the parent pipe and lifetime handling are unchanged, and a missing or malformed reply still blocks the operation.

Scope: this serves the enrollment and management safety requirement that a biometric mutation only runs under a verified sleep inhibitor. It changes only two installed Python commands and adds tests. It creates no persistent state or machine configuration. Upgrade replaces the two commands; reverting the change restores the previous check and its refusal on affected systems. The query itself performs no biometric mutation.

Hardware risk: low. The change only affects a read-only precondition check.

Tested:

  • T2_TOUCHID_USER=test python -m unittest discover -s tests on Linux (Python 3.14.4), as an unprivileged user: 1682 tests passed, 2 skipped. This includes 16 new tests that cover both callers, mismatched inhibitors, a dead or exiting child process, query failure, and malformed replies.
  • py_compile for src/*.py and tests/*.py, git diff --check, ShellCheck 0.11.0 on the CI file set, tools/privacy-check.sh, and enrollment_research/scripts/check-public-tree.sh.
  • Hardware: MacBookAir9,1, Ubuntu 26.04.1, bridgeOS 24P6005. With this fix installed, a normal first enrollment and a later management rollback both passed the inhibitor gate. Overall bring-up on that machine also needed other local changes that are described in the linked report and are not part of this PR.

Not tested: the Python 3.12 CI job and the userspace C build (no C changes here). This PR does not qualify suspend/resume or graphical unlock.

Kernel selection, GRUB configuration, the account-generation recovery, experimental creation version 3, and the persistence-recovery changes stay out of this PR.

Related to #27 (inhibitor portion only).

On Ubuntu, systemd-inhibit --list rejects --json=short, so the
registration check always failed. Native enrollment stopped before
capture and identity management refused to run.

Ask logind directly with busctl ListInhibitors. Validate the a(ssssuu)
reply and require the same live child PID, the exact operation label,
the sleep scope and block mode. Acquisition and lifetime handling are
unchanged, and an unverified inhibitor still blocks the operation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant