From 7d8017d63178f3e773b5307fc06cd2de47dcacca Mon Sep 17 00:00:00 2001 From: mzz2017 Date: Sun, 7 Jun 2020 01:19:06 +0800 Subject: [PATCH] optimize(db): set database directory permission to 0750 to protect privacy --- service/db/nutsdb.go | 3 ++- service/pre.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/service/db/nutsdb.go b/service/db/nutsdb.go index 092c324f..5b588679 100644 --- a/service/db/nutsdb.go +++ b/service/db/nutsdb.go @@ -17,8 +17,9 @@ func initDB() { opt := nutsdb.DefaultOptions opt.Dir = confPath db, err = nutsdb.Open(opt) + // for privacy + defer os.Chmod(confPath, os.ModeDir|0750) if err != nil { - _ = os.Chmod(confPath, os.ModeDir|0755) log.Fatal(err) } } diff --git a/service/pre.go b/service/pre.go index a4f6a261..df42b127 100644 --- a/service/pre.go +++ b/service/pre.go @@ -135,7 +135,7 @@ func initConfigure() { //db confPath := global.GetEnvironmentConfig().Config if _, err := os.Stat(confPath); os.IsNotExist(err) { - _ = os.MkdirAll(path.Dir(confPath), os.ModeDir|0755) + _ = os.MkdirAll(path.Dir(confPath), os.ModeDir|0750) } if configure.IsConfigureNotExists() { // need to migrate?