mirror of
https://github.com/containers/podman.git
synced 2025-10-17 11:14:40 +08:00
Save --privileged state
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Closes: #255 Approved by: mheon
This commit is contained in:

committed by
Atomic Bot

parent
12e3d9d8a2
commit
50d4cd2868
@ -188,7 +188,7 @@ func getCtrInspectInfo(ctr *libpod.Container, ctrInspectData *libpod.ContainerIn
|
||||
MemorySwappiness: memSwappiness,
|
||||
OomKillDisable: memDisableOOMKiller,
|
||||
PidsLimit: pidsLimit,
|
||||
Privileged: spec.Process.NoNewPrivileges,
|
||||
Privileged: config.Privileged,
|
||||
ReadonlyRootfs: spec.Root.Readonly,
|
||||
Runtime: ctr.RuntimeName(),
|
||||
NetworkMode: string(createArtifact.NetMode),
|
||||
|
@ -608,6 +608,7 @@ func (c *createConfig) GetContainerCreateOptions() ([]libpod.CtrCreateOption, er
|
||||
options = append(options, libpod.WithHosts(c.HostAdd))
|
||||
}
|
||||
|
||||
options = append(options, libpod.WithPrivileged(c.Privileged))
|
||||
return options, nil
|
||||
}
|
||||
|
||||
|
@ -268,6 +268,18 @@ func WithShmSize(size int64) CtrCreateOption {
|
||||
}
|
||||
}
|
||||
|
||||
// WithPrivileged sets the privileged flag in the container runtime
|
||||
func WithPrivileged(privileged bool) CtrCreateOption {
|
||||
return func(ctr *Container) error {
|
||||
if ctr.valid {
|
||||
return ErrCtrFinalized
|
||||
}
|
||||
|
||||
ctr.config.Privileged = privileged
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// WithSELinuxLabels sets the mount label for SELinux
|
||||
func WithSELinuxLabels(processLabel, mountLabel string) CtrCreateOption {
|
||||
return func(ctr *Container) error {
|
||||
|
34
test/podman_run_security.bats
Normal file
34
test/podman_run_security.bats
Normal file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load helpers
|
||||
|
||||
function teardown() {
|
||||
cleanup_test
|
||||
}
|
||||
|
||||
function setup() {
|
||||
copy_images
|
||||
}
|
||||
|
||||
@test "run privileged test" {
|
||||
cap=$(grep CapEff /proc/self/status | cut -f2 -d":")
|
||||
|
||||
run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run --privileged ${ALPINE} grep CapEff /proc/self/status
|
||||
echo $output
|
||||
[ "$status" -eq 0 ]
|
||||
containercap=$(echo $output | tr -d '\r'| cut -f2 -d":")
|
||||
[ $containercap = $cap ]
|
||||
|
||||
run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run --cap-add all ${ALPINE} grep CapEff /proc/self/status
|
||||
echo $output
|
||||
[ "$status" -eq 0 ]
|
||||
containercap=$(echo $output | tr -d '\r'| cut -f2 -d":")
|
||||
[ $containercap = $cap ]
|
||||
|
||||
cap=$(grep CapAmb /proc/self/status | cut -f2 -d":")
|
||||
run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run --cap-drop all ${ALPINE} grep CapEff /proc/self/status
|
||||
echo $output
|
||||
[ "$status" -eq 0 ]
|
||||
containercap=$(echo $output | tr -d '\r'| cut -f2 -d":")
|
||||
[ $containercap = $cap ]
|
||||
}
|
Reference in New Issue
Block a user