xref: /illumos-gate/usr/src/lib/libc/port/gen/ucred.c (revision 7257d1b4d25bfac0c802847390e98a464fd787ac)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
545916cd2Sjpk  * Common Development and Distribution License (the "License").
645916cd2Sjpk  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21*7257d1b4Sraf 
227c478bd9Sstevel@tonic-gate /*
23*7257d1b4Sraf  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
287c478bd9Sstevel@tonic-gate 
29*7257d1b4Sraf #pragma weak _ucred_free = ucred_free
30*7257d1b4Sraf #pragma weak _ucred_get = ucred_get
31*7257d1b4Sraf #pragma weak _ucred_getegid = ucred_getegid
32*7257d1b4Sraf #pragma weak _ucred_geteuid = ucred_geteuid
33*7257d1b4Sraf #pragma weak _ucred_getgroups = ucred_getgroups
34*7257d1b4Sraf #pragma weak _ucred_getpflags = ucred_getpflags
35*7257d1b4Sraf #pragma weak _ucred_getpid = ucred_getpid
36*7257d1b4Sraf #pragma weak _ucred_getzoneid = ucred_getzoneid
37*7257d1b4Sraf #pragma weak _ucred_getprojid = ucred_getprojid
38*7257d1b4Sraf #pragma weak _ucred_getprivset = ucred_getprivset
39*7257d1b4Sraf #pragma weak _ucred_getrgid = ucred_getrgid
40*7257d1b4Sraf #pragma weak _ucred_getruid = ucred_getruid
41*7257d1b4Sraf #pragma weak _ucred_getsgid = ucred_getsgid
42*7257d1b4Sraf #pragma weak _ucred_getsuid = ucred_getsuid
43*7257d1b4Sraf #pragma weak _ucred_getauid = ucred_getauid
44*7257d1b4Sraf #pragma weak _ucred_getasid = ucred_getasid
45*7257d1b4Sraf #pragma weak _ucred_getatid = ucred_getatid
46*7257d1b4Sraf #pragma weak _ucred_getlabel = ucred_getlabel
47*7257d1b4Sraf #pragma weak _ucred_getamask = ucred_getamask
48*7257d1b4Sraf #pragma weak _ucred_size = ucred_size
49*7257d1b4Sraf 
50*7257d1b4Sraf #include "lint.h"
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate #define	_STRUCTURED_PROC	1
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate #include "priv_private.h"
557c478bd9Sstevel@tonic-gate #include <errno.h>
567c478bd9Sstevel@tonic-gate #include <priv.h>
577c478bd9Sstevel@tonic-gate #include <stdarg.h>
587c478bd9Sstevel@tonic-gate #include <stdlib.h>
597c478bd9Sstevel@tonic-gate #include <stdio.h>
607c478bd9Sstevel@tonic-gate #include <unistd.h>
617c478bd9Sstevel@tonic-gate #include <ucred.h>
627c478bd9Sstevel@tonic-gate #include <limits.h>
637c478bd9Sstevel@tonic-gate #include <fcntl.h>
647c478bd9Sstevel@tonic-gate #include <door.h>
657c478bd9Sstevel@tonic-gate #include <alloca.h>
667c478bd9Sstevel@tonic-gate #include <sys/ucred.h>
677c478bd9Sstevel@tonic-gate #include <sys/procfs.h>
687c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
697c478bd9Sstevel@tonic-gate #include <sys/zone.h>
7045916cd2Sjpk #include <tsol/label.h>
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate ucred_t *
737c478bd9Sstevel@tonic-gate _ucred_alloc(void)
747c478bd9Sstevel@tonic-gate {
757c478bd9Sstevel@tonic-gate 	ucred_t *r;
767c478bd9Sstevel@tonic-gate 	size_t sz = ucred_size();
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate 	r = malloc(sz);
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate 	if (r != NULL)
817c478bd9Sstevel@tonic-gate 		r->uc_size = (uint32_t)sz;
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate 	return (r);
847c478bd9Sstevel@tonic-gate }
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate void
877c478bd9Sstevel@tonic-gate ucred_free(ucred_t *uc)
887c478bd9Sstevel@tonic-gate {
897c478bd9Sstevel@tonic-gate 	free(uc);
907c478bd9Sstevel@tonic-gate }
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate ucred_t *
947c478bd9Sstevel@tonic-gate ucred_get(pid_t pid)
957c478bd9Sstevel@tonic-gate {
967c478bd9Sstevel@tonic-gate 	ucred_t *uc;
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate 	uc = _ucred_alloc();
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate 	if (uc == NULL)
1017c478bd9Sstevel@tonic-gate 		return (NULL);
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate 	if (syscall(SYS_ucredsys, UCREDSYS_UCREDGET, pid, uc) != 0) {
1047c478bd9Sstevel@tonic-gate 		ucred_free(uc);
1057c478bd9Sstevel@tonic-gate 		return (NULL);
1067c478bd9Sstevel@tonic-gate 	}
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate 	return (uc);
1097c478bd9Sstevel@tonic-gate }
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate uid_t
1127c478bd9Sstevel@tonic-gate ucred_geteuid(const ucred_t *uc)
1137c478bd9Sstevel@tonic-gate {
1147c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
1157c478bd9Sstevel@tonic-gate 	const prcred_t *cr = UCCRED(uc);
1167c478bd9Sstevel@tonic-gate 
1177c478bd9Sstevel@tonic-gate 	if (cr == NULL) {
1187c478bd9Sstevel@tonic-gate 		errno = EINVAL;
119f48205beScasper 		return ((uid_t)-1);
1207c478bd9Sstevel@tonic-gate 	}
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate 	return (cr->pr_euid);
1237c478bd9Sstevel@tonic-gate }
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate uid_t
1267c478bd9Sstevel@tonic-gate ucred_getruid(const ucred_t *uc)
1277c478bd9Sstevel@tonic-gate {
1287c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
1297c478bd9Sstevel@tonic-gate 	const prcred_t *cr = UCCRED(uc);
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate 	if (cr == NULL) {
1327c478bd9Sstevel@tonic-gate 		errno = EINVAL;
133f48205beScasper 		return ((uid_t)-1);
1347c478bd9Sstevel@tonic-gate 	}
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate 	return (cr->pr_ruid);
1377c478bd9Sstevel@tonic-gate }
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate uid_t
1407c478bd9Sstevel@tonic-gate ucred_getsuid(const ucred_t *uc)
1417c478bd9Sstevel@tonic-gate {
1427c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
1437c478bd9Sstevel@tonic-gate 	const prcred_t *cr = UCCRED(uc);
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate 	if (cr == NULL) {
1467c478bd9Sstevel@tonic-gate 		errno = EINVAL;
147f48205beScasper 		return ((uid_t)-1);
1487c478bd9Sstevel@tonic-gate 	}
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate 	return (cr->pr_suid);
1517c478bd9Sstevel@tonic-gate }
1527c478bd9Sstevel@tonic-gate 
1537c478bd9Sstevel@tonic-gate gid_t
1547c478bd9Sstevel@tonic-gate ucred_getegid(const ucred_t *uc)
1557c478bd9Sstevel@tonic-gate {
1567c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
1577c478bd9Sstevel@tonic-gate 	const prcred_t *cr = UCCRED(uc);
1587c478bd9Sstevel@tonic-gate 
1597c478bd9Sstevel@tonic-gate 	if (cr == NULL) {
1607c478bd9Sstevel@tonic-gate 		errno = EINVAL;
161f48205beScasper 		return ((gid_t)-1);
1627c478bd9Sstevel@tonic-gate 	}
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate 	return (cr->pr_egid);
1657c478bd9Sstevel@tonic-gate }
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate gid_t
1687c478bd9Sstevel@tonic-gate ucred_getrgid(const ucred_t *uc)
1697c478bd9Sstevel@tonic-gate {
1707c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
1717c478bd9Sstevel@tonic-gate 	const prcred_t *cr = UCCRED(uc);
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate 	if (cr == NULL) {
1747c478bd9Sstevel@tonic-gate 		errno = EINVAL;
175f48205beScasper 		return ((gid_t)-1);
1767c478bd9Sstevel@tonic-gate 	}
1777c478bd9Sstevel@tonic-gate 
1787c478bd9Sstevel@tonic-gate 	return (cr->pr_rgid);
1797c478bd9Sstevel@tonic-gate }
1807c478bd9Sstevel@tonic-gate 
1817c478bd9Sstevel@tonic-gate gid_t
1827c478bd9Sstevel@tonic-gate ucred_getsgid(const ucred_t *uc)
1837c478bd9Sstevel@tonic-gate {
1847c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
1857c478bd9Sstevel@tonic-gate 	const prcred_t *cr = UCCRED(uc);
1867c478bd9Sstevel@tonic-gate 
1877c478bd9Sstevel@tonic-gate 	if (cr == NULL) {
1887c478bd9Sstevel@tonic-gate 		errno = EINVAL;
189f48205beScasper 		return ((gid_t)-1);
1907c478bd9Sstevel@tonic-gate 	}
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate 	return (cr->pr_sgid);
1937c478bd9Sstevel@tonic-gate }
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate int
1967c478bd9Sstevel@tonic-gate ucred_getgroups(const ucred_t *uc, const gid_t **grps)
1977c478bd9Sstevel@tonic-gate {
1987c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
1997c478bd9Sstevel@tonic-gate 	const prcred_t *cr = UCCRED(uc);
2007c478bd9Sstevel@tonic-gate 
2017c478bd9Sstevel@tonic-gate 	if (cr == NULL) {
2027c478bd9Sstevel@tonic-gate 		errno = EINVAL;
2037c478bd9Sstevel@tonic-gate 		return (-1);
2047c478bd9Sstevel@tonic-gate 	}
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate 	if (cr->pr_ngroups > 0)
2077c478bd9Sstevel@tonic-gate 		*grps = &cr->pr_groups[0];
2087c478bd9Sstevel@tonic-gate 	else
2097c478bd9Sstevel@tonic-gate 		*grps = NULL;
2107c478bd9Sstevel@tonic-gate 
2117c478bd9Sstevel@tonic-gate 	return (cr->pr_ngroups);
2127c478bd9Sstevel@tonic-gate }
2137c478bd9Sstevel@tonic-gate 
2147c478bd9Sstevel@tonic-gate const priv_set_t *
2157c478bd9Sstevel@tonic-gate ucred_getprivset(const ucred_t *uc, priv_ptype_t set)
2167c478bd9Sstevel@tonic-gate {
2177c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
2187c478bd9Sstevel@tonic-gate 	const prpriv_t *pr = UCPRIV(uc);
2197c478bd9Sstevel@tonic-gate 	int pset = priv_getsetbyname(set);
2207c478bd9Sstevel@tonic-gate 	priv_data_t *d;
2217c478bd9Sstevel@tonic-gate 
2227c478bd9Sstevel@tonic-gate 	if (pr == NULL || pset == -1) {
2237c478bd9Sstevel@tonic-gate 		errno = EINVAL;
2247c478bd9Sstevel@tonic-gate 		return (NULL);
2257c478bd9Sstevel@tonic-gate 	}
2267c478bd9Sstevel@tonic-gate 
2277c478bd9Sstevel@tonic-gate 	LOADPRIVDATA(d);
2287c478bd9Sstevel@tonic-gate 
2297c478bd9Sstevel@tonic-gate 	return ((const priv_set_t *)
2307c478bd9Sstevel@tonic-gate 	    &pr->pr_sets[d->pd_pinfo->priv_setsize * pset]);
2317c478bd9Sstevel@tonic-gate }
2327c478bd9Sstevel@tonic-gate 
2337c478bd9Sstevel@tonic-gate pid_t
2347c478bd9Sstevel@tonic-gate ucred_getpid(const ucred_t *uc)
2357c478bd9Sstevel@tonic-gate {
2367c478bd9Sstevel@tonic-gate 
2377c478bd9Sstevel@tonic-gate 	if (uc->uc_pid == -1)
2387c478bd9Sstevel@tonic-gate 		errno = EINVAL;
2397c478bd9Sstevel@tonic-gate 
2407c478bd9Sstevel@tonic-gate 	return (uc->uc_pid);
2417c478bd9Sstevel@tonic-gate }
2427c478bd9Sstevel@tonic-gate 
2437c478bd9Sstevel@tonic-gate projid_t
2447c478bd9Sstevel@tonic-gate ucred_getprojid(const ucred_t *uc)
2457c478bd9Sstevel@tonic-gate {
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate 	if (uc->uc_projid == -1)
2487c478bd9Sstevel@tonic-gate 		errno = EINVAL;
2497c478bd9Sstevel@tonic-gate 
2507c478bd9Sstevel@tonic-gate 	return (uc->uc_projid);
2517c478bd9Sstevel@tonic-gate }
2527c478bd9Sstevel@tonic-gate 
2537c478bd9Sstevel@tonic-gate zoneid_t
2547c478bd9Sstevel@tonic-gate ucred_getzoneid(const ucred_t *uc)
2557c478bd9Sstevel@tonic-gate {
2567c478bd9Sstevel@tonic-gate 
2577c478bd9Sstevel@tonic-gate 	if (uc->uc_zoneid < MIN_ZONEID || uc->uc_zoneid > MAX_ZONEID) {
2587c478bd9Sstevel@tonic-gate 		errno = EINVAL;
2597c478bd9Sstevel@tonic-gate 		return (-1);
2607c478bd9Sstevel@tonic-gate 	}
2617c478bd9Sstevel@tonic-gate 
2627c478bd9Sstevel@tonic-gate 	return (uc->uc_zoneid);
2637c478bd9Sstevel@tonic-gate }
2647c478bd9Sstevel@tonic-gate 
26545916cd2Sjpk bslabel_t *
26645916cd2Sjpk ucred_getlabel(const ucred_t *uc)
26745916cd2Sjpk {
26845916cd2Sjpk 	/* LINTED: alignment */
26945916cd2Sjpk 	bslabel_t *slabel = UCLABEL(uc);
27045916cd2Sjpk 
27145916cd2Sjpk 	if (!is_system_labeled() || slabel == NULL) {
27245916cd2Sjpk 		errno = EINVAL;
27345916cd2Sjpk 		return (NULL);
27445916cd2Sjpk 	}
27545916cd2Sjpk 
27645916cd2Sjpk 	return (slabel);
27745916cd2Sjpk }
27845916cd2Sjpk 
2797c478bd9Sstevel@tonic-gate /*
2807c478bd9Sstevel@tonic-gate  * For now, assume single bit flags.
2817c478bd9Sstevel@tonic-gate  */
2827c478bd9Sstevel@tonic-gate uint_t
2837c478bd9Sstevel@tonic-gate ucred_getpflags(const ucred_t *uc, uint_t flag)
2847c478bd9Sstevel@tonic-gate {
2857c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
2867c478bd9Sstevel@tonic-gate 	prpriv_t *pr = UCPRIV(uc);
2877c478bd9Sstevel@tonic-gate 	char *x, *end;
2887c478bd9Sstevel@tonic-gate 
2897c478bd9Sstevel@tonic-gate 	if (pr == NULL) {
2907c478bd9Sstevel@tonic-gate 		errno = EINVAL;
2917c478bd9Sstevel@tonic-gate 		return ((uint_t)-1);
2927c478bd9Sstevel@tonic-gate 	}
2937c478bd9Sstevel@tonic-gate 
2947c478bd9Sstevel@tonic-gate 	end = (char *)pr + PRIV_PRPRIV_SIZE(pr);
2957c478bd9Sstevel@tonic-gate 	x = end - pr->pr_infosize;
2967c478bd9Sstevel@tonic-gate 
2977c478bd9Sstevel@tonic-gate 	while (x < end) {
2987c478bd9Sstevel@tonic-gate 		/* LINTED: alignment */
2997c478bd9Sstevel@tonic-gate 		priv_info_t *pi = (priv_info_t *)x;
3007c478bd9Sstevel@tonic-gate 		priv_info_uint_t *pii;
3017c478bd9Sstevel@tonic-gate 
3027c478bd9Sstevel@tonic-gate 		switch (pi->priv_info_type) {
3037c478bd9Sstevel@tonic-gate 		case PRIV_INFO_FLAGS:
3047c478bd9Sstevel@tonic-gate 			/* LINTED: alignment */
3057c478bd9Sstevel@tonic-gate 			pii = (priv_info_uint_t *)x;
3067c478bd9Sstevel@tonic-gate 			return ((pii->val & flag) ? 1 : 0);
3077c478bd9Sstevel@tonic-gate 		}
3087c478bd9Sstevel@tonic-gate 		/* Forward progress */
3097c478bd9Sstevel@tonic-gate 		if (pi->priv_info_size < sizeof (priv_info_t))
3107c478bd9Sstevel@tonic-gate 			break;
3117c478bd9Sstevel@tonic-gate 		x += pi->priv_info_size;
3127c478bd9Sstevel@tonic-gate 	}
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate 	errno = EINVAL;
3157c478bd9Sstevel@tonic-gate 	return ((uint_t)-1);
3167c478bd9Sstevel@tonic-gate }
3177c478bd9Sstevel@tonic-gate 
3187c478bd9Sstevel@tonic-gate au_id_t
3197c478bd9Sstevel@tonic-gate ucred_getauid(const ucred_t *uc)
3207c478bd9Sstevel@tonic-gate {
3217c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
3227c478bd9Sstevel@tonic-gate 	const auditinfo64_addr_t *ainfo = UCAUD(uc);
3237c478bd9Sstevel@tonic-gate 
3247c478bd9Sstevel@tonic-gate 	if (ainfo == NULL)
3257c478bd9Sstevel@tonic-gate 		return (AU_NOAUDITID);
3267c478bd9Sstevel@tonic-gate 
3277c478bd9Sstevel@tonic-gate 	return (ainfo->ai_auid);
3287c478bd9Sstevel@tonic-gate }
3297c478bd9Sstevel@tonic-gate 
3307c478bd9Sstevel@tonic-gate au_asid_t
3317c478bd9Sstevel@tonic-gate ucred_getasid(const ucred_t *uc)
3327c478bd9Sstevel@tonic-gate {
3337c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
3347c478bd9Sstevel@tonic-gate 	const auditinfo64_addr_t *ainfo = UCAUD(uc);
3357c478bd9Sstevel@tonic-gate 
3367c478bd9Sstevel@tonic-gate 	if (ainfo == NULL)
3377c478bd9Sstevel@tonic-gate 		return (-1);
3387c478bd9Sstevel@tonic-gate 
3397c478bd9Sstevel@tonic-gate 	return (ainfo->ai_asid);
3407c478bd9Sstevel@tonic-gate }
3417c478bd9Sstevel@tonic-gate 
3427c478bd9Sstevel@tonic-gate const au_tid64_addr_t *
3437c478bd9Sstevel@tonic-gate ucred_getatid(const ucred_t *uc)
3447c478bd9Sstevel@tonic-gate {
3457c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
3467c478bd9Sstevel@tonic-gate 	const auditinfo64_addr_t *ainfo = UCAUD(uc);
3477c478bd9Sstevel@tonic-gate 
3487c478bd9Sstevel@tonic-gate 	if (ainfo == NULL) {
3497c478bd9Sstevel@tonic-gate 		errno = EINVAL;
3507c478bd9Sstevel@tonic-gate 		return (NULL);
3517c478bd9Sstevel@tonic-gate 	}
3527c478bd9Sstevel@tonic-gate 
3537c478bd9Sstevel@tonic-gate 	return (&ainfo->ai_termid);
3547c478bd9Sstevel@tonic-gate }
3557c478bd9Sstevel@tonic-gate 
3567c478bd9Sstevel@tonic-gate const au_mask_t *
3577c478bd9Sstevel@tonic-gate ucred_getamask(const ucred_t *uc)
3587c478bd9Sstevel@tonic-gate {
3597c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
3607c478bd9Sstevel@tonic-gate 	const auditinfo64_addr_t *ainfo = UCAUD(uc);
3617c478bd9Sstevel@tonic-gate 
3627c478bd9Sstevel@tonic-gate 	if (ainfo == NULL) {
3637c478bd9Sstevel@tonic-gate 		errno = EINVAL;
3647c478bd9Sstevel@tonic-gate 		return (NULL);
3657c478bd9Sstevel@tonic-gate 	}
3667c478bd9Sstevel@tonic-gate 
3677c478bd9Sstevel@tonic-gate 	return (&ainfo->ai_mask);
3687c478bd9Sstevel@tonic-gate }
3697c478bd9Sstevel@tonic-gate 
3707c478bd9Sstevel@tonic-gate size_t
3717c478bd9Sstevel@tonic-gate ucred_size(void)
3727c478bd9Sstevel@tonic-gate {
3737c478bd9Sstevel@tonic-gate 	priv_data_t *d;
3747c478bd9Sstevel@tonic-gate 
3757c478bd9Sstevel@tonic-gate 	LOADPRIVDATA(d);
3767c478bd9Sstevel@tonic-gate 
3777c478bd9Sstevel@tonic-gate 	return (d->pd_ucredsize);
3787c478bd9Sstevel@tonic-gate }
379