| 1 |
.\" Copyright 2016, Michael Kerrisk <[email protected]> |
| 2 |
.\" Copyright 2016, Eugene Syromyatnikov <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 6 |
.\" |
| 7 |
.TH KEYCTL_CLEAR 2const 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
KEYCTL_CLEAR |
| 10 |
\- |
| 11 |
clear a keyring |
| 12 |
.SH LIBRARY |
| 13 |
Standard C library |
| 14 |
.RI ( libc ,\~ \-lc ) |
| 15 |
.SH SYNOPSIS |
| 16 |
.nf |
| 17 |
.BR "#include <linux/keyctl.h>" " /* Definition of " KEY* " constants */" |
| 18 |
.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" |
| 19 |
.B #include <unistd.h> |
| 20 |
.P |
| 21 |
.BI "long syscall(SYS_keyctl, KEYCTL_CLEAR, key_serial_t " key ); |
| 22 |
.fi |
| 23 |
.SH DESCRIPTION |
| 24 |
Clear the contents of (i.e., unlink all keys from) a keyring. |
| 25 |
.P |
| 26 |
The ID of the key |
| 27 |
(which must be of keyring type) |
| 28 |
.\" or the error ENOTDIR results |
| 29 |
is provided in |
| 30 |
.IR key . |
| 31 |
.\" According to Documentation/security/keys/core.rst: |
| 32 |
.\" This function can also be used to clear special kernel keyrings if they |
| 33 |
.\" are appropriately marked if the user has CAP_SYS_ADMIN capability. The |
| 34 |
.\" DNS resolver cache keyring is an example of this. |
| 35 |
.P |
| 36 |
The caller must have |
| 37 |
.I write |
| 38 |
permission on the keyring. |
| 39 |
.SH RETURN VALUE |
| 40 |
On success, |
| 41 |
0 is returned. |
| 42 |
.P |
| 43 |
On error, \-1 is returned, and |
| 44 |
.I errno |
| 45 |
is set to indicate the error. |
| 46 |
.SH VERSIONS |
| 47 |
A wrapper is provided in the |
| 48 |
.I libkeyutils |
| 49 |
library: |
| 50 |
.BR keyctl_clear (3). |
| 51 |
.SH STANDARDS |
| 52 |
Linux. |
| 53 |
.SH HISTORY |
| 54 |
Linux 2.6.10. |
| 55 |
.SH SEE ALSO |
| 56 |
.BR keyctl (2), |
| 57 |
.BR keyctl_clear (3) |