text
stringlengths
0
234
* fetch key id for the request_key(2) destination keyring.
*/
dest_keyring = keyctl(keyctl_get_keyring_id,
key_spec_requestor_keyring);
if (dest_keyring == \-1) {
fprintf(fp, "keyctl_get_keyring_id failed: %s\en",
strerror(errno));
exit(exit_failure);
}
fprintf(fp, "destination keyring: %jx\en", (uintmax_t) dest_keyring);
/*
* fetch the description of the authorization key. this
* allows us to see the key type, uid, gid, permissions,
* and description (name) of the key. among other things,
* we will see that the name of the key is a hexadecimal
* string representing the id of the key to be instantiated.
*/
if (keyctl(keyctl_describe, key_spec_reqkey_auth_key,
dbuf, sizeof(dbuf)) == \-1) {
fprintf(fp, "keyctl_describe failed: %s\en", strerror(errno));
exit(exit_failure);
}
fprintf(fp, "auth key description: %s\en", dbuf);
/*
* instantiate the key using the callout data that was supplied
* in the payload of the authorization key.
*/
if (keyctl(keyctl_instantiate, key_to_instantiate,
auth_key_payload, akp_size + 1, dest_keyring) == \-1) {
fprintf(fp, "keyctl_instantiate failed: %s\en",
strerror(errno));
exit(exit_failure);
}
exit(exit_success);
}
.ee
.sh see also
.ad l
.nh
.br keyctl (1),
.br add_key (2),
.br request_key (2),
.\" .br find_key_by_type_and_name (3)
.\" there is a man page, but this function seems not to exist
.br keyctl (3),
.br keyctl_assume_authority (3),
.br keyctl_chown (3),
.br keyctl_clear (3),
.br keyctl_describe (3),
.br keyctl_describe_alloc (3),
.br keyctl_dh_compute (3),
.br keyctl_dh_compute_alloc (3),
.br keyctl_get_keyring_id (3),
.br keyctl_get_persistent (3),
.br keyctl_get_security (3),
.br keyctl_get_security_alloc (3),
.br keyctl_instantiate (3),
.br keyctl_instantiate_iov (3),
.br keyctl_invalidate (3),
.br keyctl_join_session_keyring (3),
.br keyctl_link (3),
.br keyctl_negate (3),
.br keyctl_read (3),
.br keyctl_read_alloc (3),
.br keyctl_reject (3),
.br keyctl_revoke (3),
.br keyctl_search (3),
.br keyctl_session_to_parent (3),
.br keyctl_set_reqkey_keyring (3),
.br keyctl_set_timeout (3),
.br keyctl_setperm (3),
.br keyctl_unlink (3),
.br keyctl_update (3),
.br recursive_key_scan (3),
.br recursive_session_key_scan (3),
.br capabilities (7),
.br credentials (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_namespaces (7),
.br user\-session\-keyring (7),
.br request\-key (8)
.pp
the kernel source files under
.ir documentation/security/keys/
(or, before linux 4.13, in the file
.ir documentation/security/keys.txt ).
.sh colophon
this page is part of release 5.13 of the linux
.i man-pages