File: KEYCTL_SEARCH.2const

package info (click to toggle)
manpages 6.15-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,184 kB
  • sloc: sh: 575; python: 222; perl: 190; makefile: 29; lisp: 22
file content (100 lines) | stat: -rw-r--r-- 2,612 bytes parent folder | download | duplicates (2)
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
.\" Copyright, the authors of the Linux man-pages project
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
.TH KEYCTL_SEARCH 2const 2025-05-17 "Linux man-pages (unreleased)"
.SH NAME
KEYCTL_SEARCH
\-
search a keyring for a key
.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_SEARCH, key_serial_t " src ,
.BI "             char *" type ", char *" desc ,
.BI "             unsigned long " dst );
.fi
.SH DESCRIPTION
Search for a key in a keyring tree,
returning its ID and optionally linking it to a specified keyring.
.P
The tree to be searched is specified by passing
the ID of the head keyring in
.IR src .
The search is performed breadth-first and recursively.
.P
The
.I type
and
.I desc
arguments specify the key to be searched for:
.I type
contains the key type
(a null-terminated character string up to 32 bytes in size,
including the terminating null byte), and
.I desc
contains the description of the key
(a null-terminated character string up to 4096 bytes in size,
including the terminating null byte).
.P
The source keyring must grant
.I search
permission to the caller.
When performing the recursive search, only keyrings that grant the caller
.I search
permission will be searched.
Only keys with for which the caller has
.I search
permission can be found.
.P
If the key is found, its ID is returned as the function result.
.P
If the key is found and
.I dst
is nonzero, then, subject to the same constraints and rules as
.BR KEYCTL_LINK (2const),
the key is linked into the keyring whose ID is specified in
.IR dst .
If the destination keyring specified in
.I dst
already contains a link to a key that has the same type and description,
then that link will be displaced by a link to
the key found by this operation.
.P
Instead of valid existing keyring IDs, the source
.RI ( src )
and destination
.RI ( dst )
keyrings can be one of the special keyring IDs listed under
.BR KEYCTL_GET_KEYRING_ID (2const).
.SH RETURN VALUE
On success,
the ID of the key that was found.
.P
On error, \-1 is returned, and
.I errno
is set to indicate the error.
.SH ERRORS
.TP
.B EINVAL
The size of the description in
.I desc
(including the terminating null byte) exceeded 4096 bytes.
.SH VERSIONS
A wrapper is provided in the
.I libkeyutils
library:
.BR keyctl_search (3).
.SH STANDARDS
Linux.
.SH HISTORY
Linux 2.6.10.
.SH SEE ALSO
.BR keyctl (2),
.BR keyctl_search (3)