xref: /onnv-gate/usr/src/uts/common/sys/cred_impl.h (revision 11134:8aa0c4ca6639)
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
51676Sjpk  * Common Development and Distribution License (the "License").
61676Sjpk  * 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*11134SCasper.Dik@Sun.COM  * Copyright 2009 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 #include <sys/types.h>
300Sstevel@tonic-gate #include <sys/cred.h>
310Sstevel@tonic-gate #include <sys/priv_impl.h>
324321Scasper #include <sys/sid.h>
330Sstevel@tonic-gate 
340Sstevel@tonic-gate #ifdef	__cplusplus
350Sstevel@tonic-gate extern "C" {
360Sstevel@tonic-gate #endif
370Sstevel@tonic-gate 
380Sstevel@tonic-gate /*
390Sstevel@tonic-gate  * The user credential implementation.
400Sstevel@tonic-gate  *
410Sstevel@tonic-gate  * This is is not a public interface.  This file must not be included
420Sstevel@tonic-gate  * except by those routines in Solaris proper that implement credential
430Sstevel@tonic-gate  * manipulation and kernel policy.
440Sstevel@tonic-gate  *
450Sstevel@tonic-gate  * Credentials are shared, and therefor read-only, data structure.
460Sstevel@tonic-gate  * After finalization, on the cr_ref field is changed through crhold/crfree.
470Sstevel@tonic-gate  *
480Sstevel@tonic-gate  * Kernel modules that need access to fields of cred_t should use the
490Sstevel@tonic-gate  * accessor functions defined in <sys/cred.h>
500Sstevel@tonic-gate  *
510Sstevel@tonic-gate  * The size of the cr_groups[] array is configurable but is the same
520Sstevel@tonic-gate  * (ngroups_max) for all cred_impl structures; cr_ngroups records the number
530Sstevel@tonic-gate  * of elements currently in use, not the array size.
540Sstevel@tonic-gate  *
550Sstevel@tonic-gate  * Changes in the implementation will move cr_groups[] around.
560Sstevel@tonic-gate  *
570Sstevel@tonic-gate  * Properly sized cred_t structures are only returned by crget()/crdup()
580Sstevel@tonic-gate  * crcopy().  It is not possible to declare one.
590Sstevel@tonic-gate  */
600Sstevel@tonic-gate 
610Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMEMUSER)
620Sstevel@tonic-gate 
630Sstevel@tonic-gate struct zone;		/* forward reference */
641676Sjpk struct ts_label_s;	/* forward reference */
656134Scasper struct credklpd;	/* 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 	cred_priv_t	cr_priv;	/* privileges */
760Sstevel@tonic-gate 	projid_t	cr_projid;	/* project */
770Sstevel@tonic-gate 	struct zone	*cr_zone;	/* pointer to per-zone structure */
781676Sjpk 	struct ts_label_s *cr_label;	/* pointer to the effective label */
796134Scasper 	struct credklpd *cr_klpd;	/* pointer to the cred's klpd */
804321Scasper 	credsid_t	*cr_ksid;	/* pointer to SIDs */
81*11134SCasper.Dik@Sun.COM 	struct credgrp	*cr_grps;	/* supplemental groups */
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