Skip to content

Commit

Permalink
skip write /proc/self/attr/keycreate when selinux label is null
Browse files Browse the repository at this point in the history
Signed-off-by: ningmingxiao <[email protected]>
  • Loading branch information
ningmingxiao committed Jul 29, 2024
1 parent bb1ec25 commit ee265e5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions go-selinux/selinux_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -724,11 +724,11 @@ func peerLabel(fd uintptr) (string, error) {
// setKeyLabel takes a process label and tells the kernel to assign the
// label to the next kernel keyring that gets created
func setKeyLabel(label string) error {
err := writeCon("/proc/self/attr/keycreate", label)
if errors.Is(err, os.ErrNotExist) {
if label == "" {
return nil
}
if label == "" && errors.Is(err, os.ErrPermission) {
err := writeCon("/proc/self/attr/keycreate", label)
if errors.Is(err, os.ErrNotExist) {
return nil
}
return err
Expand Down

0 comments on commit ee265e5

Please sign in to comment.