logpolicy: use syspolicy to override LogTarget

Previously, for Windows clients only, a registry value named LogTarget
could override the log server, but only if the environment variable was
unset.

To allow administrators to enforce using a particular log server, switch
this to make the registry value take precedence over the environment
variable, and switch to the newer syspolicy.GetString so that the log
target can be specified by a GPO more easily.

Updates ENG-2515

Change-Id: Ia618986b0e07715d7db4c6df170a24d511c904c9
Signed-off-by: Adrian Dewhurst <adrian@tailscale.com>
andrew/peer-ipv6-addrs
Adrian Dewhurst 11 months ago committed by Adrian Dewhurst
parent 1406a9d494
commit 3d57c885bf

@ -48,8 +48,8 @@ import (
"tailscale.com/util/clientmetric" "tailscale.com/util/clientmetric"
"tailscale.com/util/must" "tailscale.com/util/must"
"tailscale.com/util/racebuild" "tailscale.com/util/racebuild"
"tailscale.com/util/syspolicy"
"tailscale.com/util/testenv" "tailscale.com/util/testenv"
"tailscale.com/util/winutil"
"tailscale.com/version" "tailscale.com/version"
"tailscale.com/version/distro" "tailscale.com/version/distro"
) )
@ -61,14 +61,8 @@ var getLogTargetOnce struct {
func getLogTarget() string { func getLogTarget() string {
getLogTargetOnce.Do(func() { getLogTargetOnce.Do(func() {
if val, ok := os.LookupEnv("TS_LOG_TARGET"); ok { envTarget, _ := os.LookupEnv("TS_LOG_TARGET")
getLogTargetOnce.v = val getLogTargetOnce.v, _ = syspolicy.GetString(syspolicy.LogTarget, envTarget)
} else {
if runtime.GOOS == "windows" {
logTarget, _ := winutil.GetRegString("LogTarget")
getLogTargetOnce.v = logTarget
}
}
}) })
return getLogTargetOnce.v return getLogTargetOnce.v

Loading…
Cancel
Save