1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-29 01:12:24 +08:00

Merge pull request #910 from tv42/config-mode

Config file is not executable, and must not be world accessible
This commit is contained in:
Juan Batiz-Benet
2015-03-10 07:46:50 -07:00
2 changed files with 9 additions and 1 deletions

View File

@ -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
} }

View File

@ -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)
}
} }