Skip to content

Commit

Permalink
Create config with user only permission (#269)
Browse files Browse the repository at this point in the history
Create config with user only permission

Signed-off-by: Pritesh Bandi <pritesb@amazon.com>
  • Loading branch information
priteshbandi authored Feb 8, 2023
1 parent 6ef3544 commit 1b2ec27
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion config/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ func save(filePath string, cfg interface{}) error {
if err := os.MkdirAll(dir, 0700); err != nil {
return err
}
file, err := os.Create(filePath)

file, err := os.OpenFile(filePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
return err
}
defer file.Close()

encoder := json.NewEncoder(file)
encoder.SetIndent("", " ")
return encoder.Encode(cfg)
Expand Down
2 changes: 1 addition & 1 deletion config/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (s *SigningKeys) Remove(keyName ...string) ([]string, error) {
}
s.Keys = slices.Delete(s.Keys, idx)
deletedNames = append(deletedNames, name)
if *s.Default == name {
if s.Default !=nil && *s.Default == name {
s.Default = nil
}
}
Expand Down

0 comments on commit 1b2ec27

Please sign in to comment.