Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit 1c89ff0

Browse files
authored
Merge pull request #1970 from thaJeztah/19.03_backport_skip_windows_permissions_check
[19.03 backport] Windows: skip permissions check on key Upstream-commit: 0ea69840c6f4e0ce37afc5ab121ee8d9d7b39e96 Component: cli
2 parents 9306a35 + 5c29e7b commit 1c89ff0

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

components/cli/cli/command/trust/key_load.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"io/ioutil"
88
"os"
9+
"runtime"
910

1011
"github.com/docker/cli/cli"
1112
"github.com/docker/cli/cli/command"
@@ -69,12 +70,14 @@ func loadPrivKey(streams command.Streams, keyPath string, options keyLoadOptions
6970
}
7071

7172
func getPrivKeyBytesFromPath(keyPath string) ([]byte, error) {
72-
fileInfo, err := os.Stat(keyPath)
73-
if err != nil {
74-
return nil, err
75-
}
76-
if fileInfo.Mode()&nonOwnerReadWriteMask != 0 {
77-
return nil, fmt.Errorf("private key file %s must not be readable or writable by others", keyPath)
73+
if runtime.GOOS != "windows" {
74+
fileInfo, err := os.Stat(keyPath)
75+
if err != nil {
76+
return nil, err
77+
}
78+
if fileInfo.Mode()&nonOwnerReadWriteMask != 0 {
79+
return nil, fmt.Errorf("private key file %s must not be readable or writable by others", keyPath)
80+
}
7881
}
7982

8083
from, err := os.OpenFile(keyPath, os.O_RDONLY, notary.PrivExecPerms)

0 commit comments

Comments
 (0)