Skip to content

Commit

Permalink
logpolicy: use syspolicy to override LogTarget
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
sailorfrag committed Jan 3, 2024
1 parent 1406a9d commit 3d57c88
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions logpolicy/logpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ import (
"tailscale.com/util/clientmetric"
"tailscale.com/util/must"
"tailscale.com/util/racebuild"
"tailscale.com/util/syspolicy"
"tailscale.com/util/testenv"
"tailscale.com/util/winutil"
"tailscale.com/version"
"tailscale.com/version/distro"
)
Expand All @@ -61,14 +61,8 @@ var getLogTargetOnce struct {

func getLogTarget() string {
getLogTargetOnce.Do(func() {
if val, ok := os.LookupEnv("TS_LOG_TARGET"); ok {
getLogTargetOnce.v = val
} else {
if runtime.GOOS == "windows" {
logTarget, _ := winutil.GetRegString("LogTarget")
getLogTargetOnce.v = logTarget
}
}
envTarget, _ := os.LookupEnv("TS_LOG_TARGET")
getLogTargetOnce.v, _ = syspolicy.GetString(syspolicy.LogTarget, envTarget)
})

return getLogTargetOnce.v
Expand Down

0 comments on commit 3d57c88

Please sign in to comment.