mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-25 15:08:45 +08:00
Config file is not executable, and must not be world accessible
It contains the private key.
This commit is contained in:
@ -35,7 +35,7 @@ func WriteConfigFile(filename string, cfg interface{}) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := atomicfile.New(filename, 0775)
|
f, err := atomicfile.New(filename, 0660)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package fsrepo
|
package fsrepo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
config "github.com/jbenet/go-ipfs/repo/config"
|
config "github.com/jbenet/go-ipfs/repo/config"
|
||||||
@ -23,4 +24,11 @@ func TestConfig(t *testing.T) {
|
|||||||
if cfgWritten.Datastore.Path != cfgRead.Datastore.Path {
|
if cfgWritten.Datastore.Path != cfgRead.Datastore.Path {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
|
st, err := os.Stat(filename)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("cannot stat config file: %v", err)
|
||||||
|
}
|
||||||
|
if g := st.Mode().Perm(); g&0117 != 0 {
|
||||||
|
t.Errorf("config file should not be executable or accessible to world: %v", g)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user