xref: /illumos-gate/usr/src/lib/libc/port/sys/label.c (revision 1da57d55)
145916cd2Sjpk /*
245916cd2Sjpk  * CDDL HEADER START
345916cd2Sjpk  *
445916cd2Sjpk  * The contents of this file are subject to the terms of the
545916cd2Sjpk  * Common Development and Distribution License (the "License").
645916cd2Sjpk  * You may not use this file except in compliance with the License.
745916cd2Sjpk  *
845916cd2Sjpk  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
945916cd2Sjpk  * or http://www.opensolaris.org/os/licensing.
1045916cd2Sjpk  * See the License for the specific language governing permissions
1145916cd2Sjpk  * and limitations under the License.
1245916cd2Sjpk  *
1345916cd2Sjpk  * When distributing Covered Code, include this CDDL HEADER in each
1445916cd2Sjpk  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1545916cd2Sjpk  * If applicable, add the following below this CDDL HEADER, with the
1645916cd2Sjpk  * fields enclosed by brackets "[]" replaced with your own identifying
1745916cd2Sjpk  * information: Portions Copyright [yyyy] [name of copyright owner]
1845916cd2Sjpk  *
1945916cd2Sjpk  * CDDL HEADER END
2045916cd2Sjpk  */
21*7257d1b4Sraf 
2245916cd2Sjpk /*
23*7257d1b4Sraf  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
2445916cd2Sjpk  * Use is subject to license terms.
2545916cd2Sjpk  */
2645916cd2Sjpk 
27*7257d1b4Sraf #include "lint.h"
2845916cd2Sjpk #include <sys/types.h>
2945916cd2Sjpk #include <sys/syscall.h>
3045916cd2Sjpk #include <sys/tsol/tsyscall.h>
3145916cd2Sjpk #include <unistd.h>
3245916cd2Sjpk #include <limits.h>
3345916cd2Sjpk #include <stdlib.h>
3445916cd2Sjpk #include <errno.h>
3545916cd2Sjpk #include "libc.h"
3645916cd2Sjpk 
3745916cd2Sjpk static	int	_is_labeled = -1;
3845916cd2Sjpk 
3945916cd2Sjpk /*
4045916cd2Sjpk  * is_system_labeled :
4145916cd2Sjpk  *	Return the status of MAC labeling on this system.
4245916cd2Sjpk  *	Returns 0 if labeling is not installed or not active,
4345916cd2Sjpk  */
4445916cd2Sjpk int
is_system_labeled(void)4545916cd2Sjpk is_system_labeled(void)
4645916cd2Sjpk {
4745916cd2Sjpk 	if (_is_labeled >= 0)
4845916cd2Sjpk 		return (_is_labeled);		/* fast path if cached */
4945916cd2Sjpk 
5045916cd2Sjpk 	return (_is_labeled = syscall(SYS_labelsys, TSOL_SYSLABELING));
5145916cd2Sjpk }
52