Skip to content

Commit

Permalink
Moved dir safety check logging to per-OS code
Browse files Browse the repository at this point in the history
  • Loading branch information
mxmauro committed Mar 10, 2021
1 parent 51e808d commit 4135b81
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 1 addition & 2 deletions nodecontrol/kmdControl.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ func (kc *KMDController) StartKMD(args KMDStartArgs) (alreadyRunning bool, err e
logging.Base().Errorf("%s: kmd data dir exists but is not a directory", kc.kmdDataDir)
return false, errors.New("bad kmd data dir")
}
if !isDirectorySafe(dataDirStat) {
logging.Base().Errorf("%s: kmd data dir exists but is too permissive (%o), change to (%o)", kc.kmdDataDir, dataDirStat.Mode()&0777, DefaultKMDDataDirPerms)
if !kc.isDirectorySafe(dataDirStat) {
return false, errors.New("kmd data dir not secure")
}
} else {
Expand Down
5 changes: 4 additions & 1 deletion nodecontrol/kmdControl_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ package nodecontrol

import (
"os"

"github.com/algorand/go-algorand/logging"
)

func isDirectorySafe(dirStats os.FileInfo) bool {
func (kc *KMDController) isDirectorySafe(dirStats os.FileInfo) bool {
if (dirStats.Mode() & 0077) != 0 {
logging.Base().Errorf("%s: kmd data dir exists but is too permissive (%o), change to (%o)", kc.kmdDataDir, dataDirStat.Mode()&0777, DefaultKMDDataDirPerms)
return false
}
return true
Expand Down
4 changes: 2 additions & 2 deletions nodecontrol/kmdControl_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ import (
"os"
)

func isDirectorySafe(_ os.FileInfo) bool {
func (kc *KMDController) isDirectorySafe(_ os.FileInfo) bool {
return true
}
}

0 comments on commit 4135b81

Please sign in to comment.