Merge branch 'less_closed'
[unleashed.git] / usr / src / man / man3tsol / setflabel.3tsol
blob5c4a5e8040718a012c3aacfd26bb47fdd46eb746
1 '\" te
2 .\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH SETFLABEL 3TSOL "Jul 20, 2007"
7 .SH NAME
8 setflabel \- move file to zone with corresponding sensitivity label
9 .SH SYNOPSIS
10 .LP
11 .nf
12 \fBcc\fR [\fIflag\fR...] \fIfile\fR... \fB-ltsol\fR [\fIlibrary\fR...]
13 .fi
15 .LP
16 .nf
17 #include <tsol/label.h>
19 \fBint\fR \fBsetflabel\fR(\fBconst char *\fR\fIpath\fR, \fBconst m_label_t *\fR\fIlabel_p\fR);
20 .fi
22 .SH DESCRIPTION
23 .sp
24 .LP
25 The file that is named by \fIpath\fR is relabeled by moving it to a new
26 pathname relative to the root directory of the zone corresponding to
27 \fIlabel_p\fR. If the source and destination file systems are loopback mounted
28 from the same underlying file system, the file is renamed. Otherwise, the file
29 is copied and removed from the source directory.
30 .sp
31 .LP
32 The \fBsetflabel()\fR function enforces the following policy checks:
33 .RS +4
34 .TP
35 .ie t \(bu
36 .el o
37 If the sensitivity label of \fIlabel_p\fR equals the existing sensitivity
38 label, then the file is not moved.
39 .RE
40 .RS +4
41 .TP
42 .ie t \(bu
43 .el o
44 If the corresponding directory does not exist in the destination zone, or if
45 the directory exists, but has a different label than \fIlabel_p\fR, the file is
46 not moved. Also, if the file already exists in the destination directory, the
47 file is not moved.
48 .RE
49 .RS +4
50 .TP
51 .ie t \(bu
52 .el o
53 If the sensitivity label of the existing file is not equal to the calling
54 process label and the caller is not in the global zone, then the file is not
55 moved. If the caller is in the global zone, the existing file label must be in
56 a labeled zone (not \fBADMIN_LOW\fR or \fBADMIN_HIGH\fR).
57 .RE
58 .RS +4
59 .TP
60 .ie t \(bu
61 .el o
62 If the calling process does not have write access to both the source and
63 destination directories, then the calling process must have
64 \fBPRIV_FILE_DAC_WRITE\fR in its set of effective privileges.
65 .RE
66 .RS +4
67 .TP
68 .ie t \(bu
69 .el o
70 If the sensitivity label of \fIlabel_p\fR provides read only access to the
71 existing sensitivity label (an upgrade), then the user must have the
72 \fBsolaris.label.file.upgrade\fR authorization. In addition, if the current
73 zone is a labeled zone, then it must have been assigned the privilege
74 \fBPRIV_FILE_UPGRADE_SL\fR when the zone was configured.
75 .RE
76 .RS +4
77 .TP
78 .ie t \(bu
79 .el o
80 If the sensitivity label of \fIlabel_p\fR does not provide access to the
81 existing sensitivity label (a downgrade), then the calling user must have the
82 \fBsolaris.label.file.downgrade\fR authorization. In addition, if the current
83 zone is a labeled zone, then it must have been assigned the privilege
84 \fBPRIV_FILE_DOWNGRADE_SL\fR when the zone was configured.
85 .RE
86 .RS +4
87 .TP
88 .ie t \(bu
89 .el o
90 If the calling process is not in the global zone, and the user does not have
91 the \fBsolaris.label.range\fR authorization, then \fIlabel_p\fR must be within
92 the user's label range and within the system accreditation range.
93 .RE
94 .RS +4
95 .TP
96 .ie t \(bu
97 .el o
98 If the existing file is in use (not tranquil) it is not moved. This tranquility
99 check does not cover race conditions nor remote file access.
103 Additional policy constraints can be implemented by customizing the shell
104 script \fB/etc/security/tsol/relabel\fR. See the comments in this file.
105 .SH RETURN VALUES
108 Upon successful completion, \fBsetflabel()\fR returns 0. Otherwise it returns
109 -1 and sets \fIerrno\fR to indicate the error.
110 .SH ERRORS
113 The \fBsetflabel()\fR function fails and the file is unchanged if:
115 .ne 2
117 \fB\fBEACCES\fR\fR
119 .RS 16n
120 Search permission is denied for a component of the path prefix of \fIpath\fR.
122 The calling process does not have mandatory write access to the final component
123 of path because the sensitivity label of the final component of path does not
124 dominate the sensitivity label of the calling  process and the calling process
125 does not have \fBPRIV_FILE_MAC_WRITE\fR in its set of effective privileges.
129 .ne 2
131 \fB\fBEBUSY\fR\fR
133 .RS 16n
134 There is an open file descriptor reference to the final component of
135 \fIpath\fR.
139 .ne 2
141 \fB\fBECONNREFUSED\fR\fR
143 .RS 16n
144 A connection to the label daemon could not be established.
148 .ne 2
150 \fB\fBEEXIST\fR\fR
152 .RS 16n
153 A file with the same name exists in the destination directory.
157 .ne 2
159 \fB\fBEINVAL\fR\fR
161 .RS 16n
162 Improper parameters were received by the label daemon.
166 .ne 2
168 \fB\fBEISDIR\fR\fR
170 .RS 16n
171 The existing file is a directory.
175 .ne 2
177 \fB\fBELOOP\fR\fR
179 .RS 16n
180 Too many symbolic links were encountered in translating \fIpath\fR.
184 .ne 2
186 \fB\fBEMLINK\fR\fR
188 .RS 16n
189 The existing file is hardlinked to another file.
193 .ne 2
195 \fB\fBENAMETOOLONG\fR\fR
197 .RS 16n
198 The length of the path argument exceeds \fIPATH_MAX\fR.
202 .ne 2
204 \fB\fBENOENT\fR\fR
206 .RS 16n
207 The file referred to by \fIpath\fR does not exist.
211 .ne 2
213 \fB\fBEROFS\fR\fR
215 .RS 16n
216 The file system is read-only or its label is \fBADMIN_LOW\fR or
217 \fBADMIN_HIGH\fR.
220 .SH ATTRIBUTES
223 See \fBattributes\fR(5) for descriptions of the following attributes:
228 box;
229 c | c
230 l | l .
231 ATTRIBUTE TYPE  ATTRIBUTE VALUE
233 Interface Stability     Committed
235 MT-Level        MT-Safe
238 .SH SEE ALSO
241 \fBlibtsol\fR(3LIB), \fBattributes\fR(5)
244 \fISetting a File Sensitivity Label\fR in \fISolaris Trusted Extensions
245 Developer\&'s Guide\fR
246 .SH NOTES
249 The functionality described on this manual page is available only if the system
250 is configured with Trusted Extensions.