File: keyctl_instantiate.3

package info (click to toggle)
keyutils 1.2-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 288 kB
  • ctags: 197
  • sloc: ansic: 1,863; makefile: 149; sh: 13
file content (185 lines) | stat: -rw-r--r-- 5,529 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
.\"
.\" Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
.\" Written by David Howells (dhowells@redhat.com)
.\"
.\" This program is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU General Public License
.\" as published by the Free Software Foundation; either version
.\" 2 of the License, or (at your option) any later version.
.\"
.TH KEYCTL_INSTANTIATE 3 "4 May 2006" Linux "Linux Key Management Calls"
.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.SH NAME
keyctl_assume_authority \- Assume the authority to instantiate a key
keyctl_instantiate \- Instantiate a key
keyctl_negate \- Negatively instantiate a key
.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.SH SYNOPSIS
.nf
.B #include <keyutils.h>
.sp
.BI "long keyctl_assume_authority(key_serial_t " key ");"
.sp
.BI "long keyctl_instantiate(key_serial_t " key ", const char *" payload ,
.BI "size_t " plen ", key_serial_t " keyring ");"
.sp
.BI "long keyctl_negate(key_serial_t " key ", unsigned " timeout ,
.BI "key_serial_t " keyring ");"
.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.SH DESCRIPTION
.BR keyctl_assume_authority ()
assumes the authority for the calling thread to deal with and instantiate the
specified uninstantiated
.IR key .
.P
The calling thread must have the appopriate authorisation key resident in one
of its keyrings for this to succeed, and that authority must not have been
revoked.
.P
The authorising key is allocated by request_key() when it needs to invoke
userspace to generate a key for the requesting process.  This is then attached
to one of the keyrings of the userspace process to which the task of
instantiating the key is given:
.IP
requester -> request_key() -> instantiator
.P
Calling this function modifies the way
.BR request_key ()
works when called thereafter by the calling (instantiator) thread; once the
authority is assumed, the keyrings of the initial process are added to the
search path, using the initial process's UID, GID, groups and security
context.
.P
If a thread has multiple instantiations to deal with, it may call this
function to change the authorisation key currently in effect.  Supplying a
.B zero
.I key
de-assumes the currently assumed authority.
.P
.B NOTE!
This is a per-thread setting and not a per-process setting so that a
multithreaded process can be used to instantiate several keys at once.
.P
.BR keyctl_instantiate ()
instantiates the payload of an uninstantiated key from the data specified.
.I payload
and
.I plen
specify the data for the new payload.
.I payload
may be NULL and
.I plen
may be zero if the key type permits that.  The key type may reject the data if
it's in the wrong format or in some other way invalid.
.P
.BR keyctl_negate ()
marks a key as negatively instantiated and sets the expiration timer on it.
.I timeout
specifies the lifetime of the key in seconds.
.P
Only a key for which authority has been assumed may be instantiated or
negatively instantiated, and once instantiated, the authorisation key will be
revoked and the requesting process will be able to resume.
.P
The destination
.IR keyring ,
if given, is assumed to belong to the initial requester, and not the
instantiating process.  Therefore, the special keyring IDs refer to the
requesting process's keyrings, not the caller's, and the requester's UID,
etc. will be used to access them.
.P
The destination keyring can be
.B zero
if no extra link is desired.
.P
The requester, not the caller, must have
.B write
permission on the destination for a link to be made there.
.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.SH RETURN VALUE
On success
.BR keyctl_instantiate ()
returns
.BR 0 .
On error, the value
.B -1
will be returned and errno will have been set to an appropriate error.
.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.SH ERRORS
.TP
.B ENOKEY
The key or keyring specified is invalid.
.TP
.B EKEYEXPIRED
The keyring specified has expired.
.TP
.B EKEYREVOKED
The key or keyring specified had been revoked, or the authorisation has been
revoked.
.TP
.B EINVAL
The payload data was invalid.
.TP
.B ENOMEM
Insufficient memory to store the new payload or to expand the destination
keyring.
.TP
.B EDQUOT
The key quota for the key's user would be exceeded by increasing the size of
the key to accommodate the new payload or the key quota for the keyring's user
would be exceeded by expanding the destination keyring.
.TP
.B EACCES
The key exists, but is not
.B writable
by the requester.
.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.SH LINKING
This is a library function that can be found in
.IR libkeyutils .
When linking,
.B -lkeyutils
should be specified to the linker.
.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.SH SEE ALSO
.BR keyctl (1),
.br
.BR add_key (2),
.br
.BR keyctl (2),
.br
.BR request_key (2),
.br
.BR keyctl_get_keyring_ID (3),
.br
.BR keyctl_join_session_keyring (3),
.br
.BR keyctl_update (3),
.br
.BR keyctl_revoke (3),
.br
.BR keyctl_chown (3),
.br
.BR keyctl_setperm (3),
.br
.BR keyctl_describe (3),
.br
.BR keyctl_clear (3),
.br
.BR keyctl_link (3),
.br
.BR keyctl_unlink (3),
.br
.BR keyctl_search (3),
.br
.BR keyctl_read (3),
.br
.BR keyctl_set_reqkey_keyring (3),
.br
.BR keyctl_set_timeout (3),
.br
.BR keyctl_describe_alloc (3),
.br
.BR keyctl_read_alloc (3),
.br
.BR request-key (8)