text
stringlengths
0
234
.br keyctl (1)
command's
.b instantiate
operation.
the arguments supplied to the
.b instantiate
operation are:
the id of the uninstantiated key
.ri ( %k );
the callout data supplied to the
.br request_key ()
call
.ri ( %c );
and the session keyring
.ri ( %s )
of the requestor (i.e., the caller of
.br request_key ()).
see
.br request\-key.conf (5)
for details of these
.i %
specifiers.
.pp
then we run the program and check the contents of
.ir /proc/keys
to verify that the requested key has been instantiated:
.pp
.in +4n
.ex
$ \fb./t_request_key user mtk:key1 "payload data"\fp
$ \fbgrep \(aq2dddaf50\(aq /proc/keys\fp
2dddaf50 i\-\-q\-\-\- 1 perm 3f010000 1000 1000 user mtk:key1: 12
.ee
.in
.pp
for another example of the use of this program, see
.br keyctl (2).
.ss program source
\&
.ex
/* t_request_key.c */
#include <sys/types.h>
#include <keyutils.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int
main(int argc, char *argv[])
{
key_serial_t key;
if (argc != 4) {
fprintf(stderr, "usage: %s type description callout\-data\en",
argv[0]);
exit(exit_failure);
}
key = request_key(argv[1], argv[2], argv[3],
key_spec_session_keyring);
if (key == \-1) {
perror("request_key");
exit(exit_failure);
}
printf("key id is %jx\en", (uintmax_t) key);
exit(exit_success);
}
.ee
.sh see also
.ad l
.nh
.br keyctl (1),
.br add_key (2),
.br keyctl (2),
.br keyctl (3),
.br capabilities (7),
.br keyrings (7),
.br keyutils (7),
.br persistent\-keyring (7),
.br process\-keyring (7),
.br session\-keyring (7),
.br thread\-keyring (7),
.br user\-keyring (7),
.br user\-session\-keyring (7),
.br request\-key (8)
.pp
the kernel source files
.ir documentation/security/keys/core.rst
and
.ir documentation/keys/request\-key.rst
(or, before linux 4.13, in the files
.\" commit b68101a1e8f0263dbc7b8375d2a7c57c6216fb76
.ir documentation/security/keys.txt
and
.\" commit 3db38ed76890565772fcca3279cc8d454ea6176b
.ir documentation/security/keys\-request\-key.txt ).