Keep provisioning credentials out of OEM installs and factory snapshots

Review findings from codex and Copilot:

- A rig-supplied credentials file in OEM mode now contributes only its LUKS
  passphrase: preserved users/root_enc_password fields would have created a
  hidden provisioning account despite OEM promising no user until first boot.
- The factory snapshot is taken writable, scrubbed of deployment credentials
  (staged authorized_keys, tailscale auth key and join unit, the dead OEM
  LUKS key and its initramfs drop-ins), then set read-only — a reset years
  later must not authorize the original deployment key or rejoin its tailnet.
- The missing-Node-tarball case is a hard install error on every install,
  not just OEM: the stash is what lets a factory reset finalize offline.
- The configurator's OEM gate checks the runtime package for the service
  unit as well as the setup binary.
- The test harness handles the deliberately skipped mode picker on blank
  disks when the bundled runtime lacks OEM support.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
David Heinemeier HanssonandClaude Fable 5 committed 2026-08-07 18:09:10 -07:00
1 parent 445db32792
commit e49ea2bc96
5 files changed
+110 -15

No files matched your search

@@ -65,6 +65,15 @@ class InstallContext:
else:
raise RuntimeError(f"credentials file missing: {creds_path}")
if oem:
# OEM promises no account exists until first boot. A supplied
# credentials file (a rig handing over its LUKS passphrase) must
# not smuggle in users or a root password.
encryption_password = user_credentials.get("encryption_password")
user_credentials = {"users": []}
if encryption_password:
user_credentials["encryption_password"] = encryption_password
arch_configuration = dict(user_configuration)
arch_configuration.pop("omarchy_install", None)
state_dir = Path(os.environ.get("OMARCHY_INSTALL_STATE_DIR", "/run/omarchy-install"))
@@ -1208,13 +1208,13 @@ def stage_oem_state(ctx: InstallContext) -> None:
def _stage_node_tarball(ctx: InstallContext, oem_dir) -> None:
tarballs = sorted(NODE_PACKAGES_DIR.glob("node-v*-linux-x64.tar.gz"))
if not tarballs:
if ctx.oem:
raise RuntimeError(
"no bundled Node tarball in /opt/packages — OEM first-boot setup "
"could not finalize the user offline"
)
info("› no bundled Node tarball to stash for factory reset; skipping")
return
# Hard error on every install, not just OEM: the stash is what lets a
# later factory reset finalize the next owner offline, and an ISO
# build always bundles the tarball — its absence means a broken build.
raise RuntimeError(
f"no bundled Node tarball in {NODE_PACKAGES_DIR} — first-boot setup "
"and factory reset could not finalize a user offline"
)
packages_dir = oem_dir / "packages"
packages_dir.mkdir(parents=True, exist_ok=True)
@@ -1820,13 +1820,41 @@ def create_factory_snapshot(ctx: InstallContext) -> None:
info("› snapshotting @ as @factory (read-only)")
subprocess.run(
["btrfs", "subvolume", "snapshot", "-r", str(root_subvol), str(factory)],
["btrfs", "subvolume", "snapshot", str(root_subvol), str(factory)],
check=True,
)
_scrub_factory_snapshot(factory)
subprocess.run(
["btrfs", "property", "set", "-ts", str(factory), "ro", "true"],
check=True,
)
finally:
subprocess.run(["umount", str(top)], check=False, capture_output=True)
# Provisioning credentials staged for THIS deployment's first boot must not
# survive into the factory image: a reset years later would otherwise hand the
# next owner the original deployment's SSH keys or rejoin its tailnet, and a
# stale OEM LUKS key (dead after the first re-key) has no business lingering.
# The mkinitcpio/cmdline drop-ins go with the keyfile — a reset rebuild would
# otherwise fail on FILES pointing at a scrubbed path.
FACTORY_SCRUB_PATHS = (
"var/lib/omarchy/oem/authorized_keys",
"var/lib/omarchy/oem/luks-key",
"etc/omarchy/oem.key",
"etc/limine-entry-tool.d/99-omarchy-oem-unlock.conf",
"etc/mkinitcpio.conf.d/99-omarchy-oem-key.conf",
"etc/tailscale/authkey",
"etc/systemd/system/omarchy-tailscale-join.service",
"etc/systemd/system/multi-user.target.wants/omarchy-tailscale-join.service",
)
def _scrub_factory_snapshot(factory: Path) -> None:
for rel in FACTORY_SCRUB_PATHS:
(factory / rel).unlink(missing_ok=True)
def _findmnt_value(path: Path, column: str) -> str | None:
res = subprocess.run(
["findmnt", "-no", column, str(path)],