Skip to content

Commit

Permalink
Merge pull request #10253 from rhatdan/relabel
Browse files Browse the repository at this point in the history
Revert Patch to relabel if selinux not enabled
  • Loading branch information
openshift-merge-robot authored May 7, 2021
2 parents 034470e + f528511 commit 663ea96
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
10 changes: 2 additions & 8 deletions libpod/container_internal_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,14 +377,8 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) {
case "z":
fallthrough
case "Z":
if c.MountLabel() != "" {
if c.ProcessLabel() != "" {
if err := label.Relabel(m.Source, c.MountLabel(), label.IsShared(o)); err != nil {
return nil, err
}
} else {
logrus.Infof("Not relabeling volume %q in container %s as SELinux is disabled", m.Source, c.ID())
}
if err := label.Relabel(m.Source, c.MountLabel(), label.IsShared(o)); err != nil {
return nil, err
}

default:
Expand Down
13 changes: 8 additions & 5 deletions test/system/410-selinux.bats
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,23 @@ function check_label() {
skip_if_no_selinux

LABEL="system_u:object_r:tmp_t:s0"
RELABEL="system_u:object_r:container_file_t:s0"
tmpdir=$PODMAN_TMPDIR/vol
touch $tmpdir
chcon -vR ${LABEL} $tmpdir
ls -Z $tmpdir

run_podman run -v $tmpdir:/test $IMAGE cat /proc/self/attr/current
level=$(secon -l $output)
run ls -dZ ${tmpdir}
is "$output" ${LABEL} "No Relabel Correctly"

run_podman run -v $tmpdir:/test:Z --security-opt label=disable $IMAGE cat /proc/self/attr/current
level=$(secon -l $output)
run_podman run -v $tmpdir:/test:z --security-opt label=disable $IMAGE cat /proc/self/attr/current
run ls -dZ $tmpdir
is "$output" ${RELABEL} "Privileged Relabel Correctly"

run_podman run -v $tmpdir:/test:z --privileged $IMAGE cat /proc/self/attr/current
run ls -dZ $tmpdir
is "$output" ${LABEL} "No Privileged Relabel Correctly"
is "$output" ${RELABEL} "Privileged Relabel Correctly"

run_podman run -v $tmpdir:/test:Z $IMAGE cat /proc/self/attr/current
level=$(secon -l $output)
Expand All @@ -220,7 +223,7 @@ function check_label() {

run_podman run -v $tmpdir:/test:z $IMAGE cat /proc/self/attr/current
run ls -dZ $tmpdir
is "$output" "system_u:object_r:container_file_t:s0" "Shared Relabel Correctly"
is "$output" ${RELABEL} "Shared Relabel Correctly"
}

# vim: filetype=sh

0 comments on commit 663ea96

Please sign in to comment.