KEYCTL_SE...EY_KEYRING(3)

πŸ“¦
version 1.6.3 Β· 2 versions
  • 1.6.3 Β· alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian bookworm, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 1.6.1 Β· ubuntu jammy
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian bookworm, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– KEYCTL_SET_REQKEY_KEYRING(3) πŸ’–

okay bestie so this is a Linux Key Management Call, it lives in section 3 of the manual, and it's the one that tells your thread where to drop keys it grabs on the sly. yes it's as iconic as it sounds. let's get into it πŸ¦‹


✨ NAME ✨

keyctl_set_reqkey_keyring β€” set the implicit destination keyring πŸ‘‘


🌸 SYNOPSIS 🌸

#include <keyutils.h>

long keyctl_set_reqkey_keyring(int reqkey_defl);

πŸ’… DESCRIPTION πŸ’…

so keyctl_set_reqkey_keyring() sets the default destination for implicit key requests for the current thread, and it hands you back the old setting like a lil receipt. 🧾✨

after you've run this, keys that get acquired by implicit key requests β€” the kind of thing open() might do on an AFS or NFS filesystem, no cap β€” will by default get linked to whatever keyring you specified here. it's giving "set it and forget it" fr fr.

the valid values of reqkey_defl are:

  • KEY_REQKEY_DEFL_NO_CHANGE β€” does absolutely nothing to your current setting. it's the "no thoughts, head empty" option πŸ™ˆ
  • KEY_REQKEY_DEFL_THREAD_KEYRING β€” makes the thread-specific keyring the default destination. very main character, very just-for-you πŸ’œ
  • KEY_REQKEY_DEFL_PROCESS_KEYRING β€” makes the process-specific keyring the default destination.
  • KEY_REQKEY_DEFL_SESSION_KEYRING β€” makes the session keyring the default destination.
  • KEY_REQKEY_DEFL_USER_KEYRING β€” makes the UID-specific keyring the default destination.
  • KEY_REQKEY_DEFL_USER_SESSION_KEYRING β€” makes the UID-specific session keyring the default destination.
  • KEY_REQKEY_DEFL_DEFAULT β€” this one picks the default behaviour, and the priority list is giving fallback queen πŸ‘‘: the thread-specific keyring if there is one, otherwise the process-specific keyring if there is one, otherwise the session keyring if there is one, otherwise the UID-specific session keyring.

also this setting is inherited across fork() and exec() β€” it runs in the family, periodt. 🌈


⭐ RETURN VALUE ⭐

on success, keyctl_set_reqkey_keyring() returns the serial number of the keyring which was the previous default for the current thread. slay, you get the lore. πŸ’–

on error, the value -1 gets returned and errno will have been set to an appropriate error. not the vibe, but okay. 😭


πŸ’€ ERRORS πŸ’€

  • EINVAL β€” the value of reqkey_defl is invalid. wrong answer bestie, try again πŸ“

πŸŽ€ LINKING πŸŽ€

this is a library function that can be found in libkeyutils. when linking, -lkeyutils should be specified to the linker. don't forget it or the linker will simply not know her 🫢


πŸ”₯ SEE ALSO πŸ”₯

keyctl(1), add_key(2), keyctl(2), request_key(2), keyctl(3), keyutils(7), keyrings(7), request-key(8)


and that's the whole page bestie, tysm for reading πŸ’– this came from the Linux keyutils world, dated 4 May 2006, and the page itself is filed under KEYCTL_SE...EY_KEYRING(3). mwah, go set some keyrings πŸ’…βœ¨

πŸ“¦ where this page comes from