blob: 448fdb677abefe9157acfd986609f7dd4a313fa8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
// Copyright (c) Tailscale Inc & contributors
// SPDX-License-Identifier: BSD-3-Clause
//go:build android || ios
package posture
import (
"fmt"
"tailscale.com/types/logger"
"tailscale.com/util/syspolicy/pkey"
"tailscale.com/util/syspolicy/policyclient"
)
// GetSerialNumbers returns the serial number of the device as reported by an
// MDM solution. It requires configuration via the DeviceSerialNumber system policy.
// This is the only way to gather serial numbers on iOS, tvOS and Android.
func GetSerialNumbers(polc policyclient.Client, _ logger.Logf) ([]string, error) {
s, err := polc.GetString(pkey.DeviceSerialNumber, "")
if err != nil {
return nil, fmt.Errorf("failed to get serial number from MDM: %v", err)
}
if s != "" {
return []string{s}, nil
}
return nil, nil
}
|