KEYCTL_SE...EY_KEYRING(3)
π 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 ofreqkey_deflis 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
- alpine 3.22: keyutils-doc 1.6.3-r4 Β· GPL-2.0-or-later AND LGPL-2.0-or-later
- alpine 3.23: keyutils-doc 1.6.3-r4 Β· GPL-2.0-or-later AND LGPL-2.0-or-later
- alpine 3.24: keyutils-doc 1.6.3-r4 Β· GPL-2.0-or-later AND LGPL-2.0-or-later
- arch rolling: keyutils 1.6.3-4 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- centos-stream 10: keyutils-libs-devel 1.6.3-5.el10 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- centos-stream 9: keyutils-libs-devel 1.6.3-1.el9 Β· GPLv2+ and LGPLv2+
- centos-stream 9: keyutils-libs-devel 1.6.3-1.el9 Β· GPLv2+ and LGPLv2+
- debian bookworm: libkeyutils-dev 1.6.3-2 Β· GPL-2.0-or-later
- debian trixie: libkeyutils-dev 1.6.3-6 Β· GPL-2.0-or-later
- fedora 43: keyutils-libs-devel 1.6.3-6.fc43 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- fedora 43: keyutils-libs-devel 1.6.3-6.fc43 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- fedora 44: keyutils-libs-devel 1.6.3-7.fc44 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- fedora 44: keyutils-libs-devel 1.6.3-7.fc44 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- nixpkgs unstable: keyutils 1.6.3
- opensuse-leap 16.0: keyutils 1.6.3-160000.3.2 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- opensuse-leap 16.0: keyutils 1.6.3-160000.3.2 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- opensuse-leap 16.0: keyutils 1.6.3-160000.3.2 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- opensuse-leap 16.0: keyutils 1.6.3-160000.3.2 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- ubuntu noble: libkeyutils-dev 1.6.3-3build1 Β· GPL-2.0-or-later
- ubuntu questing: libkeyutils-dev 1.6.3-6ubuntu2
- ubuntu resolute: libkeyutils-dev 1.6.3-6ubuntu3 Β· GPL-2.0-or-later
- ubuntu stonking: libkeyutils-dev 1.6.3-6ubuntu3 Β· GPL-2.0-or-later
- Copyright (C) 2006 Red Hat, Inc. All Rights Reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms