Skip to content

Commit

Permalink
Merge pull request #78 from Mashimiao/runtime-test-root-fs-validation
Browse files Browse the repository at this point in the history
runtimetest: add root filesystem validation
  • Loading branch information
Mrunal Patel committed May 31, 2016
2 parents 366a66e + d9b2746 commit 923e88c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions cmd/runtimetest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,38 @@ func validateSysctls(spec *rspec.Spec) error {
return nil
}

func testWriteAccess(path string) error {
tmpfile, err := ioutil.TempFile(path, "Test")
if err != nil {
return err
}

tmpfile.Close()
os.RemoveAll(filepath.Join(path, tmpfile.Name()))

return nil
}

func validateRootFS(spec *rspec.Spec) error {
fmt.Println("validating root")
if spec.Root.Readonly {
err := testWriteAccess("/")
if err == nil {
return fmt.Errorf("Rootfs should be readonly")
}
}

return nil
}

func main() {
spec, err := loadSpecConfig()
if err != nil {
logrus.Fatalf("Failed to load configuration: %q", err)
}

validations := []validation{
validateRootFS,
validateProcess,
validateCapabilities,
validateHostname,
Expand Down

0 comments on commit 923e88c

Please sign in to comment.