From ce66121d3c4fe1b7896162b5fee684fd62331c65 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Thu, 2 May 2024 11:07:23 +0300 Subject: [PATCH] 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). --- source/kernel/selinux.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/source/kernel/selinux.go b/source/kernel/selinux.go index 51ecd9a14..f3ecbea08 100644 --- a/source/kernel/selinux.go +++ b/source/kernel/selinux.go @@ -32,14 +32,11 @@ func SelinuxEnabled() (bool, error) { return false, err } - selinuxBase := filepath.Join(sysfsBase, "selinux") - if _, err := os.Stat(selinuxBase); os.IsNotExist(err) { + status, err := os.ReadFile(filepath.Join(sysfsBase, "selinux", "enforce")) + if os.IsNotExist(err) { klog.V(1).InfoS("selinux not available on the system") return false, nil - } - - status, err := os.ReadFile(filepath.Join(selinuxBase, "enforce")) - if err != nil { + } else if err != nil { return false, err } if status[0] == byte('1') {