Skip to content

Commit b608451

Browse files
authored
Merge pull request #1694 from marquiz/devel/selinux
source/kernel: silence misleading error on selinux detection
2 parents b9770b1 + ce66121 commit b608451

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

source/kernel/selinux.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,11 @@ func SelinuxEnabled() (bool, error) {
3232
return false, err
3333
}
3434

35-
selinuxBase := filepath.Join(sysfsBase, "selinux")
36-
if _, err := os.Stat(selinuxBase); os.IsNotExist(err) {
35+
status, err := os.ReadFile(filepath.Join(sysfsBase, "selinux", "enforce"))
36+
if os.IsNotExist(err) {
3737
klog.V(1).InfoS("selinux not available on the system")
3838
return false, nil
39-
}
40-
41-
status, err := os.ReadFile(filepath.Join(selinuxBase, "enforce"))
42-
if err != nil {
39+
} else if err != nil {
4340
return false, err
4441
}
4542
if status[0] == byte('1') {

0 commit comments

Comments
 (0)