Skip to content
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
13 changes: 13 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ func saveConfig(cfg *Config) *Config {
conf.Section(defaultCoreConfig.ProfileName).ReflectFrom(&defaultProfile)
conf.SaveTo(cfg.ConfigFile)
}
makeFileUserPrivate(cfg.ConfigFile)

conf := readConfig(cfg)

Expand Down Expand Up @@ -318,6 +319,10 @@ func saveConfig(cfg *Config) *Config {
profiles = append(profiles, profile.Name())
}

if cfg.HistoryFile != "" {
makeFileUserPrivate(cfg.HistoryFile)
}

return cfg
}

Expand Down Expand Up @@ -391,6 +396,14 @@ func (c *Config) UpdateConfig(key string, value string, update bool) {
}
}

func makeFileUserPrivate(filePath string) {
if fi, err := os.Stat(filePath); err == nil && fi.Mode().IsRegular() {
if err := os.Chmod(filePath, 0600); err != nil {
fmt.Printf("Failed to set permissions on %s: %v\n", filePath, err)
}
}
}

// NewConfig creates or reload config and loads API cache
func NewConfig(configFilePath *string) *Config {
defaultConf := defaultConfig()
Expand Down