1KEYCTL_SEARCH(3)          Linux Key Management Calls          KEYCTL_SEARCH(3)
2
3
4

NAME

6       keyctl_search - Search a keyring for a key
7

SYNOPSIS

9       #include <keyutils.h>
10
11       long keyctl_search(key_serial_t keyring, const char *type,
12       const char *description, key_serial_t destination);
13

DESCRIPTION

15       keyctl_search() recursively searches the keyring for a key of the spec‐
16       ified type and description.
17
18       If found, the key will be  attached  to  the  destination  keyring  (if
19       given), and its serial number will be returned.
20
21       The  source keyring must grant search permission to the caller, and for
22       a key to be found, it must also grant search permission to the  caller.
23       Child  keyrings  will  be  only  be  recursively searched if they grant
24       search permission to the caller as well.
25
26       If the destination keyring is zero, no attempt will be made to forge  a
27       link to the key, and just the serial number will be returned.
28
29       If  the  destination keyring is given, then the link may only be formed
30       if the found key grants the caller link permission and the  destination
31       keyring grants the caller write permission.
32
33       If  the  search  is  successful, and if the destination keyring already
34       contains a link to a key that matches the specified type  and  descrip‐
35       tion, then that link will be replaced by a link to the found key.
36
37       The  source keyring and destination keyring serial numbers may be those
38       of valid keyrings to which the caller has  appropriate  permission,  or
39       they may be special keyring IDs:
40
41       KEY_SPEC_THREAD_KEYRING
42              This specifies the caller's thread-specific keyring.
43
44       KEY_SPEC_PROCESS_KEYRING
45              This specifies the caller's process-specific keyring.
46
47       KEY_SPEC_SESSION_KEYRING
48              This specifies the caller's session-specific keyring.
49
50       KEY_SPEC_USER_KEYRING
51              This specifies the caller's UID-specific keyring.
52
53       KEY_SPEC_USER_SESSION_KEYRING
54              This specifies the caller's UID-session keyring.
55

RETURN VALUE

57       On  success  keyctl_search()  returns  the  serial number of the key it
58       found.  On error, the value -1 will be returned  and  errno  will  have
59       been set to an appropriate error.
60

ERRORS

62       ENOKEY One  of  the  keyrings  doesn't  exist,  no key was found by the
63              search, or the only key found by the search was a negative key.
64
65       ENOTDIR
66              One of the keyrings is a valid key that isn't a keyring.
67
68       EKEYEXPIRED
69              One of the keyrings has expired,  or  the  only  key  found  was
70              expired.
71
72       EKEYREVOKED
73              One  of the keyrings has been revoked, or the only key found was
74              revoked.
75
76       ENOMEM Insufficient memory to expand the destination keyring.
77
78       EDQUOT The key quota for this user would be exceeded by creating a link
79              to the found key in the destination keyring.
80
81       EACCES The  source keyring didn't grant search permission, the destina‐
82              tion keyring didn't grant write  permission  or  the  found  key
83              didn't grant link permission to the caller.
84

LINKING

86       Although this is a Linux system call, it is not present in libc but can
87       be found rather in libkeyutils.  When  linking,  -lkeyutils  should  be
88       specified to the linker.
89

SEE ALSO

91       keyctl(1),
92       add_key(2),
93       keyctl(2),
94       request_key(2),
95       keyctl_get_keyring_ID(3),
96       keyctl_join_session_keyring(3),
97       keyctl_update(3),
98       keyctl_revoke(3),
99       keyctl_chown(3),
100       keyctl_setperm(3),
101       keyctl_describe(3),
102       keyctl_clear(3),
103       keyctl_link(3),
104       keyctl_unlink(3),
105       keyctl_read(3),
106       keyctl_instantiate(3),
107       keyctl_negate(3),
108       keyctl_set_reqkey_keyring(3),
109       keyctl_set_timeout(3),
110       keyctl_assume_authority(3),
111       keyctl_describe_alloc(3),
112       keyctl_read_alloc(3),
113       request-key(8)
114
115
116
117Linux                             4 May 2006                  KEYCTL_SEARCH(3)
Impressum