]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libcasper/libcasper/libcasper_service.3
Import device-tree files from Linux 6.2
[FreeBSD/FreeBSD.git] / lib / libcasper / libcasper / libcasper_service.3
1 .\" Copyright (c) 2018 Mariusz Zaborski <oshogbo@FreeBSD.org>
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .\"
25 .\" $FreeBSD$
26 .\"
27 .Dd November 15, 2021
28 .Dt LIBCASPER 3
29 .Os
30 .Sh NAME
31 .Nm CREATE_SERVICE
32 .Nd "casper service declaration macro"
33 .Sh LIBRARY
34 .Lb libcasper
35 .Sh SYNOPSIS
36 .In sys/nv.h
37 .In libcasper.h
38 .In libcasper_service.h
39 .Bd -literal
40 typedef int service_limit_func_t(const nvlist_t *, const nvlist_t *);
41
42 typedef int service_command_func_t(const char *, const nvlist_t *, nvlist_t *,
43     nvlist_t *);
44
45 .Ed
46 .Fn CREATE_SERVICE "name" "limit_func" "command_func" "flags"
47 .Sh DESCRIPTION
48 The
49 .Nm CREATE_SERVICE
50 macro is used to create a new casper service.
51 The
52 .Fa name
53 is a string containing the service name, which will be used in the
54 .Xr cap_service_open 3 ,
55 function to identify it.
56 .Pp
57 The
58 .Fa limit_func
59 is a function of type
60 .Li service_limit_func_t
61 where the first argument of the function contains an
62 .Xr nvlist 9 ,
63 old service limits and
64 the second argument contains the new limits.
65 If the service was not limited then the old limits will be set to
66 .Dv NULL .
67 This function must not allow the extension of service limits.
68 The
69 .Fa command_func
70 is a function of type
71 .Li service_command_func_t
72 where the first argument is the name of the command that should be executed.
73 The first
74 .Xr nvlist 9
75 contains the current limits and the second contains an
76 .Xr nvlist 9
77 with the current request.
78 The last argument contains a return value
79 .Xr nvlist 9
80 which contains the response from casper.
81 .Pp
82 The
83 .Fa flags
84 argument defines the limits of the service.
85 The supported flags are:
86 .Bl -ohang -offset indent
87 .It CASPER_SERVICE_STDIO
88 The casper service has access to the stdio descriptors from the process it was
89 spawned from.
90 .It CASPER_SERVICE_FD
91 The casper service has access to all of the descriptors,
92 besides the stdio descriptors,
93 from the process it was spawned from.
94 .It CASPER_SERVICE_NO_UNIQ_LIMITS
95 The whole casper communication is using an
96 .Xr nvlist 9
97 with the
98 .Dv NV_FLAG_NO_UNIQUE
99 flag.
100 .El
101 .Sh SEE ALSO
102 .Xr cap_enter 2 ,
103 .Xr libcasper 3 ,
104 .Xr capsicum 4 ,
105 .Xr nv 9
106 .Sh HISTORY
107 The
108 .Nm libcasper
109 library first appeared in
110 .Fx 10.3 .
111 .Sh AUTHORS
112 The
113 .Nm libcasper
114 library was implemented by
115 .An Pawel Jakub Dawidek Aq Mt pawel@dawidek.net
116 under sponsorship from the FreeBSD Foundation.
117 The
118 .Nm libcasper
119 new architecture was implemented by
120 .An Mariusz Zaborski Aq Mt oshogbo@FreeBSD.org
121 .