xref: /titanic_41/usr/src/uts/common/sys/cred_impl.h (revision 70025d765b044c6d8594bb965a2247a61e991a99)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_CRED_IMPL_H
28 #define	_SYS_CRED_IMPL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.h>
33 #include <sys/cred.h>
34 #include <sys/priv_impl.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * The user credential implementation.
42  *
43  * This is is not a public interface.  This file must not be included
44  * except by those routines in Solaris proper that implement credential
45  * manipulation and kernel policy.
46  *
47  * Credentials are shared, and therefor read-only, data structure.
48  * After finalization, on the cr_ref field is changed through crhold/crfree.
49  *
50  * Kernel modules that need access to fields of cred_t should use the
51  * accessor functions defined in <sys/cred.h>
52  *
53  * The size of the cr_groups[] array is configurable but is the same
54  * (ngroups_max) for all cred_impl structures; cr_ngroups records the number
55  * of elements currently in use, not the array size.
56  *
57  * Changes in the implementation will move cr_groups[] around.
58  *
59  * Properly sized cred_t structures are only returned by crget()/crdup()
60  * crcopy().  It is not possible to declare one.
61  */
62 
63 #if defined(_KERNEL) || defined(_KMEMUSER)
64 
65 struct zone;		/* forward reference */
66 
67 struct cred {
68 	uint_t		cr_ref;		/* reference count */
69 	uid_t		cr_uid;		/* effective user id */
70 	gid_t		cr_gid;		/* effective group id */
71 	uid_t		cr_ruid;	/* real user id */
72 	gid_t		cr_rgid;	/* real group id */
73 	uid_t		cr_suid;	/* "saved" user id (from exec) */
74 	gid_t		cr_sgid;	/* "saved" group id (from exec) */
75 	uint_t		cr_ngroups;	/* number of groups returned by */
76 					/* crgroups() */
77 	cred_priv_t	cr_priv;	/* privileges */
78 	projid_t	cr_projid;	/* project */
79 	struct zone	*cr_zone;	/* pointer to per-zone structure */
80 	gid_t		cr_groups[1];	/* cr_groups size not fixed */
81 					/* audit info is defined dynamically */
82 					/* and valid only when audit enabled */
83 	/* auditinfo_addr_t	cr_auinfo;	audit info */
84 };
85 
86 extern int ngroups_max;
87 
88 #define	CR_PRIVS(c)	(&(c)->cr_priv)
89 #define	CR_PRIVSETS(c)	(((c)->cr_priv.crprivs))
90 
91 #endif	/* _KERNEL */
92 
93 #ifdef	__cplusplus
94 }
95 #endif
96 
97 #endif	/* _SYS_CRED_IMPL_H */
98