From d3d33714e6834de18a8a71c44874171ec4093503 Mon Sep 17 00:00:00 2001 From: Wilken Rivera Date: Thu, 27 Jul 2023 15:58:29 -0400 Subject: [PATCH] Update plugin loading for current directory Starting with Go 1.19 the loading of binaries from the current working directory was deemed as a possible security problem. Thus the use of exec.Command or exec.LookPath no longer resolves an executable within the current working directory. This change updates the discover logic to return absolute paths for any discovered plugin, which is called directly when passed to exec.Command or exec.LookPath. By doing this Packer is able to load a custom plugin sitting in the current working directory as it did in version prior to v1.9.2. --- packer/plugin.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packer/plugin.go b/packer/plugin.go index a4321d90f..1a6a0ab84 100644 --- a/packer/plugin.go +++ b/packer/plugin.go @@ -239,7 +239,11 @@ func (c *PluginConfig) discoverSingle(glob string) (map[string]string, error) { pluginName = strings.SplitN(pluginName, "_", 2)[0] log.Printf("[INFO] Discovered potential plugin: %s = %s", pluginName, match) - res[pluginName] = match + pluginPath, err := filepath.Abs(match) + if err != nil { + pluginPath = match + } + res[pluginName] = pluginPath } return res, nil