Skip to content

Commit

Permalink
Merge pull request #789 from elezar/add-selinux-context
Browse files Browse the repository at this point in the history
Modify SELinux context of MPS pipe directory
  • Loading branch information
elezar committed Jul 10, 2024
2 parents d80f0e8 + 081a3ce commit 6c5fa87
Show file tree
Hide file tree
Showing 11 changed files with 2,231 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/mps-control-daemon/mps/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"os/exec"
"path/filepath"

"github.com/opencontainers/selinux/go-selinux"
"k8s.io/klog/v2"

"github.com/NVIDIA/k8s-device-plugin/internal/rm"
Expand Down Expand Up @@ -97,6 +98,12 @@ func (d *Daemon) Start() error {
return fmt.Errorf("error creating directory %v: %w", pipeDir, err)
}

if selinux.EnforceMode() == selinux.Enforcing {
if err := selinux.Chcon(pipeDir, "container_file_t", true); err != nil {
return fmt.Errorf("error setting SELinux context: %w", err)
}
}

logDir := d.LogDir()
if err := os.MkdirAll(logDir, 0755); err != nil {
return fmt.Errorf("error creating directory %v: %w", logDir, err)
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/mittwald/go-helm-client v0.12.9
github.com/onsi/ginkgo/v2 v2.19.0
github.com/onsi/gomega v1.33.1
github.com/opencontainers/selinux v1.11.0
github.com/prometheus/procfs v0.15.1
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.9.0
Expand Down
201 changes: 201 additions & 0 deletions vendor/github.com/opencontainers/selinux/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions vendor/github.com/opencontainers/selinux/go-selinux/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6c5fa87

Please sign in to comment.