KEYCTL_RESTRICT_KEYRING(3)
π KEYCTL_RESTRICT_KEYRING β the Linux key management calls, bestie edition π
okay so real talk, this one is a <keyutils.h> situation, it lives in the Linux key management family, and it's lowkey one of the most gatekeeping functions ever because it literally lets you lock a keyring down. iconic behavior fr fr π
β¨ NAME β¨
keyctl_restrict_keyring β restrict which keys are allowed to get linked onto a keyring π
π¦ SYNOPSIS π¦
#include <keyutils.h>
long keyctl_restrict_keyring(key_serial_t keyring,
const char *type, const char *restriction);
πΈ DESCRIPTION πΈ
so keyctl_restrict_keyring() does the thing where it limits the linkage of keys to the given keyring, using a key type and a restriction scheme you hand it. the way that it works is very much "you don't get in unless you pass the vibe check" energy π
the available options vary depending on the key type, and they typically contain a restriction name, possibly followed by key ids or other data relevant to the restriction. iykyk π
and here's the plot twist: if the type and the restriction are both NULL, the keyring will reject all links. not some. all. it's giving locked door, no key, no note, no nothing π
π₯ RETURN VALUE π₯
on success, keyctl_restrict_keyring() returns 0. slay β¨
on error, the value -1 will be returned and errno will have been set to an appropriate error. not slay π
π ERRORS π
EDEADLKβ a restriction cycle was avoided. two keyrings cannot restrict each other, periodt. no mutual-lockdown situationships allowed πEEXISTβ the keyring is already restricted. bestie it's taken, the lock is already on πEINVALβ the restriction string is invalid or too large. too much, too messy, we can't work with that πENOKEYβ the key type in the restriction is invalid or not available. never heard of her πENOTDIRβ the provided key id references an item that is not a keyring. wrong main character, wrong role πENOENTβ the key type exists but does not support restrictions. she's here, she just doesn't do that β
π«Ά 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 be so confused ngl π§
β SEE ALSO β
β οΈ gentle reminder bestie: if you restrict a keyring, you cannot un-restrict it. EEXIST said what it said. commit wisely π
that's the whole page!! from the Linux fam, dated 28 Feb 2017, and you're reading the KEYCTL_RESTRICT_KEYRING(3) girlies' cut π
mwah, go restrict responsibly πβ¨
π¦ 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 jammy: libkeyutils-dev 1.6.1-2ubuntu3 Β· GPL-2.0-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
- Copyright (C) 2017 Intel Corporation. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms