mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
28 lines
433 B
Go
28 lines
433 B
Go
|
package containerd
|
||
|
|
||
|
import (
|
||
|
"github.com/opencontainers/selinux/go-selinux"
|
||
|
)
|
||
|
|
||
|
const (
|
||
|
SELinuxContextType = "container_runtime_t"
|
||
|
)
|
||
|
|
||
|
func selinuxEnabled() (bool, error) {
|
||
|
if !selinux.GetEnabled() {
|
||
|
return false, nil
|
||
|
}
|
||
|
|
||
|
label, err := selinux.CurrentLabel()
|
||
|
if err != nil {
|
||
|
return false, err
|
||
|
}
|
||
|
|
||
|
ctx, err := selinux.NewContext(label)
|
||
|
if err != nil {
|
||
|
return false, err
|
||
|
}
|
||
|
|
||
|
return ctx["type"] == SELinuxContextType, nil
|
||
|
}
|