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.
pull/12549/head
Wilken Rivera 3 years ago
parent d1aa103ebc
commit d3d33714e6

@ -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

Loading…
Cancel
Save