2023-09-29 17:40:35 +00:00
|
|
|
// 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
|
|
|
|
}
|
2023-09-30 01:27:04 +00:00
|
|
|
|
|
|
|
func (windowsHandler) ReadBoolean(key string) (bool, error) {
|
|
|
|
value, err := winutil.GetPolicyInteger(key)
|
|
|
|
if errors.Is(err, winutil.ErrNoValue) {
|
|
|
|
err = ErrNoSuchKey
|
|
|
|
}
|
|
|
|
return value != 0, err
|
|
|
|
}
|