xref: /freebsd/lib/libc/posix1e/mac_set.3 (revision 2efeeba554cbd7bdee9cfe17641c8bd335c7972f)
1d97fcfceSRobert Watson.\" Copyright (c) 2001 Networks Associates Technology, Inc.
2d97fcfceSRobert Watson.\" All rights reserved.
3d97fcfceSRobert Watson.\"
4d97fcfceSRobert Watson.\" This software was developed for the FreeBSD Project by Chris
5d97fcfceSRobert Watson.\" Costello at Safeport Network Services and NAI Labs, the Security
6d97fcfceSRobert Watson.\" Research Division of Network Associates, Inc. under DARPA/SPAWAR
7d97fcfceSRobert Watson.\" contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS
8d97fcfceSRobert Watson.\" research program.
9d97fcfceSRobert Watson.\"
10d97fcfceSRobert Watson.\" Redistribution and use in source and binary forms, with or without
11d97fcfceSRobert Watson.\" modification, are permitted provided that the following conditions
12d97fcfceSRobert Watson.\" are met:
13d97fcfceSRobert Watson.\" 1. Redistributions of source code must retain the above copyright
14d97fcfceSRobert Watson.\"    notice, this list of conditions and the following disclaimer.
15d97fcfceSRobert Watson.\" 2. Redistributions in binary form must reproduce the above copyright
16d97fcfceSRobert Watson.\"    notice, this list of conditions and the following disclaimer in the
17d97fcfceSRobert Watson.\"    documentation and/or other materials provided with the distribution.
18d97fcfceSRobert Watson.\" 3. The name of the author may not be used to endorse or promote
19d97fcfceSRobert Watson.\"    products derived from this software without specific prior written
20d97fcfceSRobert Watson.\"    permission.
21d97fcfceSRobert Watson.\"
22d97fcfceSRobert Watson.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
23d97fcfceSRobert Watson.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24d97fcfceSRobert Watson.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25d97fcfceSRobert Watson.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
26d97fcfceSRobert Watson.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27d97fcfceSRobert Watson.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28d97fcfceSRobert Watson.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29d97fcfceSRobert Watson.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30d97fcfceSRobert Watson.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31d97fcfceSRobert Watson.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32d97fcfceSRobert Watson.\" SUCH DAMAGE.
33d97fcfceSRobert Watson.\"
34d97fcfceSRobert Watson.\" $FreeBSD$
353b296920SRuslan Ermilov.\"
36d97fcfceSRobert Watson.Dd December 21, 2001
37d97fcfceSRobert Watson.Dt MAC_SET 3
38051bb54bSRuslan Ermilov.Os
39d97fcfceSRobert Watson.Sh NAME
40d97fcfceSRobert Watson.Nm mac_set_file ,
41d97fcfceSRobert Watson.Nm mac_set_fd ,
42d97fcfceSRobert Watson.Nm mac_set_proc
43d97fcfceSRobert Watson.Nd set the MAC label for a file or process
44d97fcfceSRobert Watson.Sh LIBRARY
45d97fcfceSRobert Watson.Lb libc
46d97fcfceSRobert Watson.Sh SYNOPSIS
47d97fcfceSRobert Watson.In sys/mac.h
48d97fcfceSRobert Watson.Ft int
49d97fcfceSRobert Watson.Fn mac_set_file "const char *path_p" "mac_t label"
50d97fcfceSRobert Watson.Ft int
51d97fcfceSRobert Watson.Fn mac_set_fd "int fd" "mac_t label"
52d97fcfceSRobert Watson.Ft int
53d97fcfceSRobert Watson.Fn mac_set_proc "mac_t label"
54d97fcfceSRobert Watson.Sh DESCRIPTION
55d97fcfceSRobert WatsonThe
56d97fcfceSRobert Watson.Fn mac_set_file
57d97fcfceSRobert Watsonand
58d97fcfceSRobert Watson.Fn mac_set_fd
59d97fcfceSRobert Watsonfunctions associate a MAC label
60d97fcfceSRobert Watsonspecified by
61d97fcfceSRobert Watson.Fa label
62d97fcfceSRobert Watsonto the file referenced to by
63d97fcfceSRobert Watson.Fa path_p ,
64d97fcfceSRobert Watsonor to the file descriptor
65d97fcfceSRobert Watson.Fa fd ,
663b296920SRuslan Ermilovrespectively.
673b296920SRuslan ErmilovNote that this function will fail on socket descriptors.
683b296920SRuslan ErmilovFor information on
69d97fcfceSRobert Watsonsetting MAC labels on socket descriptors see
70d97fcfceSRobert Watson.Xr setsockopt 2 .
71d97fcfceSRobert WatsonThe
72d97fcfceSRobert Watson.Fn mac_set_proc
73d97fcfceSRobert Watsonfunction associates the MAC label
74d97fcfceSRobert Watsonspecified by
75d97fcfceSRobert Watson.Fa label
76d97fcfceSRobert Watsonto the calling process.
77d97fcfceSRobert Watson.Pp
78d97fcfceSRobert WatsonA process is allowed to set a label for a file
79d97fcfceSRobert Watsononly if it has MAC write access to the file,
803b296920SRuslan Ermilovand its effective user ID is equal to
81d97fcfceSRobert Watsonthe owner of the file,
82d97fcfceSRobert Watsonor has appropriate privileges.
83d97fcfceSRobert Watson.Sh RETURN VALUES
84d97fcfceSRobert Watson.Rv -std mac_set_fd mac_set_file mac_set_proc
85d97fcfceSRobert Watson.Sh ERRORS
86d97fcfceSRobert Watson.Bl -tag -width Er
87d97fcfceSRobert Watson.It Bq Er EACCES
88d97fcfceSRobert WatsonMAC write access to the file is denied.
89d97fcfceSRobert Watson.It Bq Er EBADF
902efeeba5SRuslan ErmilovThe
91d97fcfceSRobert Watson.Fa fd
922efeeba5SRuslan Ermilovargument
93d97fcfceSRobert Watsonis not a valid file descriptor.
94d97fcfceSRobert Watson.It Bq Er EINVAL
952efeeba5SRuslan ErmilovThe
96d97fcfceSRobert Watson.Fa label
972efeeba5SRuslan Ermilovargument
98d97fcfceSRobert Watsonis not a valid MAC label.
99d97fcfceSRobert Watson.It Bq Er EOPNOTSUPP
100d97fcfceSRobert WatsonSetting MAC labels is not supported
101d97fcfceSRobert Watsonby the file referenced by
102d97fcfceSRobert Watson.Fa fd .
103d97fcfceSRobert Watson.It Bq Er EPERM
104d97fcfceSRobert WatsonThe calling process had insufficient privelege
105d97fcfceSRobert Watsonto change the MAC label.
106d97fcfceSRobert Watson.It Bq Er EROFS
107d97fcfceSRobert WatsonFile system for the object being modified
108d97fcfceSRobert Watsonis read only.
109d97fcfceSRobert Watson.It Bq Er ENAMETOOLONG
110d97fcfceSRobert Watson.\" XXX POSIX_NO_TRUNC?
111d97fcfceSRobert WatsonThe length of the pathname in
112d97fcfceSRobert Watson.Fa path_p
113d97fcfceSRobert Watsonexceeds
114d97fcfceSRobert Watson.Dv PATH_MAX ,
115d97fcfceSRobert Watsonor a component of the pathname
116d97fcfceSRobert Watsonis longer than
117d97fcfceSRobert Watson.Dv NAME_MAX .
118d97fcfceSRobert Watson.It Bq Er ENOENT
119d97fcfceSRobert WatsonThe file referenced by
120d97fcfceSRobert Watson.Fa path_p
121d97fcfceSRobert Watsondoes not exist.
122d97fcfceSRobert Watson.It Bq Er ENOTDIR
123d97fcfceSRobert WatsonA component of the pathname
124d97fcfceSRobert Watsonreferenced by
125d97fcfceSRobert Watson.Fa path_p
126d97fcfceSRobert Watsonis not a directory.
1273b296920SRuslan Ermilov.El
128d97fcfceSRobert Watson.Sh SEE_ALSO
129d97fcfceSRobert Watson.Xr mac 3 ,
130d97fcfceSRobert Watson.Xr mac_free 3 ,
1313b296920SRuslan Ermilov.Xr mac_get 3 ,
1323b296920SRuslan Ermilov.Xr mac_text 3
133