Fix Windows credential provider cannot find binary

Windows credential provider binary path may have ".exe" suffix so
it is better to use LookPath() to support it flexibly.

Signed-off-by: Zhecheng Li <zhechengli@microsoft.com>
This commit is contained in:
Zhecheng Li 2023-08-31 04:12:50 +00:00
parent 6e0cb243d5
commit 61023579c1

View File

@ -98,8 +98,10 @@ func RegisterCredentialProviderPlugins(pluginConfigFile, pluginBinDir string) er
registerMetrics()
for _, provider := range credentialProviderConfig.Providers {
pluginBin := filepath.Join(pluginBinDir, provider.Name)
if _, err := os.Stat(pluginBin); err != nil {
// Considering Windows binary with suffix ".exe", LookPath() helps to find the correct path.
// LookPath() also calls os.Stat().
pluginBin, err := exec.LookPath(filepath.Join(pluginBinDir, provider.Name))
if err != nil {
if os.IsNotExist(err) {
return fmt.Errorf("plugin binary executable %s did not exist", pluginBin)
}