Skip to content

Commit 134a5d5

Browse files
committed
config: fix access for config and history file
Fixes #157 Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent a6552ee commit 134a5d5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

config/config.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ func saveConfig(cfg *Config) *Config {
263263
conf.Section(defaultCoreConfig.ProfileName).ReflectFrom(&defaultProfile)
264264
conf.SaveTo(cfg.ConfigFile)
265265
}
266+
makeFileGroupPrivate(cfg.ConfigFile)
266267

267268
conf := readConfig(cfg)
268269

@@ -318,6 +319,10 @@ func saveConfig(cfg *Config) *Config {
318319
profiles = append(profiles, profile.Name())
319320
}
320321

322+
if cfg.HistoryFile != "" {
323+
makeFileGroupPrivate(cfg.HistoryFile)
324+
}
325+
321326
return cfg
322327
}
323328

@@ -391,6 +396,12 @@ func (c *Config) UpdateConfig(key string, value string, update bool) {
391396
}
392397
}
393398

399+
func makeFileGroupPrivate(filePath string) {
400+
if fi, err := os.Stat(filePath); err == nil && fi.Mode().IsRegular() {
401+
_ = os.Chmod(filePath, 0660)
402+
}
403+
}
404+
394405
// NewConfig creates or reload config and loads API cache
395406
func NewConfig(configFilePath *string) *Config {
396407
defaultConf := defaultConfig()

0 commit comments

Comments
 (0)