1 .\" Copyright (C) 2014 Red Hat, Inc. All Rights Reserved.
2 .\" Written by David Howells (dhowells@redhat.com)
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.
11 .TH PERSISTENT-KEYRING 7 2020-08-13 Linux "Linux Programmer's Manual"
13 persistent-keyring \- per-user persistent keyring
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
22 is the user ID of the corresponding user.
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)
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.
39 .BR keyctl_get_persistent (3)
40 operation is performed,
41 the persistent key's expiration timer is reset to the value in:
43 /proc/sys/kernel/keys/persistent_keyring_expiry
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).
51 The persistent keyring is not directly searched by
53 it is searched only if it is linked into one of the keyrings
57 The persistent keyring is independent of
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
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
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.
84 .SS Special operations
88 .BR keyctl_get_persistent (3)
89 function for manipulating persistent keyrings.
90 (This function is an interface to the
92 .B KEYCTL_GET_PERSISTENT
94 This operation allows the calling thread to get the persistent keyring
95 corresponding to its own UID or, if the thread has the
97 capability, the persistent keyring corresponding to some other UID
98 in the same user namespace.
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.
104 .IR .persistent_register
105 keyring can be seen when reading the contents of the
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>
113 creates the key if it does not exist, and links it into the keyring.
119 .BR keyctl_get_persistent (3),
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)