Skip to content

Change the root LUKS key before syncing login and root passwords - #532

Merged
maralcbr merged 5 commits into
quattro-upstreamfrom
mac/19-password-sync
Sep 25, 2026
Merged

maralcbr merged 5 commits into
quattro-upstreamfrom
mac/19-password-sync

Conversation

@maralcbr

@maralcbr maralcbr commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Ticket 19. Stacked on #517 (mac/18-generic-luks), whose journal helpers it reuses. The same fix for the frozen fork is maralcbr#272.

What changed

omarchy-drive-password now keeps the drive holding /, the login user and root on one password, as installation sets them. For that drive it asks for the current password and checks it opens the disk, changes the LUKS key, confirms the new key opens the disk and the old one no longer does, and only then runs chpasswd for the login user and root. Any other encrypted drive changes its LUKS key alone and leaves the accounts untouched.

A journal in ~/.local/state/omarchy/drive-password.state (LUKS UUID, key slots, phase; never a password, written with rekey_state_put) lets the next run finish an interrupted change. The rerun asks for the password the disk opens with now and accepts only the old key (removing the slot the interrupted change added) or the new one (retiring the old slot). Once the new key is confirmed only its slot is accepted, so another key such as a recovery passphrase never becomes the login password. The outcome of luksChangeKey is judged by whether the new key opens the disk, not by its exit status.

Runs are serialised, and every cryptsetup step holds a disk lock so one left running by a killed run finishes before the next run reads the drive. A / whose LUKS partition cannot be resolved fails closed. The script never traces passwords.

Behaviour changes, all platforms (x86 included; quattro-upstream and upstream Quattro changed only the LUKS key):

  • the system disk now also moves the login and root passwords; the manual's password section says so
  • the current password is asked with gum instead of cryptsetup's prompt, and a new password equal to it is refused
  • --pbkdf argon2id is passed only to LUKS2, since LUKS1 rejects it, so LUKS1 drives can change their password again

Not covered: typing a recovery passphrase as the current password still rotates that slot rather than the daily key, as before. That belongs with ticket 33.

Testing

  • test/shell.d/drive-password-test.sh (rewritten): fake slot-table drives plus the real cryptsetup on file-backed LUKS2 and LUKS1 volumes with the command's own KDF. Every cryptsetup and chpasswd call is a crash point; the run is killed after each step, rerun with the old or the new password, and each rerun is killed after each of its own steps.
  • Also covered: failed luksChangeKey, luksChangeKey dying between keys, an orphaned luksChangeKey, recovery key refused before and after confirmation, renumbered disk found by UUID, failed or unnamed root lookup, unreadable journal, slots enrolled after the crash, failed chpasswd root, concurrent runs, bash -x, one-slot disk, LVM on LUKS, unencrypted root, data drive leaves the login unchanged.
  • 14 mutations fail the test, including the old ordering, sync on any drive, no rollback or retirement, any-slot resume, no locks, fail-open lookup and tracing.
  • test/all in an Arch aarch64 container: same failures as the base branch (environment-only files). test/cli passes.
  • Not run: the x86 encrypted-install VM (x86 worker not reachable) and hardware.

Second review, two rounds, all findings fixed and covered above:

  • Round 1: a non-zero luksChangeKey dropped the journal; a recovery passphrase was accepted before confirmation; an interrupted LUKS1 rotation left the old key valid; root lookup failed open; runs could interleave; tracing leaked passwords.
  • Round 2: LUKS1 could not change at all (argon2id); a new password equal to the current one could hit the only slot; the old key was not rechecked on LUKS2; an orphaned cryptsetup escaped the lock; empty slot lists and extra slots were trusted.

A confirming pass on the final diff is pending.

omarchy-drive-password now keeps the login and root passwords on the system disk's passphrase, as installation sets them, but only after the new LUKS key is confirmed to open the disk. A secret-free journal lets the next run finish an interrupted change, and other encrypted drives change alone.
Ask for the current password up front and journal its slot, the pre-change slots and the disk UUID, so a rerun accepts only the old or new key (never another key such as a recovery passphrase), retires whichever the interrupted change left behind, and finds the disk after renumbering. Judge luksChangeKey by whether the new key opens the disk rather than by its exit status, fail closed when / cannot be resolved, serialise runs with a lock and never trace passwords.
On LUKS1 the old-key retirement would otherwise find the new key in the slot it had just been written to and kill it. Retire only a slot the old key still opens in its original place.
Pass argon2id only to LUKS2, so LUKS1 drives can change at all, and keep retiring slots until the old key opens nothing. Hold a disk lock around every cryptsetup step so one left running by a killed run finishes before the next run reads the drive. Fail closed on a crypt layer lsblk cannot name, refuse a journal without its slot list, and never remove more than the one slot an interrupted change added.
@maralcbr
maralcbr changed the base branch from mac/18-generic-luks to quattro-upstream September 25, 2026 10:09
@maralcbr
maralcbr merged commit 0e9b240 into quattro-upstream Sep 25, 2026
5 checks passed
maralcbr added a commit that referenced this pull request Sep 25, 2026
Brings in the password sync (#532), audio (#535), display (#533), Wi-Fi
resume (#529) and battery charge limit (#525) work.

omarchy-drive-password takes #532's version. It already carries what #503
added (no tracing, the new password over stdin), and it has no Apple branch.
#503's drive-password-apple-test.sh asserted that the disk password never
changes the login or root password, which ticket 19 replaced with a
journaled LUKS-first sync for the system disk; drive-password-test.sh covers
the shared behaviour, so the Apple copy goes.
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