key_move(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… key_move(9) β€” like, the actual manual page, bestie

okay so this is key_move(9) from the Kernel API Manual, and honestly? it's giving "small function, big responsibilities." it moves a key from one keyring to another. that's the whole vibe. let's get into it πŸŽ€


✨ NAME ✨

key_move β€” move a key from one keyring to another. yes, literally that. no crumbs left behind πŸ¦‹


🌸 SYNOPSIS 🌸

int key_move (struct key *key , struct key *from_keyring , struct key
*to_keyring , unsigned int flags );

look at her. four parameters. one int return. main character energy fr fr πŸ‘‘


πŸ’– ARGUMENTS πŸ’–

  • key β€” the key we're moving. the little guy in question πŸ₯Ί
  • from_keyring β€” the keyring we're removing the link from. she's losing a link today, it's fine, she'll recover πŸ’…
  • to_keyring β€” the keyring we're making the link in. she's gaining one. slay.
  • flags β€” qualifying flags, like KEYCTL_MOVE_EXCL. the "qualifying" is doing a lot of work there ngl ✨

πŸ¦‹ DESCRIPTION πŸ¦‹

so what actually happens? key_move makes a link in to_keyring to a key, such that the keyring holds a reference on that key and the key can potentially be found by searching that keyring β€” and simultaneously removes a link to the key from from_keyring. one motion, two outcomes, iconic behaviour honestly πŸ”₯

this function will write-lock both keyring's semaphores and will consume some of the user's key data quota to hold the link on to to_keyring. so yeah, it's not free. budget accordingly πŸ™ˆ

returns 0 if successful. and if it's not successful, here's the whole mood board of error codes:

  • -ENOTDIR β€” if either keyring isn't a keyring. like bestie, that's not a keyring πŸ’€
  • -EKEYREVOKED β€” if either keyring has been revoked. oop.
  • -ENFILE β€” if the second keyring is full. no room, no vibes 😭
  • -EDQUOT β€” if there is insufficient key data quota remaining to add another link. the quota said no πŸ“
  • -ENOMEM β€” if there's insufficient memory. classic.
  • -EEXIST β€” only if KEYCTL_MOVE_EXCL is set, and only if there's already a matching key in to_keyring. exclusivity is a boundary, respect it πŸ’…
also important, and i'm not being cute about this one: it is assumed that the caller has checked that it is permitted for a link to be made. meaning the keyring should have Write permission and the key needs Link permission. the function is not doing that check for you β€” that's your job, bestie 🫢

🌈 SEE ALSO 🌈

go read these next, they're all part of the same friend group:


⭐ okay that's the page!! sourced from ./security/keys, dated October 2026 β€” so like, future-dated documentation, we love a forward-thinking queen. bye bestie, go move some keys πŸ’œπŸ§š

πŸ“¦ where this page comes from