mirror of https://github.com/tailscale/tailscale/
xcode/iOS: support serial number collection via MDM on iOS
Fixes tailscale/corp#18366. This PR provides serial number collection on iOS, by allowing system administrators to pass a `DeviceSerialNumber` MDM key which can be read by the `posture` package in Go. Signed-off-by: Andrea Gottardo <andrea@gottardo.me>18366-xcodeios-support-serial-number-collection-via-mdm-on-ios
parent
da7c3d1753
commit
fb6a33546b
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (c) Tailscale Inc & AUTHORS
|
||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
//go:build ios
|
||||||
|
|
||||||
|
package posture
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"tailscale.com/types/logger"
|
||||||
|
"tailscale.com/util/syspolicy"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetSerialNumber returns the serial number of the iOS device as reported by an
|
||||||
|
// MDM solution. Requires configuration via the DeviceSerialNumber system policy.
|
||||||
|
// This is the only way to gather serial numbers on iOS and tvOS.
|
||||||
|
func GetSerialNumbers(_ logger.Logf) ([]string, error) {
|
||||||
|
serials := []string{}
|
||||||
|
|
||||||
|
serialNumberFromMDM, err := syspolicy.GetString("DeviceSerialNumber", "")
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to get serial number from MDM: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if serialNumberFromMDM != "" {
|
||||||
|
serials = append(serials, serialNumberFromMDM)
|
||||||
|
}
|
||||||
|
|
||||||
|
return serials, nil
|
||||||
|
}
|
Loading…
Reference in New Issue