xref: /onnv-gate/usr/src/uts/common/sys/cred_impl.h (revision 1676:37f4a3e2bd99)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*1676Sjpk  * Common Development and Distribution License (the "License").
6*1676Sjpk  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*1676Sjpk  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef _SYS_CRED_IMPL_H
270Sstevel@tonic-gate #define	_SYS_CRED_IMPL_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #include <sys/types.h>
320Sstevel@tonic-gate #include <sys/cred.h>
330Sstevel@tonic-gate #include <sys/priv_impl.h>
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #ifdef	__cplusplus
360Sstevel@tonic-gate extern "C" {
370Sstevel@tonic-gate #endif
380Sstevel@tonic-gate 
390Sstevel@tonic-gate /*
400Sstevel@tonic-gate  * The user credential implementation.
410Sstevel@tonic-gate  *
420Sstevel@tonic-gate  * This is is not a public interface.  This file must not be included
430Sstevel@tonic-gate  * except by those routines in Solaris proper that implement credential
440Sstevel@tonic-gate  * manipulation and kernel policy.
450Sstevel@tonic-gate  *
460Sstevel@tonic-gate  * Credentials are shared, and therefor read-only, data structure.
470Sstevel@tonic-gate  * After finalization, on the cr_ref field is changed through crhold/crfree.
480Sstevel@tonic-gate  *
490Sstevel@tonic-gate  * Kernel modules that need access to fields of cred_t should use the
500Sstevel@tonic-gate  * accessor functions defined in <sys/cred.h>
510Sstevel@tonic-gate  *
520Sstevel@tonic-gate  * The size of the cr_groups[] array is configurable but is the same
530Sstevel@tonic-gate  * (ngroups_max) for all cred_impl structures; cr_ngroups records the number
540Sstevel@tonic-gate  * of elements currently in use, not the array size.
550Sstevel@tonic-gate  *
560Sstevel@tonic-gate  * Changes in the implementation will move cr_groups[] around.
570Sstevel@tonic-gate  *
580Sstevel@tonic-gate  * Properly sized cred_t structures are only returned by crget()/crdup()
590Sstevel@tonic-gate  * crcopy().  It is not possible to declare one.
600Sstevel@tonic-gate  */
610Sstevel@tonic-gate 
620Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMEMUSER)
630Sstevel@tonic-gate 
640Sstevel@tonic-gate struct zone;		/* forward reference */
65*1676Sjpk struct ts_label_s;	/* forward reference */
660Sstevel@tonic-gate 
670Sstevel@tonic-gate struct cred {
680Sstevel@tonic-gate 	uint_t		cr_ref;		/* reference count */
690Sstevel@tonic-gate 	uid_t		cr_uid;		/* effective user id */
700Sstevel@tonic-gate 	gid_t		cr_gid;		/* effective group id */
710Sstevel@tonic-gate 	uid_t		cr_ruid;	/* real user id */
720Sstevel@tonic-gate 	gid_t		cr_rgid;	/* real group id */
730Sstevel@tonic-gate 	uid_t		cr_suid;	/* "saved" user id (from exec) */
740Sstevel@tonic-gate 	gid_t		cr_sgid;	/* "saved" group id (from exec) */
750Sstevel@tonic-gate 	uint_t		cr_ngroups;	/* number of groups returned by */
760Sstevel@tonic-gate 					/* crgroups() */
770Sstevel@tonic-gate 	cred_priv_t	cr_priv;	/* privileges */
780Sstevel@tonic-gate 	projid_t	cr_projid;	/* project */
790Sstevel@tonic-gate 	struct zone	*cr_zone;	/* pointer to per-zone structure */
80*1676Sjpk 	struct ts_label_s *cr_label;	/* pointer to the effective label */
810Sstevel@tonic-gate 	gid_t		cr_groups[1];	/* cr_groups size not fixed */
820Sstevel@tonic-gate 					/* audit info is defined dynamically */
830Sstevel@tonic-gate 					/* and valid only when audit enabled */
840Sstevel@tonic-gate 	/* auditinfo_addr_t	cr_auinfo;	audit info */
850Sstevel@tonic-gate };
860Sstevel@tonic-gate 
870Sstevel@tonic-gate extern int ngroups_max;
880Sstevel@tonic-gate 
890Sstevel@tonic-gate #define	CR_PRIVS(c)	(&(c)->cr_priv)
900Sstevel@tonic-gate #define	CR_PRIVSETS(c)	(((c)->cr_priv.crprivs))
910Sstevel@tonic-gate 
920Sstevel@tonic-gate #endif	/* _KERNEL */
930Sstevel@tonic-gate 
940Sstevel@tonic-gate #ifdef	__cplusplus
950Sstevel@tonic-gate }
960Sstevel@tonic-gate #endif
970Sstevel@tonic-gate 
980Sstevel@tonic-gate #endif	/* _SYS_CRED_IMPL_H */
99