Skip to content

Commit 23880eb

Browse files
committed
cmd/tailscaled: support "ts_omit_ssh" build tag to remove SSH
Some environments would like to remove Tailscale SSH support for the binary for various reasons when not needed (either for peace of mind, or the ~1MB of binary space savings). Updates tailscale/corp#24454 Updates tailscale#1278 Updates tailscale#12614 Change-Id: Iadd6c5a393992c254b5dc9aa9a526916f96fd07a Signed-off-by: Brad Fitzpatrick <[email protected]>
1 parent 2c8859c commit 23880eb

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

cmd/tailscaled/deps_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Tailscale Inc & AUTHORS
2+
// SPDX-License-Identifier: BSD-3-Clause
3+
4+
package main
5+
6+
import (
7+
"testing"
8+
9+
"tailscale.com/tstest/deptest"
10+
)
11+
12+
func TestOmitSSH(t *testing.T) {
13+
const msg = "unexpected with ts_omit_ssh"
14+
deptest.DepChecker{
15+
GOOS: "linux",
16+
GOARCH: "amd64",
17+
Tags: "ts_omit_ssh",
18+
BadDeps: map[string]string{
19+
"tailscale.com/ssh/tailssh": msg,
20+
"golang.org/x/crypto/ssh": msg,
21+
"tailscale.com/sessionrecording": msg,
22+
"github.com/anmitsu/go-shlex": msg,
23+
"github.com/creack/pty": msg,
24+
"github.com/kr/fs": msg,
25+
"github.com/pkg/sftp": msg,
26+
"github.com/u-root/u-root/pkg/termios": msg,
27+
"tempfork/gliderlabs/ssh": msg,
28+
},
29+
}.Check(t)
30+
}

cmd/tailscaled/ssh.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Tailscale Inc & AUTHORS
22
// SPDX-License-Identifier: BSD-3-Clause
33

4-
//go:build linux || darwin || freebsd || openbsd
4+
//go:build (linux || darwin || freebsd || openbsd) && !ts_omit_ssh
55

66
package main
77

tstest/deptest/deptest.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type DepChecker struct {
2121
GOOS string // optional
2222
GOARCH string // optional
2323
BadDeps map[string]string // package => why
24+
Tags string // comma-separated
2425
}
2526

2627
func (c DepChecker) Check(t *testing.T) {
@@ -29,7 +30,7 @@ func (c DepChecker) Check(t *testing.T) {
2930
t.Skip("skipping dep tests on windows hosts")
3031
}
3132
t.Helper()
32-
cmd := exec.Command("go", "list", "-json", ".")
33+
cmd := exec.Command("go", "list", "-json", "-tags="+c.Tags, ".")
3334
var extraEnv []string
3435
if c.GOOS != "" {
3536
extraEnv = append(extraEnv, "GOOS="+c.GOOS)

0 commit comments

Comments
 (0)