Repository navigation
Fix Linux remote wipe deleting nothing on NixOS - #58165
Conversation
The detached systemd-run unit starts with systemd's default PATH, which on NixOS has no coreutils or awk, so every rm failed silently while the host still halted. Add the NixOS system profile to PATH, drop hardcoded /usr/bin paths, and abort before deleting if awk or rm are missing, since is_network_mount fails open without awk.
There was a problem hiding this comment.
🟡 Changes recommended
Missing awk or rm can abort only the detached child after users are locked out, while the parent returns success and Fleet incorrectly reports the intact host as wiped.
1 open issue
1 file not reviewed
changes/56443-nixos-wipe-path: Excluded by your content exclusion settings
What changed in this PR
This PR fixes command discovery in Fleet’s Linux remote wipe script on NixOS, including the detached process launched by systemd.
Changes:
- Adds the NixOS system profile to
PATHand resolvessyncandnohupwithout hardcoded paths. - Adds a child-side prerequisite check for
awkandrmbefore deletion. - Updates script assertions to cover NixOS command paths and preflight ordering.
| File | Description |
|---|---|
ee/server/service/embedded_scripts/linux_wipe.sh |
Adds NixOS command discovery and wipe prerequisite validation. |
ee/server/service/embedded_scripts_test.go |
Checks command-path portability and preflight placement. |
Review effort: Balanced
| } | ||
|
|
||
| wipe_all_files() { | ||
| require_wipe_commands |
|
Caution Review failedFailed to post review comments. GitHub was unavailable or timed out while CodeRabbit was posting the review. Please request a new review later if the pull request still needs one. This happened while posting 5 inline comments. Use Review findings with unconfirmed publication: 3
Review summary publication is unconfirmed.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #58165 +/- ##
==========================================
- Coverage 78.57% 78.57% -0.01%
==========================================
Files 3774 3774
Lines 265736 265736
Branches 16712 16712
==========================================
- Hits 208807 208794 -13
- Misses 56732 56745 +13
Partials 197 197
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|

Related issue: Resolves #56443
Fixes the QA failure in #56443 (comment): on NixOS, the detached
fleet-wipeunit (systemd-run) starts with systemd's defaultPATH, which has no coreutils or awk. Everyrmfailed silently,prepare_nix_storefailed atawk, and the sysrq halt still ran, so Fleet reported the host as wiped while nothing was deleted. Thesystemd-rundetach (#53131, 4.93.0) predates NixOS support (#54098, 4.94.0), so NixOS wipes have deleted nothing since 4.94.0.Changes to
linux_wipe.sh:/run/current-system/sw/bintoPATHwhen it exists, for both the parent and the detached child./usr/bin/syncand/usr/bin/nohup(NixOS has no/usr/binbesidesenv).awkorrmis missing. Withoutawk,is_network_mountreports every path as local, so a host withrmbut noawkwould delete network-mounted data.No behavior change on FHS distros.
Checklist for submitter
changes/,orbit/changes/oree/fleetd-chrome/changes.See Changes files for more information.
Testing
Added/updated automated tests
QA'd all new/changed functionality manually
Not yet tested on a real NixOS host. Ran the detached child in a throwaway
nixos/nixcontainer (gawk + util-linux added) set up like NixOS: tools only in/nix/storeexposed via/run/current-system/sw/bin,/nix/storeas a read-only bind mount, child run with systemd's defaultPATH:main/home,/etc,/varand/nix/storekept/home,/etc,/vardeleted;/nix/storeremounted rw and deleted lastError: awk not found in PATH (...); aborting wipe; nothing deletedAlso ran the child on
ubuntu:24.04formainand this PR: identical results.For unreleased bug fixes in a release candidate, one of:
AI
AI: Claude Code (claude-opus-5-5)
Summary by CodeRabbit