Skip to content

Point native account-drift recovery at t2-native-authority-rebind - #15

Closed
watli01 wants to merge 2 commits into
macintog:mainfrom
watli01:fix/native-drift-pending-adaptive
Closed

watli01 wants to merge 2 commits into
macintog:mainfrom
watli01:fix/native-drift-pending-adaptive

Conversation

@watli01

@watli01 watli01 commented Oct 27, 2026 •

Copy link
Copy Markdown

What changed

On a Linux-native installation, an account-generation change led users into a path that permanently broke the native authority. This PR points them at the right command instead.

The account generation includes the passwd database epoch. Any rewrite of /etc/passwd or /etc/shadow changes it, and a package installation whose systemd-sysusers hook adds system users is enough. Native first run then stopped with "selected Linux account generation changed; explicit disabled rebinding and live reconciliation are required". That message, and the README, name the user-map path: t2-touchid-user-map rebind-disabled followed by enable-reconciled.

That path cannot work for a Linux-native authority:

  • Each user-map publish writes a new users.json generation.
  • The native provisioning and activation journals pin the mapping generation. _load_provisioned_authority requires activation.enabled_mapping_generation == mapping_set.generation.
  • After the rebind and enable, first run stops with "protected Linux-native replacement authority does not reconcile", even though the mapping is enabled.
  • t2-native-authority-rebind then refuses too, because the mapping already carries the current generation.

The intended native tool is t2-native-authority-rebind (t2_native_account_rebind). It leaves users.json and its history byte-for-byte intact, and records the prior account generation as an alias that t2_linux_account.collect accepts.

Changes:

  • src/t2-native-enroll.py: the first-run account-generation error now says "confirm the account, then run t2-native-authority-rebind". A comment explains why the user-map rebind cannot apply.
  • src/t2_native_account_rebind.py: a stale rebind record no longer blocks recovery after a second account change (see "Stale rebind records" below).
  • docs/TROUBLESHOOTING.md: a new section with the native procedure. It also explains why the acknowledgement holds on the same installation, warns against the user-map path for native authorities, and explains how a later account change is handled.
  • README.md: the upgrade note sends native authorities to t2-native-authority-rebind. It keeps the existing disabled-rebind wording for other mappings, which this PR does not evaluate.
  • src/README.md and CHANGELOG.md: matching notes.

Behavior changes: the first-run error text, and the stale-record handling in t2_native_account_rebind.

An earlier revision of this PR changed enable-reconciled to accept a pending adaptive user Catacomb (state 7). That change is withdrawn. It only addressed a symptom of following the user-map path, which cannot restore a native authority anyway.

Hardware evidence

MacBookPro16,1, linux-native authority. A desktop package installation rewrote the passwd database, and first run failed with the old message. Following it (rebind-disabled, then enable-reconciled) produced exactly the failure above.

Recovery on that machine:

  1. Restored the original users.json from a filesystem snapshot taken before the package installation, keeping the rewritten file as a backup.
  2. t2-native-authority-rebind --linux-uid 1000 --acknowledge-complete-native-authority-migration reported complete_authority_validated: true.
  3. t2-native-first-run, t2-biometric-ready, t2-touchid-post-reboot and fprintd all started.
  4. t2-touchid-doctor passed every check except the existing suspend-mode warning.

A second package installation later added another system user on the same machine. With main's module, first run failed with "native account migration binding is invalid", t2-touchid-user-map status failed with "live Linux account assertion failed", and the rebind refused because a record existed. With this branch's two files installed:

  1. status reported account-generation-changed again.
  2. t2-native-authority-rebind validated the complete authority and replaced its own stale record. users.json was byte-identical before and after.
  3. The four services started, and the doctor passed every check except the suspend-mode warning.

Stale rebind records

A rebind record covers one account change. On main, a later passwd rewrite made the record a dead end:

  • resolve() raised because the recorded current generation no longer matched.
  • t2_linux_account.collect then failed with "native account migration binding is invalid", so even the account assertion that publish() needs could not run.
  • publish() refused because a record already existed.

Every later package installation that adds a system user hit this. The fix:

  • Record validation moves into one helper, _manifest(). Malformed, foreign or wrong-UID records still fail closed.
  • resolve() returns None for a well-formed record whose current generation no longer matches. A stale record grants no alias, so the account reads as changed and first run names the rebind again.
  • publish() replaces a stale record, but only when its prior generation and mapping generation still match the validated authority.
    • It writes the new record under a unique temporary name, rechecks that the existing record is unchanged, then renames atomically.
    • The existing protected read-back still runs.
    • A record that is still current is refused with "already exists"; one that no longer matches the authority is refused and left untouched.
  • Replacement reuses the existing --acknowledge-complete-native-authority-migration flag. It states the same complete-authority condition as the first rebind.

Review notes

  • Requirement served: recovery guidance for T2Touch's own Linux-native account binding after account-generation drift.
  • Owned files/settings: none added. Upgrade, failure and removal behave as before.
  • Hardware risk level: low. The code touches only account-alias resolution and the rebind record write, and does nothing to the T2. A stale record now grants nothing instead of raising, which is still fail-closed: it never aliases an account it was not made for.
  • External problems: the package installation that rewrote passwd, and other local platform repairs on the reference machine, are not part of T2Touch and are not imported.
  • Open questions:
    • Should t2-touchid-user-map refuse rebind-disabled and enable-reconciled for a Linux-native authority, instead of only documenting the hazard?
    • Should replacing a stale record require its own acknowledgement flag instead of reusing the migration one?
  • Not claimed: the compatibility-mode drift procedure.

Tests

  • New test_account_generation_change_names_the_native_rebind in tests/test_native_enrollment_authority.py. It fails against main and passes here.
  • tests/test_native_account_rebind.py:
    • five new tests: a later account change replaces the stale record; a still-current record is not replaced; a stale record for a different authority is refused and untouched; a malformed existing record blocks publish; the replacement aborts, leaving no temporary file, if the record changes underneath;
    • the old wrong-current-generation test now asserts that a stale record grants no alias (None), and still raises for a changed authority.
  • Four of these fail against main (replace, abort, stale-no-alias, other authority); the still-current and malformed guards pass on both.
  • Full suite: python -m unittest discover -s tests, 1656 tests OK (1 skipped).
  • py_compile, tools/privacy-check.sh and enrollment_research/scripts/check-public-tree.sh pass.
  • Hardware: both recoveries above on one machine, including the second account change. Not exercised: a fingerprint match after the second recovery, compatibility mode, other hardware.

🤖 Generated with Claude Code

@watli01
watli01 marked this pull request as draft October 27, 2026 14:06
@watli01

watli01 commented Oct 27, 2026

Copy link
Copy Markdown
Author

Converting to draft: the native-mode procedure in this PR is wrong and is being rewritten around t2-native-authority-rebind.

On a Linux-native machine, the troubleshooting steps added here (t2-touchid-user-map rebind-disabled, then enable-reconciled) rewrite users.json. Native first-run requires the activation journal's enabled_mapping_generation to equal the mapping-set generation. So after those publishes it fails with "protected Linux-native replacement authority does not reconcile", even though the mapping is enabled.

The native path for account-generation drift is t2-native-authority-rebind. It leaves the mapping and its history intact and lets the account collector accept the prior generation. On the reference machine, restoring the original mapping and running it validated the complete authority, and first-run, post-reboot and fprintd all came up.

Next: point native first-run's error and the docs at t2-native-authority-rebind, and re-evaluate whether the enable-reconciled change is still needed.

The account generation includes the passwd database epoch, so a package
installation whose sysusers hook adds system users changes it. Linux-native
first run then said "explicit disabled rebinding and live reconciliation are
required", naming the user-map rebind-disabled and enable-reconciled path.
That path republishes users.json, while the native provisioning and
activation journals pin its generation, so following it leaves first run
failing with "protected Linux-native replacement authority does not
reconcile", and t2-native-authority-rebind then refuses because the mapping
already carries the current generation.

Name t2-native-authority-rebind in the first-run error instead. It keeps the
mapping and its history intact and records the prior account generation as
an alias. Document the native procedure, the warning against the user-map
path, and the current limit: one rebind record covers one account change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@watli01
watli01 force-pushed the fix/native-drift-pending-adaptive branch from d70b367 to 86f7962 Compare October 27, 2026 19:32
@watli01 watli01 changed the title Re-enable native mappings with a pending adaptive update Point native account-drift recovery at t2-native-authority-rebind Oct 27, 2026
A native account rebind record covers one account change. After a second
passwd rewrite (for example another package adding a system user) resolve()
raised because the recorded current generation no longer matched, so every
Linux account assertion failed with "native account migration binding is
invalid", and publish() refused because a record already existed. There was
no supported recovery.

Validate the record's structure in one helper. A well-formed record whose
current generation no longer matches now grants no alias, so the account
reads as changed and first run names the rebind again. publish() replaces
such a stale record, but only when its prior and mapping generations still
match the validated authority. It writes under a unique temporary name,
rechecks the record before the atomic rename, and keeps the protected
readback. A record that is still current, malformed, or foreign is refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@macintog

Copy link
Copy Markdown
Owner

Thanks for tracking this down, and for the clear account of why the user-map path can't restore a native authority. We're closing this as superseded, revised version included. T2Touch is moving its Touch ID support into Omarchy itself, and the native first-run, enrollment and user-map tools this PR changes are being replaced there. That's also why we're not taking up your two review questions, on whether t2-touchid-user-map should refuse native authorities and whether replacing a stale record needs its own acknowledgement flag: both concern tools the new design drops.

The new design doesn't use /etc/passwd to identify the account its fingerprints belong to, so this bug shouldn't come up there. We've planned a regression test to keep it that way: installing a package must not break those fingerprints. It credits you.

@macintog macintog closed this Oct 28, 2026
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.

2 participants