1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
.\" Copyright, the authors of the Linux man-pages project
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
.TH KEYCTL_RESTRICT_KEYRING 2const 2025-05-17 "Linux man-pages (unreleased)"
.SH NAME
KEYCTL_RESTRICT_KEYRING
\-
restrict keys that may be linked to a keyring
.SH LIBRARY
Standard C library
.RI ( libc ,\~ \-lc )
.SH SYNOPSIS
.nf
.BR "#include <linux/keyctl.h>" " /* Definition of " KEY* " constants */"
.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */"
.B #include <unistd.h>
.P
.BI "long syscall(SYS_keyctl, KEYCTL_RESTRICT_KEYRING, key_serial_t " keyring ,
.BI " const char *_Nullable " type ", const char *" restriction );
.fi
.SH DESCRIPTION
Apply a key-linking restriction to the keyring with the ID provided in
.IR keyring .
The caller must have
.I setattr
permission on the key.
If
.I type
is NULL, any attempt to add a key to the keyring is blocked;
otherwise it contains a pointer to a string with a key type name and
.I restriction
contains a pointer to string that describes the type-specific restriction.
As of Linux 4.12, only the type "asymmetric" has restrictions defined:
.TP
.B builtin_trusted
Allows only keys that are signed by a key linked to the built-in keyring
(".builtin_trusted_keys").
.TP
.B builtin_and_secondary_trusted
Allows only keys that are signed by a key linked to the secondary keyring
(".secondary_trusted_keys") or, by extension, a key in a built-in keyring,
as the latter is linked to the former.
.TP
.BI key_or_keyring: key
.TQ
.BI key_or_keyring: key :chain
If
.I key
specifies the ID of a key of type "asymmetric",
then only keys that are signed by this key are allowed.
.IP
If
.I key
specifies the ID of a keyring,
then only keys that are signed by a key linked
to this keyring are allowed.
.IP
If ":chain" is specified, keys that are signed by a keys linked to the
destination keyring (that is, the keyring with the ID specified in the
.I keyring
argument) are also allowed.
.P
Note that a restriction can be configured only once for the specified keyring;
once a restriction is set, it can't be overridden.
.SH RETURN VALUE
On success,
0 is returned.
.P
On error, \-1 is returned, and
.I errno
is set to indicate the error.
.SH ERRORS
.TP
.B EDEADLK
The requested keyring restriction would result in a cycle.
.TP
.B EEXIST
.I keyring
already has a restriction set.
.TP
.B ENOENT
The type provided in
.I type
argument doesn't support setting key linking restrictions.
.TP
.B EOPNOTSUPP
.I type
was "asymmetric",
and the key specified in the restriction specification provided in
.I restriction
has type other than "asymmetric" or "keyring".
.SH VERSIONS
A wrapper is provided in the
.I libkeyutils
library:
.BR keyctl_restrict_keyring (3).
.SH STANDARDS
Linux.
.SH HISTORY
Linux 4.12.
.\" commit 6563c91fd645556c7801748f15bc727c77fcd311
.\" commit 7228b66aaf723a623e578aa4db7d083bb39546c9
.SH SEE ALSO
.BR keyctl (2),
.BR keyctl_restrict_keyring (3)
|