mirror of
https://github.com/docker/compose.git
synced 2026-10-12 02:13:08 +00:00
fix(plugins): honor PATHEXT for provider lookup on Windows
The PATH fallback of provider discovery appended a hardcoded ".exe" on Windows, restricting providers to compiled binaries. exec.LookPath already implements Windows executable resolution (PATHEXT), which finds .exe but also .com/.bat/.cmd scripts — the suffix only narrowed the lookup. Drop the executable() indirection and look up the bare name. Note this only affects the PATH fallback: the docker CLI plugin channel (docker-<name>) keeps requiring .exe on Windows, per docker/cli plugin candidate rules. Fixes #14157 Signed-off-by: Nicolas De Loof <[email protected]>
This commit is contained in:
committed by
Guillaume Lours
parent
b3284911a3
commit
2be4e2d656
@@ -198,7 +198,11 @@ func (s *composeService) getPluginBinaryPath(provider string) (path string, err
|
||||
path = plugin.Path
|
||||
}
|
||||
if errdefs.IsNotFound(err) {
|
||||
path, err = exec.LookPath(executable(provider))
|
||||
// A plain LookPath honors Windows executable-resolution semantics
|
||||
// (PATHEXT: .exe, but also .com/.bat/.cmd), so provider executables
|
||||
// need not be compiled binaries. Callers must not append a hardcoded
|
||||
// ".exe": it restricts the lookup instead of helping it.
|
||||
path, err = exec.LookPath(provider)
|
||||
}
|
||||
return path, err
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
//go:build windows
|
||||
|
||||
/*
|
||||
Copyright 2020 Docker Compose CLI authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package compose
|
||||
|
||||
func executable(s string) string {
|
||||
return s + ".exe"
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
//go:build !windows
|
||||
|
||||
/*
|
||||
Copyright 2020 Docker Compose CLI authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package compose
|
||||
|
||||
func executable(s string) string {
|
||||
return s
|
||||
}
|
||||
Reference in New Issue
Block a user