mirror of
https://github.com/garethgeorge/backrest.git
synced 2026-08-28 20:06:32 +00:00
fix: chmod config 0600 such that only the creating user can read
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user