RECURSIVE_KEY_SCAN(3)
π RECURSIVE_KEY_SCAN(3) π
okay bestie, so this is a page from the Linux Key Utility Calls manual, and it's literally the blueprint for walking a whole keyring tree like the main character you are β¨
πΈ NAME πΈ
recursive_key_scan, recursive_session_key_scan β apply a function to all keys in a keyring tree π
β¨ SYNOPSIS β¨
#include <keyutils.h>
typedef int (*recursive_key_scanner_t)(key_serial_t parent,
key_serial_t key, char *desc, int desc_len, void *data);
long recursive_key_scan(key_serial_t keyring,
recursive_key_scanner_t func, void *data);
long recursive_session_key_scan(recursive_key_scanner_t func,
void *data);
like, that's the whole vibe right there π
π¦ DESCRIPTION π¦
recursive_key_scan() does a depth-first recursive scan of the keyring tree you point it at, and it applies func to every single link it finds in the accessible keyrings inside that tree. no cap, every link. and data gets passed along to every invocation of func π«Ά
The return values of func get summed up and that sum is what you get back as the overall return value. Errors? Ignored, periodt. π Also: inaccessible keyrings don't get scanned, but the links pointing at them still get passed to func β so like, func still hears about them, she just doesn't go inside. π
recursive_session_key_scan() works exactly like recursive_key_scan() except the caller's session keyring is the starting keyring. same energy, different starting point. π
The callback function gets called for each link found in all the keyrings in the nominated tree β which means it may be called multiple times for a particular key if that key has multiple links to it. so don't be shocked when the same key shows up again, she's just that popular. π
π the callback function's parameters π
parentβ the keyring containing the link, or0for the initial key. πkeyβ the key to which the link points. π₯descanddesc_lenβ a pointer to the raw description and its length, as retrieved withkeyctl_describe_alloc(). These will beNULLand-1respectively if the description couldn't be retrieved, anderrnowill retain the error fromkeyctl_describe_alloc(). π so yeah, check those. fr fr.dataβ the data passed to the scanner function. β
π RETURN VALUE π
These functions return the sum of the results of the callback functions they invoke. that's it, that's the whole bag. π
π ERRORS π
Ignored. literally ignored. not even a little bit of attention. πβ¨
π§ LINKING π§
When linking, -lkeyutils should be specified to the linker. don't forget it or the linker will be giving you the side eye. π
π SEE ALSO π
and that's the tea, bestie π this page is from Linux, dated 10 Mar 2011 β iconic, historic, still slaying. now go scan that tree. πΈπ¦β¨
π¦ 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) 2011 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