xref: /illumos-gate/usr/src/lib/libc/port/gen/ucred.c (revision d0fa49b7)
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  */
217257d1b4Sraf 
227c478bd9Sstevel@tonic-gate /*
237257d1b4Sraf  * 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 
287257d1b4Sraf #pragma weak _ucred_free = ucred_free
297257d1b4Sraf #pragma weak _ucred_get = ucred_get
307257d1b4Sraf #pragma weak _ucred_getegid = ucred_getegid
317257d1b4Sraf #pragma weak _ucred_geteuid = ucred_geteuid
327257d1b4Sraf #pragma weak _ucred_getgroups = ucred_getgroups
337257d1b4Sraf #pragma weak _ucred_getpflags = ucred_getpflags
347257d1b4Sraf #pragma weak _ucred_getpid = ucred_getpid
357257d1b4Sraf #pragma weak _ucred_getzoneid = ucred_getzoneid
367257d1b4Sraf #pragma weak _ucred_getprojid = ucred_getprojid
377257d1b4Sraf #pragma weak _ucred_getprivset = ucred_getprivset
387257d1b4Sraf #pragma weak _ucred_getrgid = ucred_getrgid
397257d1b4Sraf #pragma weak _ucred_getruid = ucred_getruid
407257d1b4Sraf #pragma weak _ucred_getsgid = ucred_getsgid
417257d1b4Sraf #pragma weak _ucred_getsuid = ucred_getsuid
427257d1b4Sraf #pragma weak _ucred_getauid = ucred_getauid
437257d1b4Sraf #pragma weak _ucred_getasid = ucred_getasid
447257d1b4Sraf #pragma weak _ucred_getatid = ucred_getatid
457257d1b4Sraf #pragma weak _ucred_getlabel = ucred_getlabel
467257d1b4Sraf #pragma weak _ucred_getamask = ucred_getamask
477257d1b4Sraf #pragma weak _ucred_size = ucred_size
487257d1b4Sraf 
497257d1b4Sraf #include "lint.h"
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate #define	_STRUCTURED_PROC	1
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate #include "priv_private.h"
547c478bd9Sstevel@tonic-gate #include <errno.h>
557c478bd9Sstevel@tonic-gate #include <priv.h>
567c478bd9Sstevel@tonic-gate #include <stdarg.h>
577c478bd9Sstevel@tonic-gate #include <stdlib.h>
587c478bd9Sstevel@tonic-gate #include <stdio.h>
597c478bd9Sstevel@tonic-gate #include <unistd.h>
607c478bd9Sstevel@tonic-gate #include <ucred.h>
617c478bd9Sstevel@tonic-gate #include <limits.h>
627c478bd9Sstevel@tonic-gate #include <fcntl.h>
637c478bd9Sstevel@tonic-gate #include <door.h>
647c478bd9Sstevel@tonic-gate #include <alloca.h>
657c478bd9Sstevel@tonic-gate #include <sys/ucred.h>
667c478bd9Sstevel@tonic-gate #include <sys/procfs.h>
677c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
687c478bd9Sstevel@tonic-gate #include <sys/zone.h>
6945916cd2Sjpk #include <tsol/label.h>
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate ucred_t *
_ucred_alloc(void)727c478bd9Sstevel@tonic-gate _ucred_alloc(void)
737c478bd9Sstevel@tonic-gate {
747c478bd9Sstevel@tonic-gate 	ucred_t *r;
757c478bd9Sstevel@tonic-gate 	size_t sz = ucred_size();
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate 	r = malloc(sz);
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate 	if (r != NULL)
807c478bd9Sstevel@tonic-gate 		r->uc_size = (uint32_t)sz;
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate 	return (r);
837c478bd9Sstevel@tonic-gate }
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate void
ucred_free(ucred_t * uc)867c478bd9Sstevel@tonic-gate ucred_free(ucred_t *uc)
877c478bd9Sstevel@tonic-gate {
887c478bd9Sstevel@tonic-gate 	free(uc);
897c478bd9Sstevel@tonic-gate }
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate ucred_t *
ucred_get(pid_t pid)937c478bd9Sstevel@tonic-gate ucred_get(pid_t pid)
947c478bd9Sstevel@tonic-gate {
957c478bd9Sstevel@tonic-gate 	ucred_t *uc;
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate 	uc = _ucred_alloc();
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate 	if (uc == NULL)
1007c478bd9Sstevel@tonic-gate 		return (NULL);
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate 	if (syscall(SYS_ucredsys, UCREDSYS_UCREDGET, pid, uc) != 0) {
1037c478bd9Sstevel@tonic-gate 		ucred_free(uc);
1047c478bd9Sstevel@tonic-gate 		return (NULL);
1057c478bd9Sstevel@tonic-gate 	}
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate 	return (uc);
1087c478bd9Sstevel@tonic-gate }
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate uid_t
ucred_geteuid(const ucred_t * uc)1117c478bd9Sstevel@tonic-gate ucred_geteuid(const ucred_t *uc)
1127c478bd9Sstevel@tonic-gate {
1137c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
1147c478bd9Sstevel@tonic-gate 	const prcred_t *cr = UCCRED(uc);
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate 	if (cr == NULL) {
1177c478bd9Sstevel@tonic-gate 		errno = EINVAL;
118f48205beScasper 		return ((uid_t)-1);
1197c478bd9Sstevel@tonic-gate 	}
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate 	return (cr->pr_euid);
1227c478bd9Sstevel@tonic-gate }
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate uid_t
ucred_getruid(const ucred_t * uc)1257c478bd9Sstevel@tonic-gate ucred_getruid(const ucred_t *uc)
1267c478bd9Sstevel@tonic-gate {
1277c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
1287c478bd9Sstevel@tonic-gate 	const prcred_t *cr = UCCRED(uc);
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate 	if (cr == NULL) {
1317c478bd9Sstevel@tonic-gate 		errno = EINVAL;
132f48205beScasper 		return ((uid_t)-1);
1337c478bd9Sstevel@tonic-gate 	}
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate 	return (cr->pr_ruid);
1367c478bd9Sstevel@tonic-gate }
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate uid_t
ucred_getsuid(const ucred_t * uc)1397c478bd9Sstevel@tonic-gate ucred_getsuid(const ucred_t *uc)
1407c478bd9Sstevel@tonic-gate {
1417c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
1427c478bd9Sstevel@tonic-gate 	const prcred_t *cr = UCCRED(uc);
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate 	if (cr == NULL) {
1457c478bd9Sstevel@tonic-gate 		errno = EINVAL;
146f48205beScasper 		return ((uid_t)-1);
1477c478bd9Sstevel@tonic-gate 	}
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate 	return (cr->pr_suid);
1507c478bd9Sstevel@tonic-gate }
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate gid_t
ucred_getegid(const ucred_t * uc)1537c478bd9Sstevel@tonic-gate ucred_getegid(const ucred_t *uc)
1547c478bd9Sstevel@tonic-gate {
1557c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
1567c478bd9Sstevel@tonic-gate 	const prcred_t *cr = UCCRED(uc);
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate 	if (cr == NULL) {
1597c478bd9Sstevel@tonic-gate 		errno = EINVAL;
160f48205beScasper 		return ((gid_t)-1);
1617c478bd9Sstevel@tonic-gate 	}
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate 	return (cr->pr_egid);
1647c478bd9Sstevel@tonic-gate }
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate gid_t
ucred_getrgid(const ucred_t * uc)1677c478bd9Sstevel@tonic-gate ucred_getrgid(const ucred_t *uc)
1687c478bd9Sstevel@tonic-gate {
1697c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
1707c478bd9Sstevel@tonic-gate 	const prcred_t *cr = UCCRED(uc);
1717c478bd9Sstevel@tonic-gate 
1727c478bd9Sstevel@tonic-gate 	if (cr == NULL) {
1737c478bd9Sstevel@tonic-gate 		errno = EINVAL;
174f48205beScasper 		return ((gid_t)-1);
1757c478bd9Sstevel@tonic-gate 	}
1767c478bd9Sstevel@tonic-gate 
1777c478bd9Sstevel@tonic-gate 	return (cr->pr_rgid);
1787c478bd9Sstevel@tonic-gate }
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate gid_t
ucred_getsgid(const ucred_t * uc)1817c478bd9Sstevel@tonic-gate ucred_getsgid(const ucred_t *uc)
1827c478bd9Sstevel@tonic-gate {
1837c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
1847c478bd9Sstevel@tonic-gate 	const prcred_t *cr = UCCRED(uc);
1857c478bd9Sstevel@tonic-gate 
1867c478bd9Sstevel@tonic-gate 	if (cr == NULL) {
1877c478bd9Sstevel@tonic-gate 		errno = EINVAL;
188f48205beScasper 		return ((gid_t)-1);
1897c478bd9Sstevel@tonic-gate 	}
1907c478bd9Sstevel@tonic-gate 
1917c478bd9Sstevel@tonic-gate 	return (cr->pr_sgid);
1927c478bd9Sstevel@tonic-gate }
1937c478bd9Sstevel@tonic-gate 
1947c478bd9Sstevel@tonic-gate int
ucred_getgroups(const ucred_t * uc,const gid_t ** grps)1957c478bd9Sstevel@tonic-gate ucred_getgroups(const ucred_t *uc, const gid_t **grps)
1967c478bd9Sstevel@tonic-gate {
1977c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
1987c478bd9Sstevel@tonic-gate 	const prcred_t *cr = UCCRED(uc);
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate 	if (cr == NULL) {
2017c478bd9Sstevel@tonic-gate 		errno = EINVAL;
2027c478bd9Sstevel@tonic-gate 		return (-1);
2037c478bd9Sstevel@tonic-gate 	}
2047c478bd9Sstevel@tonic-gate 
2057c478bd9Sstevel@tonic-gate 	if (cr->pr_ngroups > 0)
2067c478bd9Sstevel@tonic-gate 		*grps = &cr->pr_groups[0];
2077c478bd9Sstevel@tonic-gate 	else
2087c478bd9Sstevel@tonic-gate 		*grps = NULL;
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate 	return (cr->pr_ngroups);
2117c478bd9Sstevel@tonic-gate }
2127c478bd9Sstevel@tonic-gate 
2137c478bd9Sstevel@tonic-gate const priv_set_t *
ucred_getprivset(const ucred_t * uc,priv_ptype_t set)2147c478bd9Sstevel@tonic-gate ucred_getprivset(const ucred_t *uc, priv_ptype_t set)
2157c478bd9Sstevel@tonic-gate {
2167c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
2177c478bd9Sstevel@tonic-gate 	const prpriv_t *pr = UCPRIV(uc);
2187c478bd9Sstevel@tonic-gate 	int pset = priv_getsetbyname(set);
2197c478bd9Sstevel@tonic-gate 	priv_data_t *d;
2207c478bd9Sstevel@tonic-gate 
2217c478bd9Sstevel@tonic-gate 	if (pr == NULL || pset == -1) {
2227c478bd9Sstevel@tonic-gate 		errno = EINVAL;
2237c478bd9Sstevel@tonic-gate 		return (NULL);
2247c478bd9Sstevel@tonic-gate 	}
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate 	LOADPRIVDATA(d);
2277c478bd9Sstevel@tonic-gate 
2287c478bd9Sstevel@tonic-gate 	return ((const priv_set_t *)
2297c478bd9Sstevel@tonic-gate 	    &pr->pr_sets[d->pd_pinfo->priv_setsize * pset]);
2307c478bd9Sstevel@tonic-gate }
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate pid_t
ucred_getpid(const ucred_t * uc)2337c478bd9Sstevel@tonic-gate ucred_getpid(const ucred_t *uc)
2347c478bd9Sstevel@tonic-gate {
2357c478bd9Sstevel@tonic-gate 
2367c478bd9Sstevel@tonic-gate 	if (uc->uc_pid == -1)
2377c478bd9Sstevel@tonic-gate 		errno = EINVAL;
2387c478bd9Sstevel@tonic-gate 
2397c478bd9Sstevel@tonic-gate 	return (uc->uc_pid);
2407c478bd9Sstevel@tonic-gate }
2417c478bd9Sstevel@tonic-gate 
2427c478bd9Sstevel@tonic-gate projid_t
ucred_getprojid(const ucred_t * uc)2437c478bd9Sstevel@tonic-gate ucred_getprojid(const ucred_t *uc)
2447c478bd9Sstevel@tonic-gate {
2457c478bd9Sstevel@tonic-gate 
2467c478bd9Sstevel@tonic-gate 	if (uc->uc_projid == -1)
2477c478bd9Sstevel@tonic-gate 		errno = EINVAL;
2487c478bd9Sstevel@tonic-gate 
2497c478bd9Sstevel@tonic-gate 	return (uc->uc_projid);
2507c478bd9Sstevel@tonic-gate }
2517c478bd9Sstevel@tonic-gate 
2527c478bd9Sstevel@tonic-gate zoneid_t
ucred_getzoneid(const ucred_t * uc)2537c478bd9Sstevel@tonic-gate ucred_getzoneid(const ucred_t *uc)
2547c478bd9Sstevel@tonic-gate {
2557c478bd9Sstevel@tonic-gate 
2567c478bd9Sstevel@tonic-gate 	if (uc->uc_zoneid < MIN_ZONEID || uc->uc_zoneid > MAX_ZONEID) {
2577c478bd9Sstevel@tonic-gate 		errno = EINVAL;
2587c478bd9Sstevel@tonic-gate 		return (-1);
2597c478bd9Sstevel@tonic-gate 	}
2607c478bd9Sstevel@tonic-gate 
2617c478bd9Sstevel@tonic-gate 	return (uc->uc_zoneid);
2627c478bd9Sstevel@tonic-gate }
2637c478bd9Sstevel@tonic-gate 
26445916cd2Sjpk bslabel_t *
ucred_getlabel(const ucred_t * uc)26545916cd2Sjpk ucred_getlabel(const ucred_t *uc)
26645916cd2Sjpk {
26745916cd2Sjpk 	/* LINTED: alignment */
26845916cd2Sjpk 	bslabel_t *slabel = UCLABEL(uc);
26945916cd2Sjpk 
27045916cd2Sjpk 	if (!is_system_labeled() || slabel == NULL) {
27145916cd2Sjpk 		errno = EINVAL;
27245916cd2Sjpk 		return (NULL);
27345916cd2Sjpk 	}
27445916cd2Sjpk 
27545916cd2Sjpk 	return (slabel);
27645916cd2Sjpk }
27745916cd2Sjpk 
2787c478bd9Sstevel@tonic-gate /*
2797c478bd9Sstevel@tonic-gate  * For now, assume single bit flags.
2807c478bd9Sstevel@tonic-gate  */
2817c478bd9Sstevel@tonic-gate uint_t
ucred_getpflags(const ucred_t * uc,uint_t flag)2827c478bd9Sstevel@tonic-gate ucred_getpflags(const ucred_t *uc, uint_t flag)
2837c478bd9Sstevel@tonic-gate {
2847c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
2857c478bd9Sstevel@tonic-gate 	prpriv_t *pr = UCPRIV(uc);
2867c478bd9Sstevel@tonic-gate 	char *x, *end;
2877c478bd9Sstevel@tonic-gate 
2887c478bd9Sstevel@tonic-gate 	if (pr == NULL) {
2897c478bd9Sstevel@tonic-gate 		errno = EINVAL;
2907c478bd9Sstevel@tonic-gate 		return ((uint_t)-1);
2917c478bd9Sstevel@tonic-gate 	}
2927c478bd9Sstevel@tonic-gate 
2937c478bd9Sstevel@tonic-gate 	end = (char *)pr + PRIV_PRPRIV_SIZE(pr);
2947c478bd9Sstevel@tonic-gate 	x = end - pr->pr_infosize;
2957c478bd9Sstevel@tonic-gate 
2967c478bd9Sstevel@tonic-gate 	while (x < end) {
2977c478bd9Sstevel@tonic-gate 		/* LINTED: alignment */
2987c478bd9Sstevel@tonic-gate 		priv_info_t *pi = (priv_info_t *)x;
2997c478bd9Sstevel@tonic-gate 		priv_info_uint_t *pii;
3007c478bd9Sstevel@tonic-gate 
3017c478bd9Sstevel@tonic-gate 		switch (pi->priv_info_type) {
3027c478bd9Sstevel@tonic-gate 		case PRIV_INFO_FLAGS:
3037c478bd9Sstevel@tonic-gate 			/* LINTED: alignment */
3047c478bd9Sstevel@tonic-gate 			pii = (priv_info_uint_t *)x;
3057c478bd9Sstevel@tonic-gate 			return ((pii->val & flag) ? 1 : 0);
3067c478bd9Sstevel@tonic-gate 		}
3077c478bd9Sstevel@tonic-gate 		/* Forward progress */
3087c478bd9Sstevel@tonic-gate 		if (pi->priv_info_size < sizeof (priv_info_t))
3097c478bd9Sstevel@tonic-gate 			break;
3107c478bd9Sstevel@tonic-gate 		x += pi->priv_info_size;
3117c478bd9Sstevel@tonic-gate 	}
3127c478bd9Sstevel@tonic-gate 
3137c478bd9Sstevel@tonic-gate 	errno = EINVAL;
3147c478bd9Sstevel@tonic-gate 	return ((uint_t)-1);
3157c478bd9Sstevel@tonic-gate }
3167c478bd9Sstevel@tonic-gate 
3177c478bd9Sstevel@tonic-gate au_id_t
ucred_getauid(const ucred_t * uc)3187c478bd9Sstevel@tonic-gate ucred_getauid(const ucred_t *uc)
3197c478bd9Sstevel@tonic-gate {
3207c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
3217c478bd9Sstevel@tonic-gate 	const auditinfo64_addr_t *ainfo = UCAUD(uc);
3227c478bd9Sstevel@tonic-gate 
3237c478bd9Sstevel@tonic-gate 	if (ainfo == NULL)
3247c478bd9Sstevel@tonic-gate 		return (AU_NOAUDITID);
3257c478bd9Sstevel@tonic-gate 
3267c478bd9Sstevel@tonic-gate 	return (ainfo->ai_auid);
3277c478bd9Sstevel@tonic-gate }
3287c478bd9Sstevel@tonic-gate 
3297c478bd9Sstevel@tonic-gate au_asid_t
ucred_getasid(const ucred_t * uc)3307c478bd9Sstevel@tonic-gate ucred_getasid(const ucred_t *uc)
3317c478bd9Sstevel@tonic-gate {
3327c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
3337c478bd9Sstevel@tonic-gate 	const auditinfo64_addr_t *ainfo = UCAUD(uc);
3347c478bd9Sstevel@tonic-gate 
3357c478bd9Sstevel@tonic-gate 	if (ainfo == NULL)
336*d0fa49b7STony Nguyen 		return ((au_asid_t)-1);
3377c478bd9Sstevel@tonic-gate 
3387c478bd9Sstevel@tonic-gate 	return (ainfo->ai_asid);
3397c478bd9Sstevel@tonic-gate }
3407c478bd9Sstevel@tonic-gate 
3417c478bd9Sstevel@tonic-gate const au_tid64_addr_t *
ucred_getatid(const ucred_t * uc)3427c478bd9Sstevel@tonic-gate ucred_getatid(const ucred_t *uc)
3437c478bd9Sstevel@tonic-gate {
3447c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
3457c478bd9Sstevel@tonic-gate 	const auditinfo64_addr_t *ainfo = UCAUD(uc);
3467c478bd9Sstevel@tonic-gate 
3477c478bd9Sstevel@tonic-gate 	if (ainfo == NULL) {
3487c478bd9Sstevel@tonic-gate 		errno = EINVAL;
3497c478bd9Sstevel@tonic-gate 		return (NULL);
3507c478bd9Sstevel@tonic-gate 	}
3517c478bd9Sstevel@tonic-gate 
3527c478bd9Sstevel@tonic-gate 	return (&ainfo->ai_termid);
3537c478bd9Sstevel@tonic-gate }
3547c478bd9Sstevel@tonic-gate 
3557c478bd9Sstevel@tonic-gate const au_mask_t *
ucred_getamask(const ucred_t * uc)3567c478bd9Sstevel@tonic-gate ucred_getamask(const ucred_t *uc)
3577c478bd9Sstevel@tonic-gate {
3587c478bd9Sstevel@tonic-gate 	/* LINTED: alignment */
3597c478bd9Sstevel@tonic-gate 	const auditinfo64_addr_t *ainfo = UCAUD(uc);
3607c478bd9Sstevel@tonic-gate 
3617c478bd9Sstevel@tonic-gate 	if (ainfo == NULL) {
3627c478bd9Sstevel@tonic-gate 		errno = EINVAL;
3637c478bd9Sstevel@tonic-gate 		return (NULL);
3647c478bd9Sstevel@tonic-gate 	}
3657c478bd9Sstevel@tonic-gate 
3667c478bd9Sstevel@tonic-gate 	return (&ainfo->ai_mask);
3677c478bd9Sstevel@tonic-gate }
3687c478bd9Sstevel@tonic-gate 
3697c478bd9Sstevel@tonic-gate size_t
ucred_size(void)3707c478bd9Sstevel@tonic-gate ucred_size(void)
3717c478bd9Sstevel@tonic-gate {
3727c478bd9Sstevel@tonic-gate 	priv_data_t *d;
3737c478bd9Sstevel@tonic-gate 
3747c478bd9Sstevel@tonic-gate 	LOADPRIVDATA(d);
3757c478bd9Sstevel@tonic-gate 
3767c478bd9Sstevel@tonic-gate 	return (d->pd_ucredsize);
3777c478bd9Sstevel@tonic-gate }
378