xref: /onnv-gate/usr/src/lib/libc/port/sys/label.c (revision 6812:febeba71273d)
11676Sjpk /*
21676Sjpk  * CDDL HEADER START
31676Sjpk  *
41676Sjpk  * The contents of this file are subject to the terms of the
51676Sjpk  * Common Development and Distribution License (the "License").
61676Sjpk  * You may not use this file except in compliance with the License.
71676Sjpk  *
81676Sjpk  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
91676Sjpk  * or http://www.opensolaris.org/os/licensing.
101676Sjpk  * See the License for the specific language governing permissions
111676Sjpk  * and limitations under the License.
121676Sjpk  *
131676Sjpk  * When distributing Covered Code, include this CDDL HEADER in each
141676Sjpk  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
151676Sjpk  * If applicable, add the following below this CDDL HEADER, with the
161676Sjpk  * fields enclosed by brackets "[]" replaced with your own identifying
171676Sjpk  * information: Portions Copyright [yyyy] [name of copyright owner]
181676Sjpk  *
191676Sjpk  * CDDL HEADER END
201676Sjpk  */
21*6812Sraf 
221676Sjpk /*
23*6812Sraf  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
241676Sjpk  * Use is subject to license terms.
251676Sjpk  */
261676Sjpk 
271676Sjpk #pragma ident	"%Z%%M%	%I%	%E% SMI"
281676Sjpk 
29*6812Sraf #include "lint.h"
301676Sjpk #include <sys/types.h>
311676Sjpk #include <sys/syscall.h>
321676Sjpk #include <sys/tsol/tsyscall.h>
331676Sjpk #include <unistd.h>
341676Sjpk #include <limits.h>
351676Sjpk #include <stdlib.h>
361676Sjpk #include <errno.h>
371676Sjpk #include "libc.h"
381676Sjpk 
391676Sjpk static	int	_is_labeled = -1;
401676Sjpk 
411676Sjpk /*
421676Sjpk  * is_system_labeled :
431676Sjpk  *	Return the status of MAC labeling on this system.
441676Sjpk  *	Returns 0 if labeling is not installed or not active,
451676Sjpk  */
461676Sjpk int
is_system_labeled(void)471676Sjpk is_system_labeled(void)
481676Sjpk {
491676Sjpk 	if (_is_labeled >= 0)
501676Sjpk 		return (_is_labeled);		/* fast path if cached */
511676Sjpk 
521676Sjpk 	return (_is_labeled = syscall(SYS_labelsys, TSOL_SYSLABELING));
531676Sjpk }
54