Skip to content

Commit

Permalink
Older kernels do not support keyring labeling
Browse files Browse the repository at this point in the history
Ignore setting the kernel keyring label if the
/proc/self/attr/keycreate file does not exists.

runc attempts to set this file on older kernels and is blowing up.

If a system has a /proc/self/attr/keyring and the caller attempts to set
the label to "" and SELinux is disabled, ignore the error.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
  • Loading branch information
rhatdan committed Apr 4, 2019
1 parent 0bb7b9f commit 3a1f366
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.0-dev
1.2.2
9 changes: 8 additions & 1 deletion go-selinux/selinux_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,14 @@ func SocketLabel() (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 {
return writeCon("/proc/self/attr/keycreate", label)
err := writeCon("/proc/self/attr/keycreate", label)
if os.IsNotExist(err) {
return nil
}
if label == "" && os.IsPermission(err) && !GetEnabled() {
return nil
}
return err
}

// KeyLabel retrieves the current kernel keyring label setting
Expand Down

0 comments on commit 3a1f366

Please sign in to comment.