8939 btxld coverity cleanups
[unleashed.git] / include / sys / cred_impl.h
blobbe4b0c7f6f1a0c10034c23987c8a67461fb04f20
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_CRED_IMPL_H
28 #define _SYS_CRED_IMPL_H
30 #include <sys/types.h>
31 #include <sys/cred.h>
32 #include <sys/priv_impl.h>
33 #include <sys/sid.h>
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
40 * The user credential implementation.
42 * This is is not a public interface. This file must not be included
43 * except by those routines in Solaris proper that implement credential
44 * manipulation and kernel policy.
46 * Credentials are shared, and therefor read-only, data structure.
47 * After finalization, on the cr_ref field is changed through crhold/crfree.
49 * Kernel modules that need access to fields of cred_t should use the
50 * accessor functions defined in <sys/cred.h>
52 * The size of the cr_groups[] array is configurable but is the same
53 * (ngroups_max) for all cred_impl structures; cr_ngroups records the number
54 * of elements currently in use, not the array size.
56 * Changes in the implementation will move cr_groups[] around.
58 * Properly sized cred_t structures are only returned by crget()/crdup()
59 * crcopy(). It is not possible to declare one.
62 #if defined(_KERNEL) || defined(_KMEMUSER)
64 struct zone; /* forward reference */
65 struct credklpd; /* forward reference */
67 /* Supplemental groups list. */
68 typedef struct credgrp {
69 uint_t crg_ref;
70 uint_t crg_ngroups;
71 gid_t crg_groups[1];
72 } credgrp_t;
74 struct cred {
75 uint_t cr_ref; /* reference count */
76 uid_t cr_uid; /* effective user id */
77 gid_t cr_gid; /* effective group id */
78 uid_t cr_ruid; /* real user id */
79 gid_t cr_rgid; /* real group id */
80 uid_t cr_suid; /* "saved" user id (from exec) */
81 gid_t cr_sgid; /* "saved" group id (from exec) */
82 cred_priv_t cr_priv; /* privileges */
83 projid_t cr_projid; /* project */
84 struct zone *cr_zone; /* pointer to per-zone structure */
85 struct credklpd *cr_klpd; /* pointer to the cred's klpd */
86 credsid_t *cr_ksid; /* pointer to SIDs */
87 credgrp_t *cr_grps; /* supplemental groups */
88 /* audit info is defined dynamically */
89 /* and valid only when audit enabled */
90 /* auditinfo_addr_t cr_auinfo; audit info */
93 extern int ngroups_max;
95 #define CR_PRIVS(c) (&(c)->cr_priv)
96 #define CR_PRIVSETS(c) (((c)->cr_priv.crprivs))
98 #endif /* _KERNEL */
100 #ifdef __cplusplus
102 #endif
104 #endif /* _SYS_CRED_IMPL_H */