KEYCTL\_MOVE(3) Linux Key Management Calls KEYCTL\_MOVE(3)

# [NAME](#NAME)

keyctl\_move - Move a key between keyrings

# [SYNOPSIS](#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](#DESCRIPTION)

**keyctl\_move**() atomically unlinks *key* from *from\_keyring* and links it into *to\_keyring* in a single operation. Depending on the flags set, a link to any matching key in to\_keyring may get displaced.

*flags* is a bitwise-OR of zero or more of the following flags:

[**KEYCTL\_MOVE\_EXCL**](#KEYCTL_MOVE_EXCL)

If there's a matching key in to\_keyring, don't displace it but rather return an error.

The caller must have **write** permission on both keyring to be able to create or remove links in them.

The caller must have **link** permission on a key to be able to create a new link to it.

# [RETURN VALUE](#RETURN_VALUE)

On success **keyctl\_move**() return **0**. On error, the value **-1** will be returned and *errno* will have been set to an appropriate error.

# [ERRORS](#ERRORS)

[**ENOKEY**](#ENOKEY)

The key or one of the keyrings specified are invalid.

[**ENOKEY**](#ENOKEY~2)

A key with the same type and description is present in to\_keyring and KEYCTL\_MOVE\_EXCL is set.

[**EKEYEXPIRED**](#EKEYEXPIRED)

The key or one of the keyrings specified have expired.

[**EKEYREVOKED**](#EKEYREVOKED)

The key or one of the keyrings specified have been revoked.

[**EACCES**](#EACCES)

The key exists, but is not **linkable** by the calling process.

[**EACCES**](#EACCES~2)

The keyrings exist, but are not **writable** by the calling process.

[**ENOMEM**](#ENOMEM)

Insufficient memory to effect the changes.

[**EDQUOT**](#EDQUOT)

Expanding to\_keyring would exceed the keyring owner's quota.

# [LINKING](#LINKING)

This is a library function that can be found in *libkeyutils*. When linking, **-lkeyutils** should be specified to the linker.

# [SEE ALSO](#SEE_ALSO)

[**keyctl**(1)](/man/os/keyutils/keyctl.1), [**add\_key**(2)](/man/os/keyutils/add_key.2), [**keyctl**(2)](/man/os/keyutils/keyctl.2), [**request\_key**(2)](/man/os/keyutils/request_key.2), [**keyctl**(3)](/man/os/keyutils/keyctl.3), [**keyrings**(7)](/man/os/keyutils/keyrings.7), [**keyutils**(7)](/man/os/keyutils/keyutils.7)

29 May 2019 Linux

---

Document: keyctl_move(3) from keyutils 1.6.3-r40 (Chainguard OS)
Source: https://kernel.googlesource.com/pub/scm/linux/kernel/git/dhowells/keyutils.git
