Skip to content

Commit

Permalink
Merge pull request #82 from Mashimiao/runtime-test-maksed-path-valida…
Browse files Browse the repository at this point in the history
…tion

runtimetest: add masked paths validation
  • Loading branch information
Mrunal Patel committed Jun 1, 2016
2 parents af77603 + 615585a commit 17b3b7b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cmd/runtimetest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
Expand Down Expand Up @@ -215,6 +216,23 @@ func validateRootFS(spec *rspec.Spec) error {
return nil
}

func validateMaskedPaths(spec *rspec.Spec) error {
fmt.Println("validating maskedPaths")
for _, maskedPath := range spec.Linux.MaskedPaths {
f, err := os.Open(maskedPath)
if err != nil {
return err
}
defer f.Close()
b := make([]byte, 1)
_, err = f.Read(b)
if err != io.EOF {
return fmt.Errorf("%v should not be readable", maskedPath)
}
}
return nil
}

func main() {
spec, err := loadSpecConfig()
if err != nil {
Expand All @@ -228,6 +246,7 @@ func main() {
validateHostname,
validateRlimits,
validateSysctls,
validateMaskedPaths,
}

for _, v := range validations {
Expand Down

0 comments on commit 17b3b7b

Please sign in to comment.