k3s/pkg/agent/containerd/selinux.go

28 lines
463 B
Go
Raw Normal View History

2020-02-24 20:13:59 +00:00
package containerd
import (
"github.com/opencontainers/selinux/go-selinux"
)
const (
SELinuxContextType = "container_runtime_t"
)
func selinuxStatus() (bool, bool, error) {
2020-02-24 20:13:59 +00:00
if !selinux.GetEnabled() {
return false, false, nil
2020-02-24 20:13:59 +00:00
}
label, err := selinux.CurrentLabel()
if err != nil {
return true, false, err
2020-02-24 20:13:59 +00:00
}
ctx, err := selinux.NewContext(label)
if err != nil {
return true, false, err
2020-02-24 20:13:59 +00:00
}
return true, ctx["type"] == SELinuxContextType, nil
2020-02-24 20:13:59 +00:00
}