Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SELinux package to apply context #907

Merged
merged 1 commit into from
Aug 28, 2024

Conversation

empovit
Copy link
Contributor

@empovit empovit commented Aug 17, 2024

Use github.com/opencontainers/selinux/go-selinux instead of calling the chcon command to set SELinux context.

This PR builds upon #789, but according to opencontainers/selinux/issues/215, a full label must be applied when using the SELinux Go package. Also, checking whether SELinux is available has been changed - the reason was discussed in detail in #847.

@empovit
Copy link
Contributor Author

empovit commented Aug 17, 2024

/cc @cdesiniotis @elezar

@@ -98,7 +99,7 @@ func (d *Daemon) Start() error {
return fmt.Errorf("error creating directory %v: %w", pipeDir, err)
}

if err := setSELinuxContext(pipeDir, "container_file_t"); err != nil {
if err := setSELinuxContext(pipeDir, "system_u:object_r:container_file_t:s0"); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any chance that this is available as a constant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid it is not :/ Not in the selinux package or any of the imported packages. But I can make it a constant if that's what you mean.

Copy link
Member

@elezar elezar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @empovit.

Using the package where possible definitely makes sense. Thanks for getting to the bottom of this.

Use `github.com/opencontainers/selinux/go-selinux` instead of
calling the `chcon` command to set SELinux context.

Signed-off-by: Vitaliy Emporopulo <vemporop@redhat.com>
@elezar elezar merged commit f21de56 into NVIDIA:main Aug 28, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants