fix: enforce non-root execution in Taskfile and shell scripts #433

Merged
guettlibot merged 6 commits from issue-414-ensure-not-run-as-root into main 2026-06-05 16:41:39 +00:00
guettlibot commented 2026-06-04 20:46:32 +00:00 (Migrated from codeberg.org)

Closes #414

Summary

  • Added a non-root precondition to _preflight in Taskfile.yml, which is the shared dependency for all local task commands (analyze, test, test-widget, build-linux, check, etc.). This is the single choke point that rejects root before any local work begins.
  • Added an identical id -u guard to five scripts that can be invoked directly outside of task: deploy.sh, scripts/setup_dagger_remote.sh, stalwart-dev/test.sh, stalwart-dev/integration_ui_test.sh, stalwart-dev/integration_android_test.sh.
  • Added rm -f ~/.ssh/dagger_key before the write in scripts/setup_dagger_remote.sh so an existing stale file or symlink is cleanly removed rather than clobbered via redirection.

No SSH-as-root patterns were found in any scripts (audit passed clean — setup_dagger_remote.sh uses dagger@$DAGGER_ENGINE_HOST, deploy.sh uses the configurable $SSH_USER, and DEVELOPMENT.md already recommends ssh $DEV_USER@localhost).

Test plan

  • Verify task check (or any task command) prints "Do not run as root" and exits non-zero when run as root.
  • Verify stalwart-dev/test.sh and sibling scripts print the same error when run as root.
  • Verify normal non-root execution is unaffected.

🤖 Generated with Claude Code

Closes #414 ## Summary - Added a non-root precondition to `_preflight` in `Taskfile.yml`, which is the shared dependency for all local `task` commands (`analyze`, `test`, `test-widget`, `build-linux`, `check`, etc.). This is the single choke point that rejects root before any local work begins. - Added an identical `id -u` guard to five scripts that can be invoked directly outside of `task`: `deploy.sh`, `scripts/setup_dagger_remote.sh`, `stalwart-dev/test.sh`, `stalwart-dev/integration_ui_test.sh`, `stalwart-dev/integration_android_test.sh`. - Added `rm -f ~/.ssh/dagger_key` before the write in `scripts/setup_dagger_remote.sh` so an existing stale file or symlink is cleanly removed rather than clobbered via redirection. No SSH-as-root patterns were found in any scripts (audit passed clean — `setup_dagger_remote.sh` uses `dagger@$DAGGER_ENGINE_HOST`, `deploy.sh` uses the configurable `$SSH_USER`, and `DEVELOPMENT.md` already recommends `ssh $DEV_USER@localhost`). ## Test plan - [ ] Verify `task check` (or any `task` command) prints "Do not run as root" and exits non-zero when run as root. - [ ] Verify `stalwart-dev/test.sh` and sibling scripts print the same error when run as root. - [ ] Verify normal non-root execution is unaffected. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.