Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source/kernel: silence misleading error on selinux detection #1694

Merged
merged 1 commit into from
May 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions source/kernel/selinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,11 @@
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) {

Check warning on line 36 in source/kernel/selinux.go

View check run for this annotation

Codecov / codecov/patch

source/kernel/selinux.go#L35-L36

Added lines #L35 - L36 were not covered by tests
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 {

Check warning on line 39 in source/kernel/selinux.go

View check run for this annotation

Codecov / codecov/patch

source/kernel/selinux.go#L39

Added line #L39 was not covered by tests
return false, err
}
if status[0] == byte('1') {
Expand Down