diff --git a/.changelog/24798.txt b/.changelog/24798.txt new file mode 100644 index 000000000..902a2a6d7 --- /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 d79be2b1b..d77b88e50 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 }