Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix executable checks for windows #11692

Merged
merged 1 commit into from Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,4 @@
changes:
- type: fix
scope: cli/plugin
description: Fix check of executable bits on Windows.
5 changes: 5 additions & 0 deletions pkg/cmd/pulumi/package.go
Expand Up @@ -20,6 +20,7 @@ import (
"io/fs"
"os"
"path/filepath"
"runtime"
"strings"

"github.com/blang/semver"
Expand Down Expand Up @@ -109,6 +110,10 @@ func schemaFromSchemaSource(packageSource string) (*schema.Package, error) {
}

isExecutable := func(info fs.FileInfo) bool {
// Windows doesn't have executable bits to check
if runtime.GOOS == "windows" {
return !info.IsDir()
}
return info.Mode()&0111 != 0 && !info.IsDir()
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/pulumi/plugin_install.go
Expand Up @@ -233,7 +233,8 @@ func getFilePayload(file string, spec workspace.PluginSpec) (workspace.PluginCon
return nil, fmt.Errorf("seeking back in file %s: %w", source, err)
}
if !encoding.IsCompressed(compressHeader) {
if (stat.Mode() & 0100) == 0 {
// Windows doesn't have executable bits to check
if runtime.GOOS != "windows" && (stat.Mode()&0100) == 0 {
return nil, fmt.Errorf("%s is not executable", source)
}
return workspace.SingleFilePlugin(f, spec), nil
Expand Down