Skip to content

Commit

Permalink
add seccomp default profile fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Antonio Murdaca <[email protected]>
Signed-off-by: Jessica Frazelle <[email protected]>
  • Loading branch information
runcom authored and jessfraz committed Feb 19, 2016
1 parent ad60023 commit 11435b6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions integration-cli/docker_cli_run_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -909,3 +909,13 @@ func (s *DockerSuite) TestRunApparmorProcDirectory(c *check.C) {
c.Fatalf("expected chmod 777 /proc/1/attr/current to fail, got %s: %v", out, err)
}
}

// make sure the default profile can be successfully parsed (using unshare as it is
// something which we know is blocked in the default profile)
func (s *DockerSuite) TestRunSeccompWithDefaultProfile(c *check.C) {
testRequires(c, SameHostDaemon, seccompEnabled)

out, _, err := dockerCmdWithError("run", "--security-opt", "seccomp:../profiles/seccomp/default.json", "debian:jessie", "unshare", "--map-root-user", "--user", "sh", "-c", "whoami")
c.Assert(err, checker.NotNil, check.Commentf(out))
c.Assert(strings.TrimSpace(out), checker.Equals, "unshare: unshare failed: Operation not permitted")
}
9 changes: 9 additions & 0 deletions profiles/seccomp/seccomp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@ func TestLoadProfile(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if _, err := LoadProfile(string(f)); err != nil {
t.Fatal(err)
}
}

func TestLoadDefaultProfile(t *testing.T) {
f, err := ioutil.ReadFile("default.json")
if err != nil {
t.Fatal(err)
}
if _, err := LoadProfile(string(f)); err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 11435b6

Please sign in to comment.