@cryptotaxi247 / kubo / commits / 5baf3c7fc

Config file is not executable, and must not be world accessible

It contains the private key.

Tommi Virtanen committed Mar 5, 2015 at 14:45 UTC 5baf3c7fc1df6ea343c4ca92e5ea2cc28d00d4ca
2 files changed +9 -1
repo/fsrepo/serialize/serialize.go
+1 -1
@@ -35,7 +35,7 @@ func WriteConfigFile(filename string, cfg interface{}) error {
35 return err
36 }
37
38 - f, err := atomicfile.New(filename, 0775)
38 + f, err := atomicfile.New(filename, 0660)
39 if err != nil {
40 return err
41 }
repo/fsrepo/serialize/serialize_test.go
+8
@@ -1,6 +1,7 @@
1 package fsrepo
2
3 import (
4 + "os"
5 "testing"
6
7 config "github.com/jbenet/go-ipfs/repo/config"
@@ -23,4 +24,11 @@ func TestConfig(t *testing.T) {
24 if cfgWritten.Datastore.Path != cfgRead.Datastore.Path {
25 t.Fail()
26 }
27 + st, err := os.Stat(filename)
28 + if err != nil {
29 + t.Fatalf("cannot stat config file: %v", err)
30 + }
31 + if g := st.Mode().Perm(); g&0117 != 0 {
32 + t.Errorf("config file should not be executable or accessible to world: %v", g)
33 + }
34 }