xref: /freebsd/lib/libc/posix1e/mac_prepare.3 (revision b653faaa19c47a4a7e488e5ead738b7ae44ffe8b)
1bec8c3f9SRobert Watson.\" Copyright (c) 2002, 2003 Networks Associates Technology, Inc.
25bc8d712SChris Costello.\" All rights reserved.
35bc8d712SChris Costello.\"
45bc8d712SChris Costello.\" This software was developed for the FreeBSD Project by Chris
55bc8d712SChris Costello.\" Costello at Safeport Network Services and Network Associates Labs,
65bc8d712SChris Costello.\" the Security Research Division of Network Associates, Inc. under
75bc8d712SChris Costello.\" DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
85bc8d712SChris Costello.\" DARPA CHATS research program.
95bc8d712SChris Costello.\"
105bc8d712SChris Costello.\" Redistribution and use in source and binary forms, with or without
115bc8d712SChris Costello.\" modification, are permitted provided that the following conditions
125bc8d712SChris Costello.\" are met:
135bc8d712SChris Costello.\" 1. Redistributions of source code must retain the above copyright
145bc8d712SChris Costello.\"    notice, this list of conditions and the following disclaimer.
155bc8d712SChris Costello.\" 2. Redistributions in binary form must reproduce the above copyright
165bc8d712SChris Costello.\"    notice, this list of conditions and the following disclaimer in the
175bc8d712SChris Costello.\"    documentation and/or other materials provided with the distribution.
185bc8d712SChris Costello.\"
195bc8d712SChris Costello.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
205bc8d712SChris Costello.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
215bc8d712SChris Costello.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
225bc8d712SChris Costello.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
235bc8d712SChris Costello.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
245bc8d712SChris Costello.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
255bc8d712SChris Costello.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
265bc8d712SChris Costello.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
275bc8d712SChris Costello.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
285bc8d712SChris Costello.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
295bc8d712SChris Costello.\" SUCH DAMAGE.
305bc8d712SChris Costello.\"
31*b653faaaSDag-Erling Smørgrav.Dd September 21, 2023
325bc8d712SChris Costello.Dt MAC_PREPARE 3
33aa12cea2SUlrich Spörlein.Os
345bc8d712SChris Costello.Sh NAME
35bec8c3f9SRobert Watson.Nm mac_prepare , mac_prepare_type , mac_prepare_file_label ,
36ace5be68SRuslan Ermilov.Nm mac_prepare_ifnet_label , mac_prepare_process_label
37ace5be68SRuslan Ermilov.Nd allocate appropriate storage for
38ace5be68SRuslan Ermilov.Vt mac_t
395bc8d712SChris Costello.Sh SYNOPSIS
40ace5be68SRuslan Ermilov.In sys/mac.h
415bc8d712SChris Costello.Ft int
42bec8c3f9SRobert Watson.Fn mac_prepare "mac_t *mac" "const char *elements"
43bec8c3f9SRobert Watson.Ft int
44bec8c3f9SRobert Watson.Fn mac_prepare_type "mac_t *mac" "const char *name"
455bc8d712SChris Costello.Ft int
465bc8d712SChris Costello.Fn mac_prepare_file_label "mac_t *mac"
475bc8d712SChris Costello.Ft int
485bc8d712SChris Costello.Fn mac_prepare_ifnet_label "mac_t *mac"
495bc8d712SChris Costello.Ft int
505bc8d712SChris Costello.Fn mac_prepare_process_label "mac_t *mac"
515bc8d712SChris Costello.Sh DESCRIPTION
525bc8d712SChris CostelloThe
535bc8d712SChris Costello.Nm
545bc8d712SChris Costellofamily of functions allocates the appropriate amount of storage and initializes
555bc8d712SChris Costello.Fa *mac
565bc8d712SChris Costellofor use by
575bc8d712SChris Costello.Xr mac_get 3 .
58bec8c3f9SRobert WatsonWhen the resulting label is passed into the
59bec8c3f9SRobert Watson.Xr mac_get 3
60bec8c3f9SRobert Watsonfunctions, the kernel will attempt to fill in the label elements specified
61bec8c3f9SRobert Watsonwhen the label was prepared.
621c70a91bSXin LIElements are specified in a nul-terminated string, using commas to
63bec8c3f9SRobert Watsondelimit fields.
64bec8c3f9SRobert WatsonElement names may be prefixed with the
6535471bf8SJoel Dahl.Ql \&?
66bec8c3f9SRobert Watsoncharacter to indicate that a failure by the kernel to retrieve that
67bec8c3f9SRobert Watsonelement should not be considered fatal.
685bc8d712SChris Costello.Pp
695bc8d712SChris CostelloThe
705bc8d712SChris Costello.Fn mac_prepare
71ace5be68SRuslan Ermilovfunction accepts a list of policy names as a parameter, and allocates the
725bc8d712SChris Costellostorage to fit those label elements accordingly.
73bec8c3f9SRobert WatsonThe remaining functions in the family make use of system defaults defined
74bec8c3f9SRobert Watsonin
75bec8c3f9SRobert Watson.Xr mac.conf 5
76bec8c3f9SRobert Watsoninstead of an explicit
77bec8c3f9SRobert Watson.Va elements
78bec8c3f9SRobert Watsonargument, deriving the default from the specified object type.
795bc8d712SChris Costello.Pp
80bec8c3f9SRobert Watson.Fn mac_prepare_type
81bec8c3f9SRobert Watsonallocates the storage to fit an object label of the type specified by
82bec8c3f9SRobert Watsonthe
83bec8c3f9SRobert Watson.Va name
84bec8c3f9SRobert Watsonargument.
855bc8d712SChris CostelloThe
865bc8d712SChris Costello.Fn mac_prepare_file_label ,
875bc8d712SChris Costello.Fn mac_prepare_ifnet_label ,
885bc8d712SChris Costelloand
895bc8d712SChris Costello.Fn mac_prepare_process_label
906fb9b618SGiorgos Keramidasfunctions are equivalent to invocations of
91bec8c3f9SRobert Watson.Fn mac_prepare_type
92bec8c3f9SRobert Watsonwith arguments of
93bec8c3f9SRobert Watson.Qq file ,
94bec8c3f9SRobert Watson.Qq ifnet ,
95bec8c3f9SRobert Watsonand
96bec8c3f9SRobert Watson.Qq process
97bec8c3f9SRobert Watsonrespectively.
985bc8d712SChris Costello.Sh RETURN VALUES
99ace5be68SRuslan Ermilov.Rv -std
1005bc8d712SChris Costello.Sh SEE ALSO
1015bc8d712SChris Costello.Xr mac 3 ,
1025bc8d712SChris Costello.Xr mac_free 3 ,
1035bc8d712SChris Costello.Xr mac_get 3 ,
1041e5294bcSRobert Watson.Xr mac_is_present 3 ,
1055bc8d712SChris Costello.Xr mac_set 3 ,
1065bc8d712SChris Costello.Xr mac 4 ,
1078aa884cbSRobert Watson.Xr mac.conf 5 ,
1085bc8d712SChris Costello.Xr maclabel 7
1095bc8d712SChris Costello.Sh STANDARDS
1105bc8d712SChris CostelloPOSIX.1e is described in IEEE POSIX.1e draft 17.
111bec8c3f9SRobert Watson.Sh HISTORY
112bec8c3f9SRobert WatsonSupport for Mandatory Access Control was introduced in
113bec8c3f9SRobert Watson.Fx 5.0
114bec8c3f9SRobert Watsonas part of the
115bec8c3f9SRobert Watson.Tn TrustedBSD
116bec8c3f9SRobert WatsonProject.
117bec8c3f9SRobert WatsonSupport for generic object types first appeared in
118bec8c3f9SRobert Watson.Fx 5.2 .
119