Add PIE compilation flags
[platform/upstream/keyutils.git] / keyctl_setperm.3
1 .\"
2 .\" Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
3 .\" Written by David Howells (dhowells@redhat.com)
4 .\"
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.
9 .\"
10 .TH KEYCTL_SETPERM 3 "4 May 2006" Linux "Linux Key Management Calls"
11 .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
12 .SH NAME
13 keyctl_setperm \- Change the permissions mask on a key
14 .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
15 .SH SYNOPSIS
16 .nf
17 .B #include <keyutils.h>
18 .sp
19 .BI "long keyctl_setperm(key_serial_t " key ", key_perm_t " perm ");"
20 .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
21 .SH DESCRIPTION
22 .BR keyctl_setperm ()
23 changes the permissions mask on a key.
24 .P
25 A process that does not have the
26 .B SysAdmin
27 capability may not change the permissions mask on a key that doesn't have the
28 same UID as the caller.
29 .P
30 The caller must have
31 .B setattr
32 permission on a key to be able change its permissions mask.
33 .P
34 The permissions mask is a bitwise-OR of the following flags:
35 .TP
36 .B KEY_xxx_VIEW
37 Grant permission to view the attributes of a key.
38 .TP
39 .B KEY_xxx_READ
40 Grant permission to read the payload of a key or to list a keyring.
41 .TP
42 .B KEY_xxx_WRITE
43 Grant permission to modify the payload of a key or to add or remove links
44 to/from a keyring.
45 .TP
46 .B KEY_xxx_SEARCH
47 Grant permission to find a key or to search a keyring.
48 .TP
49 .B KEY_xxx_LINK
50 Grant permission to make links to a key.
51 .TP
52 .B KEY_xxx_SETATTR
53 Grant permission to change the ownership and permissions attributes of a key.
54 .TP
55 .B KEY_xxx_ALL
56 Grant all the above.
57 .P
58 The
59 .RB ' xxx '
60 in the above should be replaced by one of:
61 .TP
62 .B POS
63 Grant the permission to a process that possesses the key (has it attached
64 searchably to one of the process's keyrings).
65 .TP
66 .B USR
67 Grant the permission to a process with the same UID as the key.
68 .TP
69 .B GRP
70 Grant the permission to a process with the same GID as the key, or with a
71 match for the key's GID amongst that process's Groups list.
72 .TP
73 .B OTH
74 Grant the permission to any other process.
75 .P
76 Examples include:
77 .BR KEY_POS_VIEW ", " KEY_USR_READ ", " KEY_GRP_SEARCH " and " KEY_OTH_ALL .
78 .P
79 User, group and other grants are exclusive: if a process qualifies in
80 the 'user' category, it will not qualify in the 'groups' category; and if a
81 process qualifies in either 'user' or 'groups' then it will not qualify in
82 the 'other' category.
83 .P
84 Possessor grants are cumulative with the grants from the 'user', 'groups'
85 and 'other' categories.
86 .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
87 .SH RETURN VALUE
88 On success
89 .BR keyctl_setperm ()
90 returns
91 .B 0 .
92 On error, the value
93 .B -1
94 will be returned and errno will have been set to an appropriate error.
95 .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
96 .SH ERRORS
97 .TP
98 .B ENOKEY
99 The specified key does not exist.
100 .TP
101 .B EKEYEXPIRED
102 The specified key has expired.
103 .TP
104 .B EKEYREVOKED
105 The specified key has been revoked.
106 .TP
107 .B EACCES
108 The named key exists, but does not grant
109 .B setattr
110 permission to the calling process.
111 .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
112 .SH LINKING
113 This is a library function that can be found in
114 .IR libkeyutils .
115 When linking,
116 .B -lkeyutils
117 should be specified to the linker.
118 .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
119 .SH SEE ALSO
120 .BR keyctl (1),
121 .br
122 .BR add_key (2),
123 .br
124 .BR keyctl (2),
125 .br
126 .BR request_key (2),
127 .br
128 .BR keyctl (3),
129 .br
130 .BR request-key (8)