From 23ff4427e2485be47980fdc8061994e4dff7e3e0 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Mon, 22 Jan 2018 16:45:55 -0500 Subject: [PATCH] crio: abstract the selinux call Signed-off-by: Vincent Batts --- cmd/crio/main.go | 3 +-- cmd/crio/selinux_linux.go | 9 +++++++++ cmd/crio/selinux_unsupported.go | 9 +++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 cmd/crio/selinux_linux.go create mode 100644 cmd/crio/selinux_unsupported.go diff --git a/cmd/crio/main.go b/cmd/crio/main.go index a1c0bad9..0c4bfa3b 100644 --- a/cmd/crio/main.go +++ b/cmd/crio/main.go @@ -17,7 +17,6 @@ import ( "github.com/kubernetes-incubator/cri-o/lib" "github.com/kubernetes-incubator/cri-o/server" "github.com/kubernetes-incubator/cri-o/version" - "github.com/opencontainers/selinux/go-selinux" "github.com/sirupsen/logrus" "github.com/soheilhy/cmux" "github.com/urfave/cli" @@ -429,7 +428,7 @@ func main() { config := c.App.Metadata["config"].(*server.Config) if !config.SELinux { - selinux.SetDisabled() + disableSELinux() } if _, err := os.Stat(config.Runtime); os.IsNotExist(err) { diff --git a/cmd/crio/selinux_linux.go b/cmd/crio/selinux_linux.go new file mode 100644 index 00000000..a32c1d58 --- /dev/null +++ b/cmd/crio/selinux_linux.go @@ -0,0 +1,9 @@ +// +build linux + +package main + +import selinux "github.com/opencontainers/selinux/go-selinux" + +func disableSELinux() { + selinux.SetDisabled() +} diff --git a/cmd/crio/selinux_unsupported.go b/cmd/crio/selinux_unsupported.go new file mode 100644 index 00000000..8e719ac1 --- /dev/null +++ b/cmd/crio/selinux_unsupported.go @@ -0,0 +1,9 @@ +// +build !linux + +package main + +import "github.com/sirupsen/logrus" + +func disableSELinux() { + logrus.Infof("there is no selinux to disable") +}