---
name: "keyctl_set_reqkey_keyring"
section: "3"
platform: "linux"
package: "keyutils"
version: "1.6.3-4"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/keyctl_set_reqkey_keyring"
---

# keyctl\_set\_reqkey\_keyring(3)

set the implicit destination keyring

## NAME

keyctl\_set\_reqkey\_keyring - set the implicit destination keyring

## SYNOPSIS

```
#include <keyutils.h>

long keyctl_set_reqkey_keyring(int reqkey_defl);
```

## DESCRIPTION

**keyctl\_set\_reqkey\_keyring**() sets the default destination for implicit key requests for the current thread and returns the old setting.

After this operation has been issued, keys acquired by implicit key requests, such as might be performed by **open**() on an AFS or NFS filesystem, will be linked by default to the specified keyring by this function.

The valid values of *reqkey\_defl* are:

- **KEY\_REQKEY\_DEFL\_NO\_CHANGE**

  This makes no change to the current setting.

- **KEY\_REQKEY\_DEFL\_THREAD\_KEYRING**

  This makes the thread-specific keyring the default destination.

- **KEY\_REQKEY\_DEFL\_PROCESS\_KEYRING**

  This makes the process-specific keyring the default destination.

- **KEY\_REQKEY\_DEFL\_SESSION\_KEYRING**

  This makes the session keyring the default destination.

- **KEY\_REQKEY\_DEFL\_USER\_KEYRING**

  This makes the UID-specific keyring the default destination.

- **KEY\_REQKEY\_DEFL\_USER\_SESSION\_KEYRING**

  This makes the UID-specific session keyring the default destination.

- **KEY\_REQKEY\_DEFL\_DEFAULT**

  This selects the default behaviour which is to use the thread-specific keyring if there is one, otherwise the process-specific keyring if there is one, otherwise the session keyring if there is one, otherwise the UID-specific session keyring.

This setting is inherited across **fork**() and **exec**().

## RETURN VALUE

On success **keyctl\_set\_reqkey\_keyring**() returns the serial number of the keyring which was the previous default for the current thread. On error, the value **-1** will be returned and *errno* will have been set to an appropriate error.

## ERRORS

- **EINVAL**

  The value of *reqkey\_defl* is invalid.

## LINKING

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

## SEE ALSO

[**keyctl**(1)](/keyctl/1.md), [**add\_key**(2)](/add_key/2.md), [**keyctl**(2)](/keyctl/2.md), [**request\_key**(2)](/request_key/2.md), [**keyctl**(3)](/keyctl/3.md), [**keyutils**(7)](/keyutils/7.md), [**keyrings**(7)](/keyrings/7.md), [**request-key**(8)](/request-key/8.md)
