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]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
25 * File with private definitions for the ucred structure for use by the
26 * kernel and library routines.
32 #include <sys/types.h>
33 #include <sys/procfs.h>
47 #if defined(_KERNEL) || _STRUCTURED_PROC != 0
49 * bitness neutral struct
51 * Add new fixed fields at the end of the structure.
54 uint32_t uc_size
; /* Size of the full structure */
55 uint32_t uc_credoff
; /* Credential offset: 0 - no cred */
56 uint32_t uc_privoff
; /* Privilege offset: 0 - no privs */
57 pid_t uc_pid
; /* Process id */
58 zoneid_t uc_zoneid
; /* Zone id */
59 projid_t uc_projid
; /* Project id */
60 /* The rest goes here */
63 /* Get the process credentials */
64 #define UCCRED(uc) (prcred_t *)(((uc)->uc_credoff == 0) ? NULL : \
65 ((char *)(uc)) + (uc)->uc_credoff)
67 /* Get the process privileges */
68 #define UCPRIV(uc) (prpriv_t *)(((uc)->uc_privoff == 0) ? NULL : \
69 ((char *)(uc)) + (uc)->uc_privoff)
71 #endif /* _KERNEL || _STRUCTURED_PROC != 0 */
74 * SYS_ucredsys subcodes.
76 #define UCREDSYS_UCREDGET 0
77 #define UCREDSYS_GETPEERUCRED 1
81 extern uint32_t ucredminsize(const cred_t
*);
83 #define UCRED_PRIV_OFF (sizeof (struct ucred_s))
84 /* The prcred_t has a variable size; it should be last. */
85 #define UCRED_CRED_OFF (UCRED_PRIV_OFF + priv_prgetprivsize(NULL))
87 #define UCRED_SIZE (UCRED_CRED_OFF + sizeof (prcred_t) + \
88 (ngroups_max - 1) * sizeof (gid_t))
93 extern struct ucred_s
*pgetucred(struct proc
*);
94 extern struct ucred_s
*cred2ucred(const cred_t
*, pid_t
, void *,
99 /* Definition only valid for structured proc. */
100 #if _STRUCTURED_PROC != 0
101 #define UCRED_SIZE(ip) (sizeof (struct ucred_s) + sizeof (prcred_t) + \
102 ((int)sysconf(_SC_NGROUPS_MAX) - 1) * sizeof (gid_t) + \
103 sizeof (prpriv_t) + \
104 sizeof (priv_chunk_t) * \
105 ((ip)->priv_setsize * (ip)->priv_nsets - 1) + \
109 extern struct ucred_s
*_ucred_alloc(void);
117 #endif /* _SYS_UCRED_H */