Skip to content

Tailscale: attempt non-interactive sudo#1551

Merged
steipete merged 4 commits into
openclaw:mainfrom
sweepies:tailscale-sudo-fix-4134132251462829549
Jan 24, 2026
Merged

Tailscale: attempt non-interactive sudo#1551
steipete merged 4 commits into
openclaw:mainfrom
sweepies:tailscale-sudo-fix-4134132251462829549

Conversation

@sweepies

Copy link
Copy Markdown

Modifying Tailscale configuration does not work without sudo by default. By attempting passwordless sudo (sudo -n) we can potentially streamline the setup for non-root installs. Currently Tailscale errors are guaranteed to happen unless Clawdbot is running as root or the user has manually enabled nonroot user Tailscale control already.

(Code written by Google Jules)

@steipete steipete self-assigned this Jan 24, 2026
google-labs-jules Bot and others added 4 commits January 24, 2026 00:17
To avoid permission denied errors when modifying Tailscale configuration (serve/funnel),
we now prepend `sudo -n` to these commands. This ensures that if the user has appropriate
sudo privileges (specifically passwordless for these commands or generally), the operation
succeeds. If sudo fails (e.g. requires password non-interactively), it will throw an error
which is caught and logged as a warning, preserving existing behavior but attempting to escalate privileges first.

- Updated `ensureFunnel` to use `sudo -n` for the enabling step.
- Updated `enableTailscaleServe`, `disableTailscaleServe`, `enableTailscaleFunnel`, `disableTailscaleFunnel` to use `sudo -n`.
- Added tests in `src/infra/tailscale.test.ts` to verify `sudo` usage.
To avoid permission denied errors when modifying Tailscale configuration (serve/funnel),
we now prepend `sudo -n` to these commands. This ensures that if the user has appropriate
sudo privileges (specifically passwordless for these commands or generally), the operation
succeeds. If sudo fails (e.g. requires password non-interactively), it will throw an error
which is caught and logged as a warning, preserving existing behavior but attempting to escalate privileges first.

- Updated `ensureFunnel` to use `sudo -n` for the enabling step.
- Updated `enableTailscaleServe`, `disableTailscaleServe`, `enableTailscaleFunnel`, `disableTailscaleFunnel` to use `sudo -n`.
To avoid permission denied errors when modifying Tailscale configuration (serve/funnel),
we now attempt the command directly first. If it fails, we catch the error and retry
with `sudo -n`. This preserves existing behavior for users where it works, but
attempts to escalate privileges (non-interactively) if needed.

- Added `execWithSudoFallback` helper in `src/infra/tailscale.ts`.
- Updated `ensureFunnel`, `enableTailscaleServe`, `disableTailscaleServe`,
  `enableTailscaleFunnel`, and `disableTailscaleFunnel` to use the fallback helper.
- Added tests in `src/infra/tailscale.test.ts` to verify fallback behavior.
@steipete
steipete merged commit 05b0b82 into openclaw:main Jan 24, 2026
17 of 22 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Landed via temp rebase onto main.

  • Gate: pnpm lint && pnpm build && pnpm test
  • Land commit: b52b58e
  • Merge commit: 05b0b82

Thanks @sweepies!

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