nixos-deploy wrapper steals sudo PATH and breaks 'just deploy' #138
Labels
No labels
area:authentication
area:flake-utilities
area:performance
area:tbd
host:chaos
host:electra
host:fleet
host:lyra
host:nova
host:vega
investigation
phase:cutover
phase:deploy
phase:mcp
phase:module
phase:packaging
phase:prep
phase:validation
priority:high
priority:medium
project:attic-postgres-lyra-rollout
project:auto-update-reliability
project:auto-update-remediation
project:declarative-purity-cleanup
project:external-review
project:fleet-boundary-cleanup
project:host-facts-refactor
project:lyra-nixos-deploy
project:lyra-service-stack-migration
project:nebula-mesh-network
project:nixos-build-deployment-pipeline
project:security-hardening
project:service-stack-migration
project:vega-sillytavern-cutover
project:wiki-rebuild
repo:numtide/flake-utils
repo:numtide/nix-auth
repo:numtide/nixos-passthru-cache
repo:numtide/nix-relay
service:auto-update
service:mem0
service:nix
service:sillytavern
service:slskd
service:synthseek
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
nimmo/nixos-config#138
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Restore the pre-PR-#125 behaviour of
just deploy(usesnom, can run as anon-root user via the system setuid sudo wrapper) while keeping the new
packages/nixos-deployNix module that replaced the inline Justfile bash.Context
PR #125 moved the long inline bash recipe from
justfiles/deploy.justintoscripts/nixos-deploy.shand packaged it aspackages/nixos-deploy/default.nix(
writeShellApplicationwithruntimeInputs = [ coreutils hostname nix nvd nix-output-monitor openssh sudo ]).The script still does the right things when invoked directly. However,
just deploynow shells out tonix run .#nixos-deploy -- ..., and thewriteShellApplicationwrapper hard-codes a PATH that begins with the storesudo (
/nix/store/...-sudo-1.9.17p2/bin/sudo, mode 0555, not setuid) beforethe user's PATH. The setuid sudo lives at
/run/wrappers/bin/sudo(mode4551), and is only first on PATH when the user opens a normal terminal — i.e.
after
/etc/set-environmentdoesexport PATH="/run/wrappers/bin:$PATH".Symptom:
just deployaborts atsudo -vwithsudo: /run/current-system/sw/bin/sudo must be owned by uid 0 and have the setuid bit set— i.e. it "complains about not being root". It also lookslike
just deployno longer usesnom, because the Justfile now only callsnix run .#nixos-deploy; thenom buildcall is buried inside the packagedscript and never runs.
Scope
packages/nixos-deploy/default.nixas the canonical "module" for thedeploy command (per user direction: don't go back to inline Justfile bash).
resolves
sudovia the caller's environment, which is the/run/wrappers/bin/sudosetuid wrapper on every NixOS host.NIXOS_DEPLOY_SUDO(and the otherNIXOS_DEPLOY_*env vars) for explicit overrides; that mechanism stays.writeShellApplicationwrapper (or via
nix run) to exercise the real PATH assembly, so thiscannot regress again.
sudois intentionally absent fromruntimeInputs.Acceptance criteria
just deploy(andnix run .#nixos-deploy -- ...) reaches thenom build --fallback ...step on a non-root invocation on a NixOS host.NIXOS_DEPLOY_SUDO=/custom/path/sudo just deploystill overrides cleanly.nix flake checkand the new wrapped-PATH regression pass.nixos-deploycommand's--helpand argument parsing remainunchanged.
Notes
just deploystarted failing with the"must be owned by uid 0 and have the setuid bit set" sudo error after
the PR #125 packaging landed.
security.wrappers(setuid)wrapper for sudo at the system level, but that's already what
/run/wrappers/bin/sudois — we just need the deploy wrapper to stopshadowing it.