Skip to content

Commit

Permalink
Merge pull request kubernetes#108070 from jsafrane/remove-selinux
Browse files Browse the repository at this point in the history
Remove util/selinux package
  • Loading branch information
k8s-ci-robot authored Feb 12, 2022
2 parents 1f041cc + 77aa06d commit 1659924
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 164 deletions.
4 changes: 2 additions & 2 deletions pkg/kubelet/cm/devicemanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"time"

cadvisorapi "github.com/google/cadvisor/info/v1"
"github.com/opencontainers/selinux/go-selinux"
"google.golang.org/grpc"
"k8s.io/klog/v2"

Expand All @@ -48,7 +49,6 @@ import (
"k8s.io/kubernetes/pkg/kubelet/metrics"
"k8s.io/kubernetes/pkg/kubelet/pluginmanager/cache"
schedulerframework "k8s.io/kubernetes/pkg/scheduler/framework"
"k8s.io/kubernetes/pkg/util/selinux"
)

const nodeWithoutTopology = -1
Expand Down Expand Up @@ -259,7 +259,7 @@ func (m *ManagerImpl) Start(activePods ActivePodsFunc, sourcesReady config.Sourc
if err = os.MkdirAll(m.socketdir, 0750); err != nil {
return err
}
if selinux.SELinuxEnabled() {
if selinux.GetEnabled() {
if err := selinux.SetFileLabel(m.socketdir, config.KubeletPluginsDirSELinuxLabel); err != nil {
klog.InfoS("Unprivileged containerized plugins might not work. Could not set selinux context on socket dir", "path", m.socketdir, "err", err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubelet/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"sync/atomic"
"time"

"github.com/opencontainers/selinux/go-selinux"
"k8s.io/client-go/informers"

cadvisorapi "github.com/google/cadvisor/info/v1"
Expand Down Expand Up @@ -109,7 +110,6 @@ import (
"k8s.io/kubernetes/pkg/security/apparmor"
sysctlallowlist "k8s.io/kubernetes/pkg/security/podsecuritypolicy/sysctl"
"k8s.io/kubernetes/pkg/util/oom"
"k8s.io/kubernetes/pkg/util/selinux"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/csi"
"k8s.io/kubernetes/pkg/volume/util/hostutil"
Expand Down Expand Up @@ -1251,7 +1251,7 @@ func (kl *Kubelet) setupDataDirs() error {
if err := os.MkdirAll(kl.getPodResourcesDir(), 0750); err != nil {
return fmt.Errorf("error creating podresources directory: %v", err)
}
if selinux.SELinuxEnabled() {
if selinux.GetEnabled() {
err := selinux.SetFileLabel(pluginRegistrationDir, config.KubeletPluginsDirSELinuxLabel)
if err != nil {
klog.InfoS("Unprivileged containerized plugins might not work, could not set selinux context on plugin registration dir", "path", pluginRegistrationDir, "err", err)
Expand Down
6 changes: 3 additions & 3 deletions pkg/kubelet/kuberuntime/kuberuntime_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"sync"
"time"

"github.com/opencontainers/selinux/go-selinux"
grpcstatus "google.golang.org/grpc/status"

"github.com/armon/circbuf"
Expand All @@ -51,7 +52,6 @@ import (
"k8s.io/kubernetes/pkg/kubelet/events"
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/kubelet/util/format"
"k8s.io/kubernetes/pkg/util/selinux"
"k8s.io/kubernetes/pkg/util/tail"
volumeutil "k8s.io/kubernetes/pkg/volume/util"
)
Expand Down Expand Up @@ -378,7 +378,7 @@ func (m *kubeGenericRuntimeManager) makeMounts(opts *kubecontainer.RunContainerO

for idx := range opts.Mounts {
v := opts.Mounts[idx]
selinuxRelabel := v.SELinuxRelabel && selinux.SELinuxEnabled()
selinuxRelabel := v.SELinuxRelabel && selinux.GetEnabled()
mount := &runtimeapi.Mount{
HostPath: v.HostPath,
ContainerPath: v.ContainerPath,
Expand Down Expand Up @@ -416,7 +416,7 @@ func (m *kubeGenericRuntimeManager) makeMounts(opts *kubecontainer.RunContainerO
// Volume Mounts fail on Windows if it is not of the form C:/
containerLogPath = volumeutil.MakeAbsolutePath(goruntime.GOOS, containerLogPath)
terminationMessagePath := volumeutil.MakeAbsolutePath(goruntime.GOOS, container.TerminationMessagePath)
selinuxRelabel := selinux.SELinuxEnabled()
selinuxRelabel := selinux.GetEnabled()
volumeMounts = append(volumeMounts, &runtimeapi.Mount{
HostPath: containerLogPath,
ContainerPath: terminationMessagePath,
Expand Down
19 changes: 0 additions & 19 deletions pkg/util/selinux/doc.go

This file was deleted.

39 changes: 0 additions & 39 deletions pkg/util/selinux/selinux.go

This file was deleted.

58 changes: 0 additions & 58 deletions pkg/util/selinux/selinux_linux.go

This file was deleted.

39 changes: 0 additions & 39 deletions pkg/util/selinux/selinux_unsupported.go

This file was deleted.

4 changes: 2 additions & 2 deletions pkg/volume/util/hostutil/hostutil_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import (
"strings"
"syscall"

"github.com/opencontainers/selinux/go-selinux"
"golang.org/x/sys/unix"
"k8s.io/klog/v2"
"k8s.io/kubernetes/pkg/util/selinux"
"k8s.io/mount-utils"
utilpath "k8s.io/utils/path"
)
Expand Down Expand Up @@ -263,7 +263,7 @@ func GetSELinux(path string, mountInfoFilename string, selinuxEnabled seLinuxEna
// GetSELinuxSupport returns true if given path is on a mount that supports
// SELinux.
func (hu *HostUtil) GetSELinuxSupport(pathname string) (bool, error) {
return GetSELinux(pathname, procMountInfoPath, selinux.SELinuxEnabled)
return GetSELinux(pathname, procMountInfoPath, selinux.GetEnabled)
}

// GetOwner returns the integer ID for the user and group of the given path
Expand Down

0 comments on commit 1659924

Please sign in to comment.