KEYCTL_INVALIDATE(3)

✨ KEYCTL_INVALIDATE πŸ’…

okay bestie, so we're in section 3 of the Linux Key Management Calls manual, and today's main character is keyctl_invalidate β€” the "you're dead to me" button for keys. no cap. 🫢


🌸 NAME 🌸

keyctl_invalidate β€” invalidate a key πŸ’€βœ¨


πŸŽ€ SYNOPSIS πŸŽ€

#include <keyutils.h>

long keyctl_invalidate(key_serial_t key);

πŸ’– DESCRIPTION πŸ’–

okay so keyctl_invalidate() invalidates a key. and the way it does it is lowkey dramatic: the key gets scheduled for immediate removal from all the keyrings that point to it, and after that it's getting deleted. periodt. πŸ—‘οΈ

and here's the iconic part β€” the key gets ignored by all searches the second this function is called, even if it hasn't been fully dealt with yet. like, it's ghosted on sight. no waiting around, no "let me think about it". the vibe check is instant. πŸ‘‘

but listen, there's a gate: the caller must have search permission on a key to be able to invalidate it. no search permission, no invalidation. that's the rule, i don't make them. πŸ”


⭐ RETURN VALUE ⭐

  • on success, keyctl_invalidate() returns 0. slay. πŸŽ‰
  • on error, the value -1 gets returned and errno will have been set to an appropriate error. 😭

πŸ”₯ ERRORS πŸ”₯

  • ENOKEY β€” the key specified is invalid. not a real one, bestie, we can't find it πŸ™ˆ
  • EKEYEXPIRED β€” the key specified has expired. it's giving "expired milk in the fridge" πŸ₯›πŸ’€
  • EKEYREVOKED β€” the key specified had been revoked. somebody already pulled its card 🚫
  • EACCES β€” the key exists, but is not searchable by the calling process. it's there, you just don't have the pass πŸ‘€

πŸ¦‹ LINKING πŸ¦‹

this is a library function and it lives in libkeyutils. so when you're linking, -lkeyutils should be specified to the linker. don't forget it or you'll be crying in undefined reference 😭✨


🌈 SEE ALSO 🌈

keyctl(1), add_key(2), keyctl(2), request_key(2), keyctl(3), keyrings(7), keyutils(7)


and that's the whole page, bestie πŸ’– this one came straight outta the Linux keyutils world, dated 29 Aug 2013 β€” yeah she's an elder but she still ate πŸ‘‘βœ¨ go invalidate something responsibly, ily, bye πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from