util/syspolicy: add ReadStringArray interface (#11857)

Fixes tailscale/corp#19459

This PR adds the ability for users of the syspolicy handler to read string arrays from the MDM solution configured on the system.

Signed-off-by: Andrea Gottardo <andrea@gottardo.me>
This commit is contained in:
Andrea Gottardo
2024-04-23 22:23:48 -07:00
committed by GitHub
parent 0cce456ee5
commit 1d3e77f373
9 changed files with 81 additions and 0 deletions

View File

@@ -36,6 +36,15 @@ func GetBoolean(key Key, defaultValue bool) (bool, error) {
return v, err
}
func GetStringArray(key Key, defaultValue []string) ([]string, error) {
markHandlerInUse()
v, err := handler.ReadStringArray(string(key))
if errors.Is(err, ErrNoSuchKey) {
return defaultValue, nil
}
return v, err
}
// PreferenceOption is a policy that governs whether a boolean variable
// is forcibly assigned an administrator-defined value, or allowed to receive
// a user-defined value.