cli: attach to pi sessions by name/id + doctor non-root clarity#57
Merged
Conversation
Greptile SummaryThis PR improves
Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[baudbot doctor] --> B{id -u == 0?}
B -->|Yes| C[IS_ROOT=1]
B -->|No| D[IS_ROOT=0]
D --> E["Print: Running without root advisory"]
C --> F[Run checks]
E --> F
F --> G{Check succeeds?}
G -->|Yes| H[pass]
G -->|No| I{IS_ROOT == 0?}
I -->|Yes| J{Parent dir exists?}
I -->|No root run| K[fail - genuine failure]
J -->|Yes| L["warn: cannot verify as non-root"]
J -->|No| K
F --> M{Firewall check}
M -->|iptables succeeds| N[pass]
M -->|Fails| O{iptables exists AND not root?}
O -->|Yes| P["warn: cannot verify firewall as non-root"]
O -->|No| Q["warn: firewall not active"]
F --> R{systemctl checks}
R --> S{Capture enabled_state}
S -->|enabled| T{Capture active_state}
S -->|auth error + non-root| U["warn: cannot verify unit state"]
S -->|other| V["warn: unit not installed"]
T -->|active| W[pass]
T -->|auth error + non-root| X["warn: cannot verify runtime"]
T -->|other| Y["warn: agent not running"]
Last reviewed commit: 2e49b68 |
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.
Summary
Improve
baudbot doctorUX when run without root privileges.Previously, running
baudbot doctoras a non-root user could show misleading failures/warnings (for example around runtime files or firewall state) that looked like actual system breakage. This PR makes those cases explicit as permission-limited / inconclusive checks with clear guidance to runsudo baudbot doctorfor authoritative results.Changes
bin/doctor.shIS_ROOTflag)..envvisibility edge casetool-guard.tsverificationiptables) verificationWhy
This reduces operator confusion during normal non-root usage while preserving strict diagnostics for root/admin runs.
Validation
bash -n bin/doctor.shbash bin/test.sh shell(all pass)./bin/doctor.shnow explains non-root inconclusive checks instead of implying system inactivity/breakage.