Skip to content

Commit b040b75

Browse files
committed
cmd/clef: fix incorrect file permissions for secrets.dat
Signed-off-by: YaoZengzeng <yaozengzeng@zju.edu.cn>
1 parent 2d98099 commit b040b75

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎cmd/clef/main.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func initializeSecrets(c *cli.Context) error {
225225
if _, err := os.Stat(location); err == nil {
226226
return fmt.Errorf("file %v already exists, will not overwrite", location)
227227
}
228-
err = ioutil.WriteFile(location, masterSeed, 0700)
228+
err = ioutil.WriteFile(location, masterSeed, 0400)
229229
if err != nil {
230230
return err
231231
}
@@ -540,14 +540,14 @@ func readMasterKey(ctx *cli.Context) ([]byte, error) {
540540

541541
// checkFile is a convenience function to check if a file
542542
// * exists
543-
// * is mode 0600
543+
// * is mode 0400
544544
func checkFile(filename string) error {
545545
info, err := os.Stat(filename)
546546
if err != nil {
547547
return fmt.Errorf("failed stat on %s: %v", filename, err)
548548
}
549549
// Check the unix permission bits
550-
if info.Mode().Perm()&077 != 0 {
550+
if info.Mode().Perm()&0377 != 0 {
551551
return fmt.Errorf("file (%v) has insecure file permissions (%v)", filename, info.Mode().String())
552552
}
553553
return nil

0 commit comments

Comments
 (0)