xref: /freebsd/lib/libc/posix1e/mac_text.3 (revision c4f6a2a9e1b1879b618c436ab4f56ff75c73a0f5)
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.\" 3. The name of the author may not be used to endorse or promote
19.\"    products derived from this software without specific prior written
20.\"    permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\" $FreeBSD$
35.Dd December 21, 2001
36.Dt MAC_TEXT 3
37.Sh NAME
38.Nm mac_from_text ,
39.Nm mac_to_text
40.Nd convert MAC label to/from text representation
41.Sh LIBRARY
42.Lb libc
43.Sh SYNOPSIS
44.In sys/mac.h
45.Ft mac_t
46.Fn mac_from_text "const char *text_p"
47.Ft "char *"
48.Fn mac_to_text "mac_t label" "size_t *len_p"
49.Sh DESCRIPTION
50The
51.Fn mac_from_text
52function converts the text representation of a label
53into a
54.Vt mac_t ,
55which must later be freed with
56.Xr mac_free .
57The
58.Fn mac_to_text
59function returns
60the text representation of
61.Fa label
62and sets
63.Fa *len_p
64to the length of the returned string.
65.Pp
66.Fx
67uses the following format
68for MAC policy text representations:
69.Pp
70.Dl Sy policy Ns No / Ns Sy qualifier
71.Pp
72Where
73.Sy policy
74can be one of
75.Dq biba ,
76.Dq mls ,
77or
78.Dq te .
79.Pp
80Valid labels can have the following arguments for
81.Sy qualifier ,
82depending on the value of
83.Sy policy .
84.Bl -tag -width "Policy" -offset indent
85.It Em Policy
86.Em Qualifier
87.It biba
88.Dq high ,
89.Dq low ,
90.Dq equal ,
91or a numeric grade.
92.It mls
93.Dq high ,
94.Dq low ,
95.Dq equal ,
96or a numeric level.
97.It te
98Types for
99.Dq te
100consist of a type name which must
101neither be empty nor exceed the length limit for the label.
102.El
103.Pp
104All policies must be present
105in a comma-separated list,
106but may be in any order
107(see
108.Sx EXAMPLES ) .
109.Sh RETURN VALUES
110The
111.Fn mac_from_text
112function returns a valid
113.Vt mac_t
114equivalent to
115the MAC label described in
116.Fa text_p
117upon success, and
118.Dv NULL
119upon failure, setting
120.Va errno
121to indicate the error.
122.Pp
123The
124.Fn mac_to_text
125function returns a string
126containing the text representation of
127.Fa label
128upon success, and
129.Dv NULL
130upon failure, setting
131.Va errno
132to indicate the error.
133.Sh EXAMPLES
134The following are valid MAC labels:
135.Bd -literal -offset indent
136biba/high,mls/low,te/none
137biba/low,mls/low,te/none
138biba/low,mls/3,te/none
139.Ed
140.Sh COMPATIBILITY
141POSIX.1e does not define
142a text format for text representations
143of MAC labels.
144.Sh ERRORS
145.Bl -tag -width Er
146.It Bq Er EINVAL
147An invalid policy or qualifier
148was specified in
149.Fa text_p ,
150or an invalid MAC label
151was specified in
152.Fa label .
153.It Bq Er ENOMEM
154Insufficient memory was available
155to allocate internal storage.
156.El
157.Sh SEE ALSO
158.Xr mac 3 ,
159.Xr mac_free 3 ,
160.Xr mac_get 3 ,
161.Xr mac_set 3
162.Sh STANDARDS
163POSIX.1e is described in IEEE POSIX.1e draft 17.
164Discussion of the draft
165continues on the cross-platform POSIX.1e implementation mailing list.
166To join this list, see the
167.Fx
168POSIX.1e implementation page
169for more information.
170