mirror of https://github.com/docker/cli.git
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>
This commit is contained in:
parent
b45b4b28f9
commit
15d361fd77
|
@ -6,6 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
|
|
||||||
"github.com/docker/cli/cli"
|
"github.com/docker/cli/cli"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
|
@ -69,6 +70,7 @@ func loadPrivKey(streams command.Streams, keyPath string, options keyLoadOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
func getPrivKeyBytesFromPath(keyPath string) ([]byte, error) {
|
func getPrivKeyBytesFromPath(keyPath string) ([]byte, error) {
|
||||||
|
if runtime.GOOS != "windows" {
|
||||||
fileInfo, err := os.Stat(keyPath)
|
fileInfo, err := os.Stat(keyPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -76,6 +78,7 @@ func getPrivKeyBytesFromPath(keyPath string) ([]byte, error) {
|
||||||
if fileInfo.Mode()&nonOwnerReadWriteMask != 0 {
|
if fileInfo.Mode()&nonOwnerReadWriteMask != 0 {
|
||||||
return nil, fmt.Errorf("private key file %s must not be readable or writable by others", keyPath)
|
return nil, fmt.Errorf("private key file %s must not be readable or writable by others", keyPath)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
from, err := os.OpenFile(keyPath, os.O_RDONLY, notary.PrivExecPerms)
|
from, err := os.OpenFile(keyPath, os.O_RDONLY, notary.PrivExecPerms)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue