FIND_KEY_B...PE_AND_NAME(3)
π FIND_KEY_B...PE_AND_NAME π
ok so bestie, we're in the Linux Key Utility Calls section of the manual, and this page is literally about one function: find_key_by_type_and_name. yes the title is a whole mouthful, we're abbreviating it, don't @ me. π
β¨ NAME β¨
find_key_by_type_and_name β find a key by type and name. that's it. that's the whole vibe. π
πΈ SYNOPSIS πΈ
#include <keyutils.h>
key_serial_t find_key_by_type_and_name(const char *type,
const char *description, key_serial_t destringid);
three arguments, one return value, zero drama. copy it exactly, bestie, the compiler is watching. π
π¦ DESCRIPTION π¦
okay so here's what find_key_by_type_and_name() actually does: it goes looking for a key that has the given type and an exact description (exact, like, no fuzzy matching, no "close enough" β we are not doing vibes-based searching here π
).
and the way it searches? it's giving main character energy in two acts:
- first it checks the thread, process and session keyrings that the process is subscribed to.
- then it checks
/proc/keys.
so it's like checking your group chats before you check the archive. π±β¨
and if a key is found β and destringid is not 0 and it specifies a keyring β then guess what? the found key gets linked into it. cute little key adoption moment fr fr. π«Ά
β RETURN VALUE β
- the function returns the ID of the key if a key was found π
- or
-1otherwise π
that's it. no cap.
π₯ ERRORS π₯
when it's not slaying, here's why:
ENOKEYβ no key was found, or the keyring you specified is invalid. (either way, nothing's there bestie π)EKEYEXPIREDβ the key or the keyring have expired. time said no. βEKEYREVOKEDβ the key or the keyring have been revoked. it's over, it's been over. π«EACCESβ the key is not accessible, or the keyring exists but is not writable by the calling process. so close and yet so far π
π LINKING π
listen up because this one matters: when you're linking, you gotta pass -lkeyutils to the linker.
no flag, no link, no keys. periodt. π
π SEE ALSO π
go read these next, they're iconic:
and that's the whole page, my love β brought to you by the Linux crew, dated 10 Sep 2013, and yeah it's an oldie but she still serves. mwah, go link some keys πβ¨
π¦ 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) 2013 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