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