mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 11:05:45 +00:00
cmd/tailscaled: log SCM interactions if the policy setting is enabled at the time of interaction
This updates the syspolicy.LogSCMInteractions check to run at the time of an interaction, just before logging a message, instead of during service startup. This ensures the most recent policy setting is used if it has changed since the service started. Updates #12687 Signed-off-by: Nick Khyl <nickk@tailscale.com>
This commit is contained in:
parent
50bf32a0ba
commit
7c8f663d70
@ -134,14 +134,13 @@ func runWindowsService(pol *logpolicy.Policy) error {
|
|||||||
logger.Logf(log.Printf).JSON(1, "SupportInfo", osdiag.SupportInfo(osdiag.LogSupportInfoReasonStartup))
|
logger.Logf(log.Printf).JSON(1, "SupportInfo", osdiag.SupportInfo(osdiag.LogSupportInfoReasonStartup))
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if logSCMInteractions, _ := syspolicy.GetBoolean(syspolicy.LogSCMInteractions, false); logSCMInteractions {
|
if syslog, err := eventlog.Open(serviceName); err == nil {
|
||||||
syslog, err := eventlog.Open(serviceName)
|
syslogf = func(format string, args ...any) {
|
||||||
if err == nil {
|
if logSCMInteractions, _ := syspolicy.GetBoolean(syspolicy.LogSCMInteractions, false); logSCMInteractions {
|
||||||
syslogf = func(format string, args ...any) {
|
|
||||||
syslog.Info(0, fmt.Sprintf(format, args...))
|
syslog.Info(0, fmt.Sprintf(format, args...))
|
||||||
}
|
}
|
||||||
defer syslog.Close()
|
|
||||||
}
|
}
|
||||||
|
defer syslog.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
syslogf("Service entering svc.Run")
|
syslogf("Service entering svc.Run")
|
||||||
|
Loading…
Reference in New Issue
Block a user