xref: /freebsd/lib/libc/posix1e/mac_text.3 (revision f5463265955b829775bbb32e1fd0bc11dafc36ce)
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 September 21, 2023
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 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 .
63.Pp
64Refer to
65.Xr maclabel 7
66for the MAC label format.
67.Sh RETURN VALUES
68.Rv -std mac_from_text mac_to_text
69.Sh COMPATIBILITY
70POSIX.1e does not define
71a format for text representations
72of MAC labels.
73.Pp
74POSIX.1e requires that text strings allocated using
75.Fn mac_to_text
76be freed using
77.Xr mac_free 3 ;
78in the
79.Fx
80implementation, they must be freed using
81.Xr free 3 ,
82as
83.Xr mac_free 3
84is used only to free memory used for type
85.Vt mac_t .
86.Sh ERRORS
87.Bl -tag -width Er
88.It Bq Er ENOMEM
89Insufficient memory was available
90to allocate internal storage.
91.El
92.Sh SEE ALSO
93.Xr free 3 ,
94.Xr mac 3 ,
95.Xr mac_get 3 ,
96.Xr mac_is_present 3 ,
97.Xr mac_prepare 3 ,
98.Xr mac_set 3 ,
99.Xr posix1e 3 ,
100.Xr mac 4 ,
101.Xr maclabel 7
102.Sh STANDARDS
103POSIX.1e is described in IEEE POSIX.1e draft 17.
104.Sh HISTORY
105Support for Mandatory Access Control was introduced in
106.Fx 5.0
107as part of the
108.Tn TrustedBSD
109Project.
110