2 .\" Copyright (c) 2013 The FreeBSD Foundation
4 .\" This documentation was written by Pawel Jakub Dawidek under sponsorship
5 .\" from the FreeBSD Foundation.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
16 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .Nd obtain capability rights
39 .Fn cap_rights_get "int fd" "cap_rights_t *rights"
43 function allows to obtain current capability rights for the given descriptor.
44 The function will fill the
46 argument with all capability rights if they were not limited or capability
47 rights configured during the last successful call of
48 .Xr cap_rights_limit 2
49 on the given descriptor.
53 argument can be inspected using
57 The complete list of the capability rights can be found in the
63 The following example demonstrates how to limit file descriptor capability
64 rights and how to obtain them.
66 cap_rights_t setrights, getrights;
69 memset(&setrights, 0, sizeof(setrights));
70 memset(&getrights, 0, sizeof(getrights));
72 fd = open("/tmp/foo", O_RDONLY);
74 err(1, "open() failed");
76 cap_rights_init(&setrights, CAP_FSTAT, CAP_READ);
77 if (cap_rights_limit(fd, &setrights) < 0 && errno != ENOSYS)
78 err(1, "cap_rights_limit() failed");
80 if (cap_rights_get(fd, &getrights) < 0 && errno != ENOSYS)
81 err(1, "cap_rights_get() failed");
83 assert(memcmp(&setrights, &getrights, sizeof(setrights)) == 0);
92 argument is not a valid active descriptor.
96 argument points at an invalid address.
99 .Xr cap_rights_limit 2 ,
103 .Xr cap_rights_init 3 ,
112 function first appeared in
114 Support for capabilities and capabilities mode was developed as part of the
118 This function was created by
119 .An Pawel Jakub Dawidek Aq Mt pawel@dawidek.net
120 under sponsorship of the FreeBSD Foundation.