Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "tailscale ssh" when built with ts_include_cli tag #12109

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions cmd/tailscale/cli/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ func runSSH(ctx context.Context, args []string) error {
// of failing. But for now:
return fmt.Errorf("no system 'ssh' command found: %w", err)
}
tailscaleBin, err := os.Executable()
if err != nil {
return err
}
knownHostsFile, err := writeKnownHosts(st)
if err != nil {
return err
Expand Down Expand Up @@ -116,7 +112,9 @@ func runSSH(ctx context.Context, args []string) error {

argv = append(argv,
"-o", fmt.Sprintf("ProxyCommand %q %s nc %%h %%p",
tailscaleBin,
// os.Executable() would return the real running binary but in case tailscale is built with the ts_include_cli tag,
// we need to return the started symlink instead
os.Args[0],
Copy link
Author

@SuperSandro2000 SuperSandro2000 May 14, 2024

Choose a reason for hiding this comment

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

I've taken this from https://github.com/tailscale/tailscale/pull/5193/files

and verified it by running PATH=/nix/store/klzg9xnlkhxfwlxwm21mfy0jnw5mpyc7-openssh-9.7p1/bin /nix/store/h98b7fwi6ic7cx699f67gp2slawfcv15-strace-6.8/bin/strace ./result/bin/tailscale ssh host -v and checking the execve syscall.

I've also looked at other usages of os.Executable() and I don't think they have a similar problem.

socketArg,
))
}
Expand Down