Skip to content

fix: thread LocalNetPath through ciConfig for root-manager tunneling - #320

Merged
scott-cotton merged 2 commits into
mainfrom
fix/preserve-localnet-path-through-sudo
Apr 28, 2026
Merged

scott-cotton merged 2 commits into
mainfrom
fix/preserve-localnet-path-through-sudo

Conversation

@scott-cotton

@scott-cotton scott-cotton commented Apr 20, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Pair with signadot/libconnect#158, which now takes a ClientConfig.LocalNetPath string prepended to PATH when libconnect execs iptables/pfctl/route. Fixes the exit status 127 seen on Gitpod where the user's PATH lacks /usr/sbin.
  • Capture $SIGNADOT_LOCALNET_PATH at CLI invocation with os.LookupEnv while the user's shell env is still visible. Unset → default /usr/sbin:/sbin; explicitly empty → no prepend (opt-out for NixOS etc.); set → pass through. Resolved string carried on a new ciConfig.LocalNetPath field and wired into localnet.ClientConfig in the root-manager.
  • The sudo --preserve-env list is unchanged — the env var never needs to survive the sudo elevation because the policy decision is resolved in the CLI before the daemon is spawned.
  • Bumps libconnect to the paired branch commit. Needs a final bump once signadot/libconnect#158 merges and is tagged before this lands on main.

Design note

Earlier iteration of this change extended --preserve-env to pass SIGNADOT_LOCALNET_PATH through sudo and had libconnect read it via os.LookupEnv. The ciConfig route is better because:

  • ciConfig is already the canonical "user-invocation state captured and handed to the daemon" boundary; this value fits that shape.
  • Removes a tacit coupling (libconnect env-var API + CLI --preserve-env list staying in sync across two repos).
  • libconnect stays policy-free — no env-var read, no default, no unset-vs-empty tri-state. The distinction is resolved at the CLI layer where the user's shell env is visible, then a single string flows through.

Behavior

  • Default (no env var): libconnect invokes iptables/pfctl/route with PATH=/usr/sbin:/sbin:$UIDPath. Gitpod works without the sudo ln -s /usr/sbin/iptables /usr/bin/iptables workaround.
  • SIGNADOT_LOCALNET_PATH=... exported by user: that value is prepended instead of the default.
  • SIGNADOT_LOCALNET_PATH= (empty): prepend disabled, tunnel-setup execs inherit root-manager env unmodified.
  • Port-forward / kubeconfig exec auth plugins: unaffected. Sandbox-manager env is not touched.

Test plan

  • go build ./...
  • go test ./...
  • gofmt -l internal/
  • Reproduce the failure on a developer env where iptables at /usr/sbin/iptables is not on user PATH, confirm signadot local connect succeeds.
  • Confirm port-forward + kubeconfig exec auth (e.g. EKS with aws-iam-authenticator, GKE with gke-gcloud-auth-plugin) still works.
  • After signadot/libconnect#158 merges: bump libconnect to the merged commit/tag.

🤖 Generated with Claude Code

Pair with signadot/libconnect, which now takes a ClientConfig.LocalNetPath
string prepended to PATH when exec'ing tunnel-setup commands (iptables
on linux; pfctl and route on darwin). Fixes the "exit status 127" seen
on Gitpod and similar environments where the user's PATH lacks
/usr/sbin where iptables lives.

Capture $SIGNADOT_LOCALNET_PATH at CLI invocation time with
os.LookupEnv so unset vs. explicitly-empty are distinguished before
serialization — unset defaults to /usr/sbin:/sbin, empty disables the
prepend for environments (e.g. NixOS) where the default search is
incorrect, set values pass through. The resolved string lives on
ciConfig.LocalNetPath and is wired into localnet.ClientConfig in the
root-manager.

The --preserve-env list on the sudo invocation is unchanged; the
policy decision is made in the CLI (where the user's shell env is
still visible) and carried through ciConfig, so libconnect holds no
env-var lookup or default of its own.

Bumps libconnect to the paired branch commit; needs a final bump once
that PR merges and is tagged.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@scott-cotton
scott-cotton force-pushed the fix/preserve-localnet-path-through-sudo branch from cab74ac to f681494 Compare April 21, 2026 07:29
@scott-cotton scott-cotton changed the title fix: preserve SIGNADOT_LOCALNET_PATH through sudo for root-manager fix: thread LocalNetPath through ciConfig for root-manager tunneling Apr 21, 2026

@daniel-de-vera daniel-de-vera left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@scott-cotton
scott-cotton merged commit dd2682f into main Apr 28, 2026
@scott-cotton
scott-cotton deleted the fix/preserve-localnet-path-through-sudo branch April 28, 2026 20:27
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.

2 participants