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
- Copyright 2016, Michael Kerrisk <mtk.manpages@gmail.com>
- Copyright 2016, Eugene Syromyatnikov <evgsyr@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms