All checks were successful
Check / eval-and-lint (push) Successful in 6m57s
Ten state-mutating sites across seven scripts wrote through a predictable, world-writable temp path (`/tmp/state.json`, `/tmp/system-state.json`) before the atomic `sudo mv`. Because the `>` redirect runs as the invoking user (sudo doesn't cover redirects), the shared fixed path is a symlink/ TOCTOU target and collides if two of these run concurrently. Switch each to a per-invocation `mktemp`; the atomic rename into place is unchanged. nomarchy-theme-set already used a temp var for its home-state write — this makes its system-state write consistent and cleans the temp up on failure. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
28 lines
878 B
Bash
Executable File
28 lines
878 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
# Configure FIDO2 support declaratively for Nomarchy NixOS.
|
|
|
|
STATE_FILE="/etc/nixos/state.json"
|
|
|
|
if [[ "--remove" == $1 ]]; then
|
|
tmp=$(mktemp); sudo jq '.features.fido2 = false' "$STATE_FILE" > "$tmp" && sudo mv "$tmp" "$STATE_FILE"
|
|
echo "FIDO2 support disabled. Applying changes..."
|
|
sudo nomarchy-sys-update
|
|
exit 0
|
|
fi
|
|
|
|
tmp=$(mktemp); sudo jq '.features.fido2 = true' "$STATE_FILE" > "$tmp" && sudo mv "$tmp" "$STATE_FILE"
|
|
echo "FIDO2 support enabled. Applying changes..."
|
|
sudo nomarchy-sys-update
|
|
|
|
# Enrollment is still an imperative action
|
|
if command -v pamu2fcfg &> /dev/null; then
|
|
echo "Let's register your FIDO2 key now."
|
|
mkdir -p ~/.config/Yubico
|
|
pamu2fcfg > ~/.config/Yubico/u2f_keys
|
|
echo "FIDO2 key registered."
|
|
else
|
|
echo "pamu2fcfg not found. It will be available after the next reboot or sys-update."
|
|
fi
|