Skip to content

fix(debug): make fs and portfw work as intended - #10

Merged
chxmxii merged 1 commit into
mainfrom
fix/portfw-fs
Aug 23, 2026
Merged

chxmxii merged 1 commit into
mainfrom
fix/portfw-fs

Conversation

@chxmxii

@chxmxii chxmxii commented Aug 23, 2026

Copy link
Copy Markdown
Owner

Two more debug commands fixed for real-world (especially rootless) use:

fs — /proc/<pid>/root is only readable by the process owner or root; on stricter setups the command just errored. It now falls back to in-container ls/find (with --match support), and failures name both attempts.

portfw — was proxying through host socat inside nsenter: broken without socat installed, needed root but failed silently per connection after printing "Forwarding…", and --local/--remote omissions forwarded to port 0. Now: pure-Go dial inside the container's netns (setns on a dedicated locked thread — no external binaries), a preflight check that fails fast with "requires root — try sudo", --remote as the only required flag (--local defaults to it), and symmetric connection teardown.

Verified live against rootless Podman 5.8.4:

  • fs --path /etc and --recursive --match "host*" list correctly
  • rootless portfw fails fast with the actionable error
  • sudo portfw -R 8080 -l 9191: real traffic flowed through the tunnel (hello-through-forward received from an in-container nc listener)
  • go vet + go test -race green

🤖 Generated with Claude Code

fs: reading the container root via /proc/<pid>/root requires root or
process ownership; when that fails it now falls back to running ls (or
find, for recursive listings with --match) inside the container instead
of erroring out, and the combined error names both attempts.

portfw: the forward proxied each connection through host socat inside
nsenter — failing when socat is missing, needing root but only failing
silently per-connection, and forwarding to port 0 when flags were
omitted. Connections are now dialed directly inside the container's
network namespace in pure Go (setns on a dedicated locked thread, no
socat/nsenter needed), namespace access is preflighted with an
actionable needs-root error before the listener starts, --remote is
the only required flag (--local defaults to it), and both directions
tear down when either side closes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@chxmxii
chxmxii merged commit f7940eb into main Aug 23, 2026
1 check passed
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.

1 participant