KEYCTL_SESSION_TO_PARENT(3)

✨ KEYCTL_SES..._TO_PARENT(3) ✨

okay so bestie, welcome to the Linux Key Management Calls section of the manual β€” this is the page for keyctl_session_to_parent, and it's giving "quietly rearranging your whole family's keyring situation" energy πŸ’…


🌸 NAME 🌸

keyctl_session_to_parent β€” set the parent process's session keyring, bestie. that's it, that's the whole vibe ✨


πŸŽ€ SYNOPSIS πŸŽ€

#include <keyutils.h>

long keyctl_session_to_parent();

no args, no fuss, she just does the thing 🫢


πŸ’– DESCRIPTION πŸ’–

so here's the tea: keyctl_session_to_parent() changes the session keyring to which the calling process's parent subscribes, and makes it be the keyring of the calling process. like, you're handing your own session keyring up to your parent, and the parent is now subscribed to that one. iconic behavior, honestly πŸ‘‘

but bestie, there are ✨conditions✨ (there always are):

  • the keyring has to have link permission available to the calling process
  • the parent process has to have the same UIDs/GIDs as the calling process
  • the LSM must not reject the replacement (so if security says no, it's a no, periodt)
also, huge note: this may not be used to affect init or a kernel thread. like, do not. it's not that kind of function πŸ™ˆ

and one more lil detail that lowkey matters a lot: the replacement will not take immediate effect on the parent process. nope. it's deferred β€” it happens the next time the parent returns to userspace from kernel space. so it's giving "the change is on its way, she's just running late πŸ¦‹"</p>


⭐ RETURN VALUE ⭐

  • success β†’ keyctl_session_to_parent() returns 0. slay πŸŽ‰
  • error β†’ the value -1 gets returned, and errno will have been set to an appropriate error. not slay πŸ’€

🌈 ERRORS 🌈

  • ENOMEM β€” not enough memory to create a key. she's broke, literally 😭
  • EPERM β€” the credentials of the parent don't match those of the caller. different UIDs/GIDs, different story πŸ™…
  • EACCES β€” the named keyring exists, but the calling process can't link to it. it's there, you just can't touch it πŸ’…

πŸ”— LINKING πŸ”—

this is a library function, bestie β€” you'll find her hanging out in libkeyutils. when you're linking, you gotta specify -lkeyutils to the linker. don't forget her, she gets lonely πŸ₯Ί


πŸ‘‘ SEE ALSO πŸ‘‘

go read those too, iykyk πŸ“šβœ¨


and that's the whole page, bestie!! 🫢 this one came from Linux, dated 20 Feb 2014 β€” the manual page for the Linux Key Management Calls, brought to you by the libkeyutils girlies πŸ’– stay keyed in, drink water, and never, ever try to affect init with this. mwah πŸŽ€

πŸ“¦ where this page comes from