From 34a34e72334d7613b7a17e02a2f51a65a883dd02 Mon Sep 17 00:00:00 2001 From: Michael Smithhisler Date: Wed, 8 Jan 2025 08:50:33 -0500 Subject: [PATCH] plugins: validate logmon process during reattach (#24798) --- .changelog/24798.txt | 3 +++ client/logmon/plugin.go | 10 ++++++++++ 2 files changed, 13 insertions(+) create mode 100644 .changelog/24798.txt diff --git a/.changelog/24798.txt b/.changelog/24798.txt new file mode 100644 index 00000000000..902a2a6d7f5 --- /dev/null +++ b/.changelog/24798.txt @@ -0,0 +1,3 @@ +```release-note:bug +drivers: validate logmon plugin during reattach +``` diff --git a/client/logmon/plugin.go b/client/logmon/plugin.go index d79be2b1bbd..d77b88e50ba 100644 --- a/client/logmon/plugin.go +++ b/client/logmon/plugin.go @@ -59,6 +59,16 @@ func LaunchLogMon(logger hclog.Logger, reattachConfig *plugin.ReattachConfig) (L return nil, nil, err } + // Note: Similar to reattaching to executors, Go-plugin uses localhost + // ports on Windows. On reattach, it may attach to another process + // listening on that port. We should validate it is actually a plugin. + if conf.Reattach != nil { + if err := rpcClient.Ping(); err != nil { + logger.Warn("failed to ping plugin process during reattach", "error", err) + return nil, nil, err + } + } + l := raw.(LogMon) return l, client, nil }