KEYCTL_ASSUME_AUTHORITY(2const)

πŸ’… KEYCTL_ASSUME_AUTHORITY β€” the keyctl const, bestie edition ✨

okay so this is a page from section 2const of the Unix manual β€” the keyctl const girlies β€” and it's literally all about assuming the authority to instantiate a key. yes that's the whole vibe. let's get into it 🫢


✨ NAME ✨

KEYCTL_ASSUME_AUTHORITY β€” bestie, it's giving "assume the authority to instantiate a key" πŸ’…


πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc) β€” yep, the classic 🌸


πŸŽ€ 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_ASSUME_AUTHORITY, key_serial_t key);

literally just one lil syscall, no cap πŸ¦‹


🌈 DESCRIPTION 🌈

So what this does: it lets the calling thread assume β€” or divest β€” the authority to instantiate a key. main character energy for threads fr fr πŸ‘‘

The key argument is doing one of two things:

  • it's a nonzero key ID, in which case you're assuming authority,
  • or it's the value 0, in which case you're divesting authority. bye bestie πŸ’€

If key is nonzero, then it specifies the ID of an uninstantiated key that you wanna take authority over. once you've got that, you can instantiate it using any one of these:

and here's the cute part: once the key has been instantiated, the thread is automatically divested of its authority to instantiate the key. it just… lets go. growth. ✨

Now, the rules. Authority over a key can be assumed only if the calling thread has, present in its keyrings, the authorization key associated with the specified key. in other words β€” and I'm quoting the vibe here β€” the KEYCTL_ASSUME_AUTHORITY operation is available only from a request-key(8)-style program. see request_key(2) if you wanna know how this operation is actually used. also: the caller must have search permission on the authorization key. no permission, no authority. 🚫

If the specified key has a matching authorization key, then the ID of that key gets returned. and you can read the authorization key with KEYCTL_READ(2const) to grab the callout information that was passed to request_key(2). handy πŸ“

If the ID given in key is 0, then the currently assumed authority is cleared (divested), and the value 0 is returned. clean slate, we love to see it πŸ’–

So why does this mechanism even exist? Because KEYCTL_ASSUME_AUTHORITY lets a program like request-key(8) assume the necessary authority to instantiate a brand-new uninstantiated key that got created as a consequence of a call to request_key(2). for more info, go read request_key(2) and the kernel source file Documentation/security/keys/request-key.rst. iykyk πŸ“–


πŸ”₯ RETURN VALUE πŸ”₯

On success, you get either:

  • 0 β€” if the ID you gave was 0, or
  • the ID of the authorization key matching the specified key β€” if you provided a nonzero key ID.

On error, -1 is returned, and errno is set to indicate the error. classic. 😭


🌸 VERSIONS 🌸

There's a wrapper for this in the libkeyutils library: keyctl_assume_authority(3). so if you don't wanna raw-dog the syscall, you don't have to 🧚


⭐ STANDARDS ⭐

Linux. that's it. that's the standard. periodt πŸ’…


πŸ‘‘ HISTORY πŸ‘‘

Linux 2.6.16. an icon, been around forever 🌈


πŸ’œ SEE ALSO πŸ’œ


lowkey reminder bestie: this authority thing only works if you're a request-key(8)-style program with the authorization key in your keyrings and search permission on it. no shortcuts, no vibes-based access 🚨

okay that's the whole page!! mwah πŸ’‹ this was Linux man-pages 6.20, dated 2026-02-08 β€” thanks for reading, ily, go instantiate something responsibly πŸŽ€βœ¨

πŸ“¦ 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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms