KEYCTL_SET_REQKEY_KEYRING(2const)

πŸ’… KEYCTL_SET_REQKEY_KEYRING πŸ’…

okay bestie, so this one lives in section 2const of the Linux manual pages β€” it's a keyctl(2) operation constant, and it's literally the "where do my spontaneous keys go" knob. no cap.


✨ NAME ✨

KEYCTL_SET_REQKEY_KEYRING β€” set the implicit destination keyring πŸŽ€

πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc)

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <linux/keyctl.h>  /* Definition of KEY* constants */
#include <sys/syscall.h>   /* Definition of SYS_* constants */
#include <unistd.h>

long syscall(SYS_keyctl, KEYCTL_SET_REQKEY_KEYRING, int op);

🌸 DESCRIPTION 🌸

So what this does is: it sets the default keyring that implicitly requested keys get linked into, for this thread, and then it hands you back the previous setting like a little receipt. 🧾✨

"Implicit key requests" are the ones made by internal kernel components β€” think of stuff like when you open files on an AFS or NFS filesystem. that's the kernel asking for a key on your behalf without you even asking, iykyk. also, setting the default keyring has an effect when a key is requested from user space too; go peek at request_key(2) for the deets.

The op argument should hold one of these values, which is how you say what the new default keyring is:

  • KEY_REQKEY_DEFL_NO_CHANGE β€” don't touch the default keyring at all. this is the "just tell me what it is rn" move β€” lets you discover the current default keyring without changing anything. πŸ‘€
  • KEY_REQKEY_DEFL_DEFAULT β€” this picks the default behavior, and the fallback chain is iconic honestly: use 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, otherwise the user-specific keyring. it just keeps going down the list. πŸ’«
  • KEY_REQKEY_DEFL_THREAD_KEYRING β€” use the thread-specific keyring (thread-keyring(7)) as the new default keyring.
  • KEY_REQKEY_DEFL_PROCESS_KEYRING β€” use the process-specific keyring (process-keyring(7)) as the new default keyring.
  • KEY_REQKEY_DEFL_SESSION_KEYRING β€” use the session-specific keyring (session-keyring(7)) as the new default keyring.
  • KEY_REQKEY_DEFL_USER_KEYRING β€” use the UID-specific keyring (user-keyring(7)) as the new default keyring.
  • KEY_REQKEY_DEFL_USER_SESSION_KEYRING β€” use the UID-specific session keyring (user-session-keyring(7)) as the new default keyring.
  • KEY_REQKEY_DEFL_REQUESTOR_KEYRING (since Linux 2.6.29) β€” use the requestor keyring.
heads up bestie: All other values are invalid. like, not "eh maybe", actually invalid. don't try it. πŸ’€

and the setting this operation controls? it gets inherited by the child of fork(2) and it's preserved across execve(2). so it follows you around. main character energy fr fr.

🫢 RETURN VALUE 🫢

On success, you get the ID of the previous default keyring that implicitly requested keys were linked to β€” one of KEY_REQKEY_DEFL_USER_*. πŸŽ‰

On error, -1 is returned, and errno is set to indicate the error. 😭

⭐ VERSIONS ⭐

There's a wrapper for this in the libkeyutils library: keyctl_set_reqkey_keyring(3)

πŸ‘‘ STANDARDS πŸ‘‘

Linux. periodt.

🌈 HISTORY 🌈

Linux 2.6.13. a classic. πŸ’–

πŸ¦„ SEE ALSO πŸ¦„


okay that's the whole thing bestie, go set some keyrings, slay πŸ’…βœ¨

Linux man-pages 6.20 β€” 2026-02-08 πŸŽ€ that's the version and the date, mwah, bye 🫢

πŸ“¦ where this page comes from
  • arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • πŸ“œ the page's license: Linux-man-pages-copyleft
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms