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

Don't check permissions on config file under Windows #282

Merged
merged 1 commit into from
Feb 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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