KEYCTL_SET_TIMEOUT(2const)

NAME
KEYCTL_SET_TIMEOUT - set the expiration timer on a key

LIBRARY
Standard C library (libc, -lc)

SYNOPSIS
#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);

DESCRIPTION
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.

RETURN VALUE
On success, 0 is returned.

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

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

STANDARDS
Linux.

HISTORY
Linux 2.6.16.

SEE ALSO
keyctl(2), keyctl_set_timeout(3)