From 088c37929c4227890fbc8d08498b81483a72d969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Cie=C5=9Blak?= Date: Tue, 30 Jul 2024 16:59:31 +0200 Subject: [PATCH] Implement LogValue for ClientCred --- lib/vnet/daemon/common.go | 9 +++++++++ lib/vnet/daemon/service_darwin.go | 3 +-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/vnet/daemon/common.go b/lib/vnet/daemon/common.go index b7e14facc25ed..fbcd3969d5926 100644 --- a/lib/vnet/daemon/common.go +++ b/lib/vnet/daemon/common.go @@ -17,6 +17,7 @@ package daemon import ( + "log/slog" "time" "github.com/gravitational/trace" @@ -48,6 +49,14 @@ type ClientCred struct { Euid int } +func (c ClientCred) LogValue() slog.Value { + return slog.GroupValue( + slog.Bool("creds_valid", c.Valid), + slog.Int("egid", c.Egid), + slog.Int("euid", c.Euid), + ) +} + func (c *Config) CheckAndSetDefaults() error { switch { case c.SocketPath == "": diff --git a/lib/vnet/daemon/service_darwin.go b/lib/vnet/daemon/service_darwin.go index 34255d814683a..b4e940c77bb63 100644 --- a/lib/vnet/daemon/service_darwin.go +++ b/lib/vnet/daemon/service_darwin.go @@ -26,7 +26,6 @@ import "C" import ( "context" "errors" - "fmt" "time" "unsafe" @@ -78,7 +77,7 @@ func Start(ctx context.Context, workFn func(context.Context, Config) error) erro "ipv6_prefix", config.IPv6Prefix, "dns_addr", config.DNSAddr, "home_path", config.HomePath, - "cred", fmt.Sprintf("%#v", config.ClientCred), + "client_cred", config.ClientCred, ) return trace.Wrap(workFn(ctx, config))