mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
specgen: permit --privileged and --cap-add
--cap-add is useful when running a privileged container with UID != 0, so that individual capabilities can be added to the container process. Closes: https://github.com/containers/podman/issues/13449 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -83,10 +83,6 @@ func (s *SpecGenerator) Validate() error {
|
||||
//
|
||||
// ContainerSecurityConfig
|
||||
//
|
||||
// capadd and privileged are exclusive
|
||||
if len(s.CapAdd) > 0 && s.Privileged {
|
||||
return exclusiveOptions("CapAdd", "privileged")
|
||||
}
|
||||
// userns and idmappings conflict
|
||||
if s.UserNS.IsPrivate() && s.IDMappings == nil {
|
||||
return errors.Wrap(ErrInvalidSpecConfig, "IDMappings are required when not creating a User namespace")
|
||||
|
@ -535,6 +535,11 @@ var _ = Describe("Podman run", func() {
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session.OutputToString()).To(ContainSubstring("0000000000000000"))
|
||||
|
||||
session = podmanTest.Podman([]string{"run", "--user=1:1", "--cap-add=DAC_OVERRIDE", "--rm", ALPINE, "grep", "CapEff", "/proc/self/status"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session.OutputToString()).To(ContainSubstring("0000000000000002"))
|
||||
|
||||
if os.Geteuid() > 0 {
|
||||
if os.Getenv("SKIP_USERNS") != "" {
|
||||
Skip("Skip userns tests.")
|
||||
|
Reference in New Issue
Block a user