Skip to content

pv status and pv doctor report healthy PF redirects as unreadable without sudo #306

Description

@munezaclovis

Summary

After a successful pv ports:install, normal pv status and pv doctor can still report the active PF redirects as unreadable and fail overall health because inspecting /dev/pf requires root privileges.

At the same time, pv ports:status reports the prepared/system files as current but does not inspect loaded rules. The three diagnostic surfaces therefore disagree on a working machine.

Verified reproduction

After the user repaired the incident with pv ports:install:

  • default and forced-IPv4 https://ai.test returned HTTP 200 through 127.0.0.1:443;
  • direct Gateway HTTPS on 48443 also returned 200;
  • pv ports:status reported every prepared/system PF file as current;
  • pv status --json reported "ports":"unreadable";
  • pv doctor failed with active pf redirects could not be inspected and suggested running pv ports:install again.

The host behavior is deterministic:

$ /sbin/pfctl -s nat
pfctl: /dev/pf: Permission denied

$ sudo -n /sbin/pfctl -s nat
sudo: a password is required

$ ls -l /dev/pf
crw-------  root wheel  /dev/pf

Current code paths

  • pv status invokes active PF inspection after file state is current: status.rs.
  • Active inspection tries pfctl, then non-interactive sudo -n: pf.rs.
  • An inspection error becomes ports: unreadable and a system failure: status.rs.
  • Doctor fails the same state and recommends reinstalling: doctor.rs.
  • pv ports:status inspects only files and always exits success: ports.rs.

Expected behavior

Read-only diagnostics should provide a reliable, non-interactive health classification without depending on a warm sudo credential. Lack of permission to enumerate PF rules must not make a verified-working route look broken or recommend repeating an already-successful install.

The exact fallback mechanism requires a design decision; status/doctor must remain non-mutating and must not prompt for authentication.

Acceptance criteria

  • pv status, pv doctor, and pv ports:status agree about healthy, inactive, stale, and genuinely uninspectable routing states.
  • A normal user with no cached sudo authentication can obtain useful status without a prompt.
  • A working end-to-end low-port route is not reported as failed solely because /dev/pf is unreadable.
  • An inactive/missing route is still reported as repair-required with pv ports:install.
  • JSON output distinguishes verified health from any intentionally unknown/uninspectable state.
  • Add coverage for permission-denied PF inspection with both working and broken low-port routing.
  • Keep mutating PF operations foreground-only.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggatewayGateway, DNS, TLS, pv openpriority-highP1 high priorityqualityTesting, status, QA, scopevalue-highHigh value

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions