summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorKristoffer Dalby <kristoffer@tailscale.com>2023-11-13 13:45:52 +0000
committerKristoffer Dalby <kristoffer@tailscale.com>2023-11-13 15:33:35 +0000
commitb2d11995c9703fd09617e23a64a1f943bf029a71 (patch)
treea0fb5b3fa06f9a38a65658beb9fd6a5dbb7f1a15
parent86c8ab7502a38b4de05308355fe0c847e4e78167 (diff)
downloadtailscale-kristoffer/editable-tailnet-displayname.tar.xz
tailscale-kristoffer/editable-tailnet-displayname.zip
posture: ignore not found serial errorskristoffer/editable-tailnet-displayname
-rw-r--r--posture/serialnumber_notmacos.go21
1 files changed, 7 insertions, 14 deletions
diff --git a/posture/serialnumber_notmacos.go b/posture/serialnumber_notmacos.go
index 2e03fac4c..d75a18dfa 100644
--- a/posture/serialnumber_notmacos.go
+++ b/posture/serialnumber_notmacos.go
@@ -8,7 +8,6 @@
package posture
import (
- "errors"
"fmt"
"strings"
@@ -31,17 +30,17 @@ func getByteFromSmbiosStructure(s *smbios.Structure, specOffset int) uint8 {
// getStringFromSmbiosStructure retrieves a string at the given specOffset.
// Returns an empty string if no string was present.
-func getStringFromSmbiosStructure(s *smbios.Structure, specOffset int) (string, error) {
+func getStringFromSmbiosStructure(s *smbios.Structure, specOffset int) string {
index := getByteFromSmbiosStructure(s, specOffset)
if index == 0 || int(index) > len(s.Strings) {
- return "", errors.New("specified offset does not exist in smbios structure")
+ return ""
}
str := s.Strings[index-1]
trimmed := strings.TrimSpace(str)
- return trimmed, nil
+ return trimmed
}
// Product Table (Type 1) structure
@@ -71,7 +70,6 @@ func init() {
validTables = append(validTables, table)
}
numOfTables = len(validTables)
-
}
// serialFromSmbiosStructure extracts a serial number from a product,
@@ -86,14 +84,7 @@ func serialFromSmbiosStructure(s *smbios.Structure) (string, error) {
)
}
- serial, err := getStringFromSmbiosStructure(s, serialNumberOffset)
- if err != nil {
- return "", fmt.Errorf(
- "failed to get serial from %s table: %w",
- idToTableName[int(s.Header.Type)],
- err,
- )
- }
+ serial := getStringFromSmbiosStructure(s, serialNumberOffset)
return serial, nil
}
@@ -125,7 +116,9 @@ func GetSerialNumbers(logf logger.Logf) ([]string, error) {
continue
}
- serials = append(serials, serial)
+ if serial != "" {
+ serials = append(serials, serial)
+ }
}
}