KEYCTL_SET_TIMEOUT(2const) KEYCTL_SET_TIMEOUT(2const)

KEYCTL_SET_TIMEOUT - set the expiration timer on a key

Standard C library (libc-lc)

#include <linux/keyctl.h>  /* Definition of KEY* constants */
#include <sys/syscall.h>   /* Definition of SYS_* constants */
#include <unistd.h>
long syscall(SYS_keyctl, KEYCTL_SET_TIMEOUT, key_serial_t key, time_t t);

Set a timeout on a key.

The ID of the key is specified in key. The timeout value, in seconds from the current time, is specified in t. The timeout is measured against the realtime clock.

Specifying the timeout value as 0 clears any existing timeout on the key.

The /proc/keys file displays the remaining time until each key will expire. (This is the only method of discovering the timeout on a key.)

The caller must either have the setattr permission on the key or hold an instantiation authorization token for the key (see request_key(2)).

The key and any links to the key will be automatically garbage collected after the timeout expires. Subsequent attempts to access the key will then fail with the error EKEYEXPIRED.

This operation cannot be used to set timeouts on revoked, expired, or negatively instantiated keys.

On success, 0 is returned.

On error, -1 is returned, and errno is set to indicate the error.

A wrapper is provided in the libkeyutils library: keyctl_set_timeout(3).

Linux.

Linux 2.6.16.

keyctl(2), keyctl_set_timeout(3)

2024-08-21 Linux man-pages 6.10