text
stringlengths
0
234
depends on the
.b lc_ctype
category of the
current locale.
.pp
passing null as
.i ps
is not multithread safe.
.sh see also
.br iconv (3),
.br mbrtowc (3),
.br mbsinit (3),
.br mbsnrtowcs (3),
.br mbstowcs (3)
.sh colophon
this page is part of release 5.13 of the linux
.i man-pages
project.
a description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
\%https://www.kernel.org/doc/man\-pages/.
.\" copyright (c) 2006 red hat, inc. all rights reserved.
.\" written by david howells (dhowells@redhat.com)
.\" and copyright (c) 2016 michael kerrisk <mtk.man-pages@gmail.com>
.\"
.\" %%%license_start(gplv2+_sw_onepara)
.\" 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.
.\" %%%license_end
.\"
.th request_key 2 2021-08-27 linux "linux key management calls"
.sh name
request_key \- request a key from the kernel's key management facility
.sh synopsis
.nf
.b #include <keyutils.h>
.pp
.bi "key_serial_t request_key(const char *" type ", const char *" description ,
.bi " const char *" callout_info ,
.bi " key_serial_t " dest_keyring ");"
.fi
.pp
.ir note :
there is no glibc wrapper for this system call; see notes.
.sh description
.br request_key ()
attempts to find a key of the given
.i type
with a description (name) that matches the specified
.ir description .
if such a key could not be found, then the key is optionally created.
if the key is found or created,
.br request_key ()
attaches it to the keyring whose id is specified in
.i dest_keyring
and returns the key's serial number.
.pp
.br request_key ()
first recursively searches for a matching key in all of the keyrings
attached to the calling process.
the keyrings are searched in the order: thread-specific keyring,
process-specific keyring, and then session keyring.
.pp
if
.br request_key ()
is called from a program invoked by
.br request_key ()
on behalf of some other process to generate a key, then the keyrings of that
other process will be searched next,
using that other process's user id, group id,
supplementary group ids, and security context to determine access.
.\" david howells: we can then have an arbitrarily long sequence
.\" of "recursive" request-key upcalls. there is no limit, other
.\" than number of pids, etc.
.pp
the search of the keyring tree is breadth-first:
the keys in each keyring searched are checked for a match before any child
keyrings are recursed into.
only keys for which the caller has
.i search
permission be found, and only keyrings for which the caller has
.i search
permission may be searched.
.pp
if the key is not found and
.i callout
is null, then the call fails with the error
.br enokey .
.pp
if the key is not found and
.i callout
is not null, then the kernel attempts to invoke a user-space
program to instantiate the key.
the details are given below.
.pp