1 .\" Copyright (C) 2006 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 REQUEST_KEY 2 2010-02-25 Linux "Linux Key Management Calls"
13 request_key \- request a key from the kernel's key management facility
16 .B #include <keyutils.h>
18 .BI "key_serial_t request_key(const char *" type ", const char *" description ,
19 .BI " const char *" callout_info ,
20 .BI " key_serial_t " keyring ");"
24 asks the kernel to find a key of the given
26 that matches the specified
28 and, if successful, to attach it to the nominated
30 and to return its serial number.
33 first recursively searches all the keyrings attached to the calling process in
34 the order thread-specific keyring, process-specific keyring and then session
35 keyring for a matching key.
39 is called from a program invoked by
41 on behalf of some other process to generate a key, then the keyrings of that
42 other process will be searched next, using that other process's UID, GID,
43 groups, and security context to control access.
45 The keys in each keyring searched are checked for a match before any child
46 keyrings are recursed into.
49 for the caller may be found, and only
51 keyrings may be searched.
53 If the key is not found, then, if
55 is set, this function will attempt to look further afield.
58 is passed to a user-space service such as
62 If that is unsuccessful also, then an error will be returned, and a temporary
63 negative key will be installed in the nominated
65 This will expire after a few seconds, but will cause subsequent
68 to fail until it does.
72 serial number may be that of a valid keyring to which the caller has write
73 permission, or it may be a special keyring ID:
75 .B KEY_SPEC_THREAD_KEYRING
76 This specifies the caller's thread-specific keyring.
78 .B KEY_SPEC_PROCESS_KEYRING
79 This specifies the caller's process-specific keyring.
81 .B KEY_SPEC_SESSION_KEYRING
82 This specifies the caller's session-specific keyring.
84 .B KEY_SPEC_USER_KEYRING
85 This specifies the caller's UID-specific keyring.
87 .B KEY_SPEC_USER_SESSION_KEYRING
88 This specifies the caller's UID-session keyring.
90 If a key is created, no matter whether it's a valid key or a negative key, it
91 will displace any other key of the same type and description from the
97 returns the serial number of the key it found.
98 On error, the value \-1
99 will be returned and errno will have been set to an appropriate error.
103 The keyring wasn't available for modification by the user.
106 The request was interrupted by a signal.
109 The key quota for this user would be exceeded by creating this key or linking
113 An expired key was found, but no replacement could be obtained.
116 The attempt to generate a new key was rejected.
119 A revoked key was found, but no replacement could be obtained.
122 Insufficient memory to create a key.
125 No matching key was found.
127 Although this is a Linux system call, it is not present in
129 but can be found rather in
133 should be specified to the linker.
140 This page is part of release 3.68 of the Linux
143 A description of the project,
144 information about reporting bugs,
145 and the latest version of this page,
147 \%http://www.kernel.org/doc/man\-pages/.