Vendor in latest selinux code for keycreate errors

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2019-04-24 08:41:56 -04:00
parent 029124da7a
commit 8362cd02c0
2 changed files with 9 additions and 2 deletions

View File

@@ -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