Skip to content

Commit

Permalink
Make app.ini more restrictive on new installations (#16266)
Browse files Browse the repository at this point in the history
Signed-off-by: Steven Kriegler <[email protected]>
  • Loading branch information
justusbunsi authored Jun 27, 2021
1 parent 35f37a3 commit f533b5d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions modules/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,19 @@ func CreateOrAppendToCustomConf(callback func(cfg *ini.File)) {
if err := cfg.SaveTo(CustomConf); err != nil {
log.Fatal("error saving to custom config: %v", err)
}

// Change permissions to be more restrictive
fi, err := os.Stat(CustomConf)
if err != nil {
log.Error("Failed to determine current conf file permissions: %v", err)
return
}

if fi.Mode().Perm() > 0o600 {
if err = os.Chmod(CustomConf, 0o600); err != nil {
log.Warn("Failed changing conf file permissions to -rw-------. Consider changing them manually.")
}
}
}

// NewServices initializes the services
Expand Down

0 comments on commit f533b5d

Please sign in to comment.