termios.3: wfix
[man-pages.git] / man7 / persistent-keyring.7
blob48b81bc90dc6865e472bc08ce5918ead1ef4eed3
1 .\" Copyright (C) 2014 Red Hat, Inc. All Rights Reserved.
2 .\" Written by David Howells (dhowells@redhat.com)
3 .\"
4 .\" %%%LICENSE_START(GPLv2+_SW_ONEPARA)
5 .\" This program is free software; you can redistribute it and/or
6 .\" modify it under the terms of the GNU General Public License
7 .\" as published by the Free Software Foundation; either version
8 .\" 2 of the License, or (at your option) any later version.
9 .\" %%%LICENSE_END
10 .\"
11 .TH PERSISTENT-KEYRING 7 2020-08-13 Linux "Linux Programmer's Manual"
12 .SH NAME
13 persistent-keyring \- per-user persistent keyring
14 .SH DESCRIPTION
15 The persistent keyring is a keyring used to anchor keys on behalf of a user.
16 Each UID the kernel deals with has its own persistent keyring that
17 is shared between all threads owned by that UID.
18 The persistent keyring has a name (description) of the form
19 .I _persistent.<UID>
20 where
21 .I <UID>
22 is the user ID of the corresponding user.
23 .PP
24 The persistent keyring may not be accessed directly,
25 even by processes with the appropriate UID.
26 .\" FIXME The meaning of the preceding sentence isn't clear. What is meant?
27 Instead, it must first be linked to one of a process's keyrings,
28 before that keyring can access the persistent keyring
29 by virtue of its possessor permits.
30 This linking is done with the
31 .BR keyctl_get_persistent (3)
32 function.
33 .PP
34 If a persistent keyring does not exist when it is accessed by the
35 .BR keyctl_get_persistent (3)
36 operation, it will be automatically created.
37 .PP
38 Each time the
39 .BR keyctl_get_persistent (3)
40 operation is performed,
41 the persistent key's expiration timer is reset to the value in:
42 .PP
43     /proc/sys/kernel/keys/persistent_keyring_expiry
44 .PP
45 Should the timeout be reached,
46 the persistent keyring will be removed and
47 everything it pins can then be garbage collected.
48 The key will then be re-created on a subsequent call to
49 .BR keyctl_get_persistent (3).
50 .PP
51 The persistent keyring is not directly searched by
52 .BR request_key (2);
53 it is searched only if it is linked into one of the keyrings
54 that is searched by
55 .BR request_key (2).
56 .PP
57 The persistent keyring is independent of
58 .BR clone (2),
59 .BR fork (2),
60 .BR vfork (2),
61 .BR execve (2),
62 and
63 .BR _exit (2).
64 It persists until its expiration timer triggers,
65 at which point it is garbage collected.
66 This allows the persistent keyring to carry keys beyond the life of
67 the kernel's record of the corresponding UID
68 (the destruction of which results in the destruction of the
69 .BR user\-keyring (7)
70 and the
71 .BR user\-session\-keyring (7)).
72 The persistent keyring can thus be used to
73 hold authentication tokens for processes that run without user interaction,
74 such as programs started by
75 .BR cron (8).
76 .PP
77 The persistent keyring is used to store UID-specific objects that
78 themselves have limited lifetimes (e.g., kerberos tokens).
79 If those tokens cease to be used
80 (i.e., the persistent keyring is not accessed),
81 then the timeout of the persistent keyring ensures that
82 the corresponding objects are automatically discarded.
83 .\"
84 .SS Special operations
85 The
86 .I keyutils
87 library provides the
88 .BR keyctl_get_persistent (3)
89 function for manipulating persistent keyrings.
90 (This function is an interface to the
91 .BR keyctl (2)
92 .B KEYCTL_GET_PERSISTENT
93 operation.)
94 This operation allows the calling thread to get the persistent keyring
95 corresponding to its own UID or, if the thread has the
96 .BR CAP_SETUID
97 capability, the persistent keyring corresponding to some other UID
98 in the same user namespace.
99 .SH NOTES
100 Each user namespace owns a keyring called
101 .IR .persistent_register
102 that contains links to all of the persistent keys in that namespace.
103 (The
104 .IR .persistent_register
105 keyring can be seen when reading the contents of the
106 .IR /proc/keys
107 file for the UID 0 in the namespace.)
109 .BR keyctl_get_persistent (3)
110 operation looks for a key with a name of the form
111 .IR _persistent.<UID>
112 in that keyring,
113 creates the key if it does not exist, and links it into the keyring.
114 .SH SEE ALSO
115 .ad l
117 .BR keyctl (1),
118 .BR keyctl (3),
119 .BR keyctl_get_persistent (3),
120 .BR keyrings (7),
121 .BR process\-keyring (7),
122 .BR session\-keyring (7),
123 .BR thread\-keyring (7),
124 .BR user\-keyring (7),
125 .BR user\-session\-keyring (7)