KEYCTL_MOVE(3)

πŸ“¦
version 1.6.3 Β· 2 versions
  • 1.6.3 Β· alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian bookworm, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 1.6.1 Β· ubuntu jammy
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian bookworm, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ NAME ✨

keyctl_move β€” bestie, this is the one that moves a key between keyrings πŸ’… (it's KEYCTL_MOVE(3), from the Linux Key Management Calls manual, if you were wondering πŸŽ€)


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <keyutils.h>

long keyctl_move(key_serial_t key, key_serial_t from_keyring,
                 key_serial_t to_keyring, unsigned int flags);

🌸 DESCRIPTION 🌸

okay so listen. keyctl_move() takes key and does the whole glow-up atomically β€” it unlinks it from from_keyring and links it straight into to_keyring in literally one single operation, no in-between era, no awkward transitional phase ✨

Depending on what flags you set, a link to any matching key chillin' in to_keyring might get displaced πŸ‘€ (yes, like, evicted. sorry girl.)

flags is a bitwise-OR of zero or more of these:

  • KEYCTL_MOVE_EXCL β€” if there's already a matching key in to_keyring, don't displace it, just throw an error instead 🚫 (not me choosing violence, the function chooses it for you)

The caller must have write permission on both keyrings to be able to create or remove links in them πŸ”‘

And the caller must have link permission on a key to be able to create a new link to it, periodt.


πŸ’– RETURN VALUE πŸ’–

On success, keyctl_move() returns 0 β€” slay πŸŽ‰

On error, the value -1 gets returned and errno will have been set to an appropriate error 😭


πŸ’€ ERRORS πŸ’€

  • ENOKEY β€” the key, or one of the keyrings you specified, is invalid.
  • ENOKEY β€” a key with the same type and description is present in to_keyring and KEYCTL_MOVE_EXCL is set. (yes bestie, ENOKEY shows up twice, that's just how it is πŸ™ˆ)
  • EKEYEXPIRED β€” the key, or one of the keyrings you specified, has expired. RIP πŸͺ¦
  • EKEYREVOKED β€” the key, or one of the keyrings you specified, has been revoked.
  • EACCES β€” the key exists, but it's not linkable by the calling process.
  • EACCES β€” the keyrings exist, but they're not writable by the calling process.
  • ENOMEM β€” not enough memory to effect the changes 😡
  • EDQUOT β€” expanding to_keyring would exceed the keyring owner's quota.

πŸ”— LINKING πŸ”—

This is a library function, and it lives in libkeyutils 🫢

When you're linking, you gotta pass -lkeyutils to the linker. no cap.


πŸ‘‘ SEE ALSO πŸ‘‘

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


mwah πŸ’‹ that's the whole page β€” Linux, dated 29 May 2019, and the manpage is KEYCTL_MOVE(3). go move some keys, you absolute icon 🌈✨

πŸ“¦ where this page comes from