mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
32c0156311
Add a more generalized package for getting policies. Updates tailcale/corp#10967 Signed-off-by: Claire Wang <claire@tailscale.com> Co-authored-by: Adrian Dewhurst <adrian@tailscale.com>
33 lines
617 B
Go
33 lines
617 B
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package syspolicy
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"tailscale.com/util/winutil"
|
|
)
|
|
|
|
type windowsHandler struct{}
|
|
|
|
func init() {
|
|
RegisterHandler(windowsHandler{})
|
|
}
|
|
|
|
func (windowsHandler) ReadString(key string) (string, error) {
|
|
s, err := winutil.GetPolicyString(key)
|
|
if errors.Is(err, winutil.ErrNoValue) {
|
|
err = ErrNoSuchKey
|
|
}
|
|
return s, err
|
|
}
|
|
|
|
func (windowsHandler) ReadUInt64(key string) (uint64, error) {
|
|
value, err := winutil.GetPolicyInteger(key)
|
|
if errors.Is(err, winutil.ErrNoValue) {
|
|
err = ErrNoSuchKey
|
|
}
|
|
return value, err
|
|
}
|