feature/tpm: quiet log output a bit

I was debugging a customer issue and saw in their 1.88.3 logs:

    TPM: error opening: stat /dev/tpm0: no such file or directory

That's unnecessary output. The lack of TPM will be reported by
them having a nil Hostinfo.TPM, which is plenty elsewhere in logs.

Let's only write out an "error opening" line if it's an interesting
error. (perhaps permissions, or EIO, etc)

Updates #cleanup

Change-Id: I3f987f6bf1d3ada03473ca3eef555e9cfafc7677
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick 2025-10-05 12:43:54 -07:00 committed by Brad Fitzpatrick
parent 005e264b54
commit 1a93a8a704

View File

@ -73,10 +73,16 @@ func info() *tailcfg.TPMInfo {
tpm, err := open()
if err != nil {
logf("error opening: %v", err)
if !os.IsNotExist(err) || verboseTPM() {
// Only log if it's an interesting error, not just "no TPM",
// as is very common, especially in VMs.
logf("error opening: %v", err)
}
return nil
}
logf("successfully opened")
if verboseTPM() {
logf("successfully opened")
}
defer tpm.Close()
info := new(tailcfg.TPMInfo)