fix(doctor): elevate root-only checks (btrfs, podman) via sudo when not root#580
Merged
Conversation
fd89da1 to
e957406
Compare
btrfs (device stats / subvolume list need CAP_SYS_ADMIN) and version_drift (rootful podman is only visible to root) both failed for an unprivileged interactive `bestool tamanu doctor`: btrfs returned EPERM and podman ran rootless and errored. Rather than report blind, elevate those commands via sudo when not root. The alertd daemon runs the sweep as root and invokes them directly, so this only affects interactive non-root runs (assumes passwordless sudo where used; otherwise sudo's failure surfaces in-check). podman elevation goes in the shared running_versions_linux, so `tamanu status` benefits too. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
e957406 to
12b41c3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Running
bestool tamanu doctoras an unprivileged user produces two false warnings:Both are privilege artifacts, not faults — and the data is obtainable, just needs root:
device stats/subvolume listneedCAP_SYS_ADMIN.podman psruns rootless and errors.So rather than skip (go blind), elevate: when not running as root (euid != 0, read from
/proc/self/status), run those commands viasudo. The alertd daemon runs the sweep as root and invokes them directly — this only changes the interactive non-root case, which now collects the same data instead of warning. Assumes passwordless sudo where used; otherwise sudo's own failure surfaces in the check.podman elevation lives in the shared
running_versions_linux, sotamanu statusgets the same fix.Note: this addresses the interactive case. The separate report that the root daemon itself gets EPERM on
btrfs device statsis a sandbox/caps issue in the deployed unit, still being diagnosed — elevation doesn't apply there (already root).