Skip to content

Inside a container selinux.Chcon fails although chcon command succeeds in applying a SELinux context #215

@empovit

Description

@empovit

When executed inside a container, the following code

selinux.Chcon("/mps/nvidia.com/gpu/pipe", "container_file_t", true)

fails for me with

lsetxattr /mps/nvidia.com/gpu/pipe: invalid argument

However, this code runs without errors and successfully updates the SELinux type:

import "os/exec"

output, err := chconCmd.CombinedOutput()
if err != nil {
	klog.Errorf("\n%v", string(output))
	return err
}
chconCmd := exec.Command("chcon", "-R", "-t", "container_file_t", "/mps/nvidia.com/gpu/pipe")

The container is running privileged on OpenShift (RHCOS).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions