Browse code

Expand unshare test to include privileged test

This ensures that AppArmor, not other mechanisms used
by Docker or the kernel is restricting the mount.

Signed-off-by: Eric Windisch <eric@windisch.us>

Eric Windisch authored on 2015/05/29 03:55:22
Showing 1 changed files
... ...
@@ -3179,6 +3179,13 @@ func (s *DockerSuite) TestRunUnshareProc(c *check.C) {
3179 3179
 	if out, _, err := runCommandWithOutput(runCmd); err == nil || !strings.Contains(out, "Permission denied") {
3180 3180
 		c.Fatalf("unshare should have failed with permission denied, got: %s, %v", out, err)
3181 3181
 	}
3182
+
3183
+	/* Ensure still fails if running privileged with the default policy */
3184
+	name = "crashoverride"
3185
+	runCmd = exec.Command(dockerBinary, "run", "--privileged", "--security-opt", "apparmor:docker-default", "--name", name, "jess/unshare", "unshare", "-p", "-m", "-f", "-r", "mount", "-t", "proc", "none", "/proc")
3186
+	if out, _, err := runCommandWithOutput(runCmd); err == nil || !strings.Contains(out, "Permission denied") {
3187
+		c.Fatalf("unshare should have failed with permission denied, got: %s, %v", out, err)
3188
+	}
3182 3189
 }
3183 3190
 
3184 3191
 func (s *DockerSuite) TestRunPublishPort(c *check.C) {