1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2024-12-14 11:57:51 +00:00

source/kernel: silence misleading error on selinux detection

Silence a irrelevant error that was printed in case /sys/fs/selinux/
directory exists but selinuxfs is not mounted (i.e. the dir is empty).
This commit is contained in:
Markus Lehtonen 2024-05-02 11:07:23 +03:00
parent c2e3de68f6
commit ce66121d3c

View file

@ -32,14 +32,11 @@ func SelinuxEnabled() (bool, error) {
return false, err return false, err
} }
selinuxBase := filepath.Join(sysfsBase, "selinux") status, err := os.ReadFile(filepath.Join(sysfsBase, "selinux", "enforce"))
if _, err := os.Stat(selinuxBase); os.IsNotExist(err) { if os.IsNotExist(err) {
klog.V(1).InfoS("selinux not available on the system") klog.V(1).InfoS("selinux not available on the system")
return false, nil return false, nil
} } else if err != nil {
status, err := os.ReadFile(filepath.Join(selinuxBase, "enforce"))
if err != nil {
return false, err return false, err
} }
if status[0] == byte('1') { if status[0] == byte('1') {