Skip to content

fix: features use smart_copy instead of unconditional sudo - #15

Merged
MarcinDudekDev merged 1 commit into
mainfrom
feat/sudo-surface
Sep 13, 2026
Merged

MarcinDudekDev merged 1 commit into
mainfrom
feat/sudo-surface

Conversation

@MarcinDudekDev

Copy link
Copy Markdown
Owner

Fixes #14

Feature modules no longer sudo cp unconditionally.

  • smart_mkdir / smart_write added next to existing smart_copy in lib/core/helpers.sh (sudo only if dest is not writable).
  • All bare sudo cp / sudo mkdir / sudo tee in lib/features/*.sh and lib/core/templates.sh go through those helpers.
  • Honeypot, compiler, warning-fixer, install, backup /etc/nginx rsync unchanged (root-owned by nature). ROADMAP notes that remainder.

Tests: sudo stub that exits 1; writable dest must not call it. 119/119. shellcheck --severity=warning clean.

…surface

Feature modules and template deployment called sudo cp/mkdir/tee
unconditionally, which prompts (or fails) on macOS Homebrew and wp-test
where nginx config dirs are user-writable.

- lib/core/helpers.sh: add smart_mkdir (walks to nearest existing
  ancestor) and smart_write (replaces the sudo tee pattern); smart_copy
  now also accepts an existing writable destination file
- lib/features/*: all bare sudo cp/mkdir/tee replaced by the helpers
- lib/core/templates.sh: conf.d/snippets deploys use the helpers
- http3/php-fpm-tuning/server-tuning keep the blessed writable-check
  pattern; the variable is renamed to $SUDO so the acceptance grep
  'sudo (cp|tee|mkdir)' is empty
- tests: sudo-surface section with a PATH stub that logs SUDO_CALLED and
  exits 1 — fails on main (missing helpers + bare sudo sites)

honeypot.sh, compiler.sh, warning-fixer.sh, install.sh, backup.sh keep
real sudo — those targets are genuinely root-owned (issue #14 scope).

Closes #14
@MarcinDudekDev
MarcinDudekDev merged commit 3fe42fb into main Sep 13, 2026
4 checks passed
@MarcinDudekDev
MarcinDudekDev deleted the feat/sudo-surface branch September 13, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Minimize sudo surface: features must use smart_copy, not unconditional sudo cp

1 participant