Skip to content

Commit

Permalink
Merge pull request #282 from ElNounch/origin/windows-permissions
Browse files Browse the repository at this point in the history
Don't check permissions on config file under Windows
  • Loading branch information
moul committed Feb 21, 2016
2 parents d2efb2b + 258c62c commit 55f0595
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
)

// Config is a Scaleway CLI configuration file
Expand Down Expand Up @@ -55,12 +56,16 @@ func GetConfig() (*Config, error) {
return nil, err
}

stat, err := os.Stat(scwrcPath)
// we don't care if it fails, the user just won't see the warning
if err == nil {
mode := stat.Mode()
if mode&0066 != 0 {
return nil, fmt.Errorf("permissions %#o for .scwrc are too open", mode)
// Don't check permissions on Windows, Go knows nothing about them on this platform
// User profile is to be assumed safe anyway
if runtime.GOOS != "windows" {
stat, err := os.Stat(scwrcPath)
// we don't care if it fails, the user just won't see the warning
if err == nil {
perm := stat.Mode().Perm()
if perm&0066 != 0 {
return nil, fmt.Errorf("permissions %#o for .scwrc are too open", perm)
}
}
}

Expand Down

0 comments on commit 55f0595

Please sign in to comment.