Skip to content

Commit

Permalink
Fix config file permissions to not be world-readable (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
ob-stripe authored Oct 9, 2019
1 parent 7e709df commit 1740886
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ func (c *Config) InitConfig() {
c.ProfilesFile = configFile
viper.SetConfigType("toml")
viper.SetConfigFile(configFile)
viper.SetConfigPermissions(os.FileMode(0600))

// Try to change permissions manually, because we used to create files
// with default permissions (0644)
err := os.Chmod(configFile, os.FileMode(0600))
if err != nil && !os.IsNotExist(err) {
log.Fatalf("%s", err)
}
}

// If a profiles file is found, read it in.
Expand Down

0 comments on commit 1740886

Please sign in to comment.