Skip to content

Commit

Permalink
runtimetest: add root filesystem validation
Browse files Browse the repository at this point in the history
Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
  • Loading branch information
Ma Shimiao committed May 26, 2016
1 parent 5130deb commit faf90f0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cmd/runtimetest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,28 @@ func validateSysctls(spec *rspec.Spec) error {
return nil
}

func validateRootFS(spec *rspec.Spec) error {
fmt.Println("validating root")
if spec.Root.Readonly {
fi, err := os.Stat("/")
if err != nil {
return err
}
if fi.Mode()&0222 != 0 {
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 faf90f0

Please sign in to comment.