Skip to content

Commit

Permalink
Show SELinux label on failure
Browse files Browse the repository at this point in the history
We are seeing EINVAL errors with container engines setting SELinux
labels. It would be helpful to see what Labels the engines are trying
to set.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
  • Loading branch information
rhatdan committed Jul 31, 2024
1 parent bb1ec25 commit a45b490
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions go-selinux/selinux_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func lSetFileLabel(fpath string, label string) error {
break
}
if err != unix.EINTR {
return &os.PathError{Op: "lsetxattr", Path: fpath, Err: err}
return &os.PathError{Op: "lsetxattr", Path: fpath, Err: fmt.Errorf("label=%s: %v", label, err)}

Check failure on line 332 in go-selinux/selinux_linux.go

View workflow job for this annotation

GitHub Actions / lint

non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
}
}

Expand All @@ -348,7 +348,7 @@ func setFileLabel(fpath string, label string) error {
break
}
if err != unix.EINTR {
return &os.PathError{Op: "setxattr", Path: fpath, Err: err}
return &os.PathError{Op: "setxattr", Path: fpath, Err: fmt.Errorf("label=%s: %v", label, err)}

Check failure on line 351 in go-selinux/selinux_linux.go

View workflow job for this annotation

GitHub Actions / lint

non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
}
}

Expand Down

0 comments on commit a45b490

Please sign in to comment.