KEYCTL_CHOWN(2const) KEYCTL_CHOWN(2const)

KEYCTL_CHOWN - change the ownership of 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_CHOWN, key_serial_t key,
             uid_t uid, gid_t gid);

Change the ownership (user and group ID) of a key.

key contains the key ID. uid contains the new user ID (or -1 in case the user ID shouldn't be changed). gid contains the new group ID (or -1 in case the group ID shouldn't be changed).

The key must grant the caller setattr permission.

For the UID to be changed, or for the GID to be changed to a group the caller is not a member of, the caller must have the CAP_SYS_ADMIN capability (see capabilities(7)).

If the UID is to be changed, the new user must have sufficient quota to accept the key. The quota deduction will be removed from the old user to the new user should the UID be changed.

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_chown(3).

Linux.

Linux 2.6.10.

keyctl(2), keyctl_chown(3)

2024-08-21 Linux man-pages 6.10