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

Commit 5c29e7b

Browse files
committed
Windows: skip permissions check on key
This code was attempting to check Linux file permissions to determine if the key was accessible by other users, which doesn't work, and therefore prevented users on Windows to load keys. Skipping this check on Windows (correspinding tests were already skipped). Signed-off-by: Sebastiaan van Stijn <github@gone.nl> (cherry picked from commit 15d361fd77d69514aa544fbcb5cb7ce15c3184f4) Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: e803e487c3f231aa0b35ede630fc388778524969 Component: cli
1 parent 918925d commit 5c29e7b

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)