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