xref: /freebsd/lib/libc/posix1e/mac_text.3 (revision 51e8e8b0f36933814b1be08913857727876aece5)
1.\" Copyright (c) 2001 Networks Associates Technology, Inc.
2.\" All rights reserved.
3.\"
4.\" This software was developed for the FreeBSD Project by Chris
5.\" Costello at Safeport Network Services and NAI Labs, the Security
6.\" Research Division of Network Associates, Inc. under DARPA/SPAWAR
7.\" contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS
8.\" research program.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\" 1. Redistributions of source code must retain the above copyright
14.\"    notice, this list of conditions and the following disclaimer.
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\"    notice, this list of conditions and the following disclaimer in the
17.\"    documentation and/or other materials provided with the distribution.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.Dd October 26, 2025
32.Dt MAC_TEXT 3
33.Os
34.Sh NAME
35.Nm mac_from_text ,
36.Nm mac_to_text
37.Nd convert MAC label to/from text representation
38.Sh LIBRARY
39.Lb libc
40.Sh SYNOPSIS
41.In sys/mac.h
42.Ft int
43.Fn mac_from_text "mac_t *mac" "const char *text"
44.Ft int
45.Fn mac_to_text "mac_t label" "char **text"
46.Sh DESCRIPTION
47The
48.Fn mac_from_text
49function converts the text representation of a label
50into the internal policy label format
51.Pq Vt mac_t
52and places it in
53.Fa *mac ,
54which must later be freed with
55.Xr mac_free 3 .
56.Pp
57The
58.Fn mac_to_text
59function allocates storage for
60.Fa *text ,
61which will be set to the text representation of
62.Fa label
63and must later be freed with
64.Xr free 3 .
65.Pp
66Refer to
67.Xr maclabel 7
68for the MAC label format.
69.Sh RETURN VALUES
70.Rv -std mac_from_text mac_to_text
71.Sh COMPATIBILITY
72POSIX.1e does not define
73a format for text representations
74of MAC labels.
75.Pp
76POSIX.1e requires that text strings allocated using
77.Fn mac_to_text
78be freed using
79.Xr mac_free 3 ;
80in the
81.Fx
82implementation, they must be freed using
83.Xr free 3 ,
84as
85.Xr mac_free 3
86is used only to free memory used for type
87.Vt mac_t .
88.Sh ERRORS
89.Bl -tag -width Er
90.It Bq Er ENOMEM
91Insufficient memory was available
92to allocate internal storage.
93.El
94.Sh SEE ALSO
95.Xr free 3 ,
96.Xr mac 3 ,
97.Xr mac_get 3 ,
98.Xr mac_is_present 3 ,
99.Xr mac_prepare 3 ,
100.Xr mac_set 3 ,
101.Xr posix1e 3 ,
102.Xr mac 4 ,
103.Xr maclabel 7
104.Sh STANDARDS
105POSIX.1e is described in IEEE POSIX.1e draft 17.
106.Sh HISTORY
107Support for Mandatory Access Control was introduced in
108.Fx 5.0
109as part of the
110.Tn TrustedBSD
111Project.
112