fix: chmod config 0600 such that only the creating user can read

This commit is contained in:
garethgeorge
2024-01-24 23:50:10 -08:00
parent 4c47086b43
commit b09f155f87
+6 -2
View File
@@ -33,8 +33,7 @@ func (f *JsonFileStore) Get() (*v1.Config, error) {
}
var config v1.Config
if err = protojson.Unmarshal(data, &config); err != nil {
if err = (protojson.UnmarshalOptions{DiscardUnknown: true}).Unmarshal(data, &config); err != nil {
return nil, fmt.Errorf("failed to unmarshal config: %w", err)
}
@@ -72,5 +71,10 @@ func (f *JsonFileStore) Update(config *v1.Config) error {
return fmt.Errorf("failed to write config file: %w", err)
}
// only the user running backrest should be able to read the config.
if err := os.Chmod(f.Path, 0600); err != nil {
return fmt.Errorf("chmod(0600) config file: %w", err)
}
return nil
}