mirror of
https://github.com/moby/moby.git
synced 2025-12-06 07:41:18 +03:00
Add support for NoNewPrivileges in docker
Signed-off-by: Mrunal Patel <mrunalp@gmail.com> Add tests for no-new-privileges Signed-off-by: Mrunal Patel <mrunalp@gmail.com> Update documentation for no-new-privileges Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
@@ -895,6 +895,18 @@ func (s *DockerSuite) TestRunSeccompDefaultProfile(c *check.C) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestRunNoNewPrivSetuid checks that --security-opt=no-new-privileges prevents
|
||||
// effective uid transtions on executing setuid binaries.
|
||||
func (s *DockerSuite) TestRunNoNewPrivSetuid(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux, NotUserNamespace, SameHostDaemon)
|
||||
|
||||
// test that running a setuid binary results in no effective uid transition
|
||||
runCmd := exec.Command(dockerBinary, "run", "--security-opt", "no-new-privileges", "--user", "1000", "nnp-test", "/usr/bin/nnp-test")
|
||||
if out, _, err := runCommandWithOutput(runCmd); err != nil || !strings.Contains(out, "EUID=1000") {
|
||||
c.Fatalf("expected output to contain EUID=1000, got %s: %v", out, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRunApparmorProcDirectory(c *check.C) {
|
||||
testRequires(c, SameHostDaemon, Apparmor)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user