hostinfo: add hostinfo.IsNATLabGuestVM

And don't make guests under vnet/natlab upload to logcatcher,
as there won't be a valid cert anyway.

Updates #13038

Change-Id: Ie1ce0139788036b8ecc1804549a9b5d326c5fef5
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2024-08-07 20:32:11 -07:00
committed by Maisem Ali
parent 8594292aa4
commit 1016aa045f
4 changed files with 20 additions and 33 deletions

View File

@@ -27,6 +27,7 @@ import (
"tailscale.com/util/dnsname"
"tailscale.com/util/lineread"
"tailscale.com/version"
"tailscale.com/version/distro"
)
var started = time.Now()
@@ -462,3 +463,15 @@ func IsSELinuxEnforcing() bool {
out, _ := exec.Command("getenforce").Output()
return string(bytes.TrimSpace(out)) == "Enforcing"
}
// IsNATLabGuestVM reports whether the current host is a NAT Lab guest VM.
func IsNATLabGuestVM() bool {
if runtime.GOOS == "linux" && distro.Get() == distro.Gokrazy {
cmdLine, _ := os.ReadFile("/proc/cmdline")
return bytes.Contains(cmdLine, []byte("tailscale-tta=1"))
}
return false
}
// NAT Lab VMs have a unique MAC address prefix.
// See