17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
545916cdjpk * Common Development and Distribution License (the "License").
645916cdjpk * You may not use this file except in compliance with the License.
77c478bdstevel@tonic-gate *
87c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bdstevel@tonic-gate * See the License for the specific language governing permissions
117c478bdstevel@tonic-gate * and limitations under the License.
127c478bdstevel@tonic-gate *
137c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bdstevel@tonic-gate *
197c478bdstevel@tonic-gate * CDDL HEADER END
207c478bdstevel@tonic-gate */
217c478bdstevel@tonic-gate/*
228249a45Jan Friedel * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
237c478bdstevel@tonic-gate * Use is subject to license terms.
2433f5ff1Milan Jurik * Copyright 2012 Milan Jurik. All rights reserved.
257c478bdstevel@tonic-gate */
267c478bdstevel@tonic-gate
277c478bdstevel@tonic-gate
287c478bdstevel@tonic-gate/*
297c478bdstevel@tonic-gate * Token processing for auditreduce.
307c478bdstevel@tonic-gate */
317c478bdstevel@tonic-gate
327c478bdstevel@tonic-gate#include <locale.h>
337c478bdstevel@tonic-gate#include <sys/zone.h>
347c478bdstevel@tonic-gate#include "auditr.h"
357c478bdstevel@tonic-gate#include "toktable.h"
367c478bdstevel@tonic-gate
377c478bdstevel@tonic-gateextern int	re_exec2(char *);
387c478bdstevel@tonic-gate
397c478bdstevel@tonic-gatestatic void	anchor_path(char *path);
407c478bdstevel@tonic-gatestatic char	*collapse_path(char *s);
417c478bdstevel@tonic-gatestatic void	get_string(adr_t *adr, char **p);
427c478bdstevel@tonic-gatestatic int	ipc_type_match(int flag, char type);
437c478bdstevel@tonic-gatestatic void	skip_string(adr_t *adr);
447c478bdstevel@tonic-gatestatic int	xgeneric(adr_t *adr);
457c478bdstevel@tonic-gate
467c478bdstevel@tonic-gate#if	AUDIT_REC
477c478bdstevel@tonic-gatevoid
487c478bdstevel@tonic-gateprint_id(int id)
497c478bdstevel@tonic-gate{
507c478bdstevel@tonic-gate	char *suffix;
517c478bdstevel@tonic-gate
527c478bdstevel@tonic-gate	if ((id < 0) || (id > MAXTOKEN) ||
537c478bdstevel@tonic-gate	    (tokentable[id].func == NOFUNC)) {
547c478bdstevel@tonic-gate		(void) fprintf(stderr,
557c478bdstevel@tonic-gate		    "token_processing: token %d not found\n", id);
567c478bdstevel@tonic-gate		return;
577c478bdstevel@tonic-gate	}
587c478bdstevel@tonic-gate
597c478bdstevel@tonic-gate	switch (id) {
607c478bdstevel@tonic-gate	case AUT_NEWGROUPS:
617c478bdstevel@tonic-gate		suffix = "_new";
627c478bdstevel@tonic-gate		break;
637c478bdstevel@tonic-gate	case AUT_ATTR32:
647c478bdstevel@tonic-gate		suffix = "32";
657c478bdstevel@tonic-gate		break;
667c478bdstevel@tonic-gate	case AUT_ARG64:
677c478bdstevel@tonic-gate	case AUT_RETURN64:
687c478bdstevel@tonic-gate	case AUT_ATTR64:
697c478bdstevel@tonic-gate	case AUT_HEADER64:
707c478bdstevel@tonic-gate	case AUT_SUBJECT64:
717c478bdstevel@tonic-gate	case AUT_PROCESS64:
727c478bdstevel@tonic-gate	case AUT_OTHER_FILE64:
737c478bdstevel@tonic-gate		suffix = "64";
747c478bdstevel@tonic-gate		break;
757c478bdstevel@tonic-gate	case AUT_SOCKET_EX:
767c478bdstevel@tonic-gate	case AUT_IN_ADDR_EX:
777c478bdstevel@tonic-gate		suffix = "_ex";
787c478bdstevel@tonic-gate		break;
797c478bdstevel@tonic-gate	case AUT_HEADER32_EX:
807c478bdstevel@tonic-gate	case AUT_SUBJECT32_EX:
817c478bdstevel@tonic-gate	case AUT_PROCESS32_EX:
827c478bdstevel@tonic-gate		suffix = "32_ex";
837c478bdstevel@tonic-gate		break;
847c478bdstevel@tonic-gate	case AUT_HEADER64_EX:
857c478bdstevel@tonic-gate	case AUT_SUBJECT64_EX:
867c478bdstevel@tonic-gate	case AUT_PROCESS64_EX:
877c478bdstevel@tonic-gate		suffix = "64_ex";
887c478bdstevel@tonic-gate		break;
897c478bdstevel@tonic-gate	default:
907c478bdstevel@tonic-gate		suffix = "";
917c478bdstevel@tonic-gate		break;
927c478bdstevel@tonic-gate	}
937c478bdstevel@tonic-gate	(void) fprintf(stderr, "token_processing: %s%s\n",
947c478bdstevel@tonic-gate	    tokentable[id].t_name, suffix);
957c478bdstevel@tonic-gate}
967c478bdstevel@tonic-gate#endif	/* AUDIT_REC */
977c478bdstevel@tonic-gate
987c478bdstevel@tonic-gate/*
997c478bdstevel@tonic-gate * Process a token in a record to determine whether the record is interesting.
1007c478bdstevel@tonic-gate */
1017c478bdstevel@tonic-gate
1027c478bdstevel@tonic-gateint
1037c478bdstevel@tonic-gatetoken_processing(adr_t *adr, int tokenid)
1047c478bdstevel@tonic-gate{
1057c478bdstevel@tonic-gate	if ((tokenid > 0) && (tokenid <= MAXTOKEN) &&
1067c478bdstevel@tonic-gate	    (tokentable[tokenid].func != NOFUNC)) {
1077c478bdstevel@tonic-gate#if	AUDIT_REC
1087c478bdstevel@tonic-gate		print_id(tokenid);
1097c478bdstevel@tonic-gate#endif	/* AUDIT_REC */
1107c478bdstevel@tonic-gate		return ((*tokentable[tokenid].func)(adr));
1117c478bdstevel@tonic-gate	}
1127c478bdstevel@tonic-gate
1137c478bdstevel@tonic-gate	/* here if token id is not in table */
1147c478bdstevel@tonic-gate	return (-2);
1157c478bdstevel@tonic-gate}
1167c478bdstevel@tonic-gate
1177c478bdstevel@tonic-gate
1187c478bdstevel@tonic-gate/* There should not be any file or header tokens in the middle of a record */
1197c478bdstevel@tonic-gate
1207c478bdstevel@tonic-gate/* ARGSUSED */
1217c478bdstevel@tonic-gateint
1227c478bdstevel@tonic-gatefile_token(adr_t *adr)
1237c478bdstevel@tonic-gate{
1247c478bdstevel@tonic-gate	return (-2);
1257c478bdstevel@tonic-gate}
1267c478bdstevel@tonic-gate
1277c478bdstevel@tonic-gate/* ARGSUSED */
1287c478bdstevel@tonic-gateint
1297c478bdstevel@tonic-gatefile64_token(adr_t *adr)
1307c478bdstevel@tonic-gate{
1317c478bdstevel@tonic-gate	return (-2);
1327c478bdstevel@tonic-gate}
1337c478bdstevel@tonic-gate
1347c478bdstevel@tonic-gate/* ARGSUSED */
1357c478bdstevel@tonic-gateint
1367c478bdstevel@tonic-gateheader_token(adr_t *adr)
1377c478bdstevel@tonic-gate{
1387c478bdstevel@tonic-gate	return (-2);
1397c478bdstevel@tonic-gate}
1407c478bdstevel@tonic-gate
1417c478bdstevel@tonic-gate/* ARGSUSED */
1427c478bdstevel@tonic-gateint
1437c478bdstevel@tonic-gateheader32_ex_token(adr_t *adr)
1447c478bdstevel@tonic-gate{
1457c478bdstevel@tonic-gate	return (-2);
1467c478bdstevel@tonic-gate}
1477c478bdstevel@tonic-gate
1487c478bdstevel@tonic-gate/* ARGSUSED */
1497c478bdstevel@tonic-gateint
1507c478bdstevel@tonic-gateheader64_ex_token(adr_t *adr)
1517c478bdstevel@tonic-gate{
1527c478bdstevel@tonic-gate	return (-2);
1537c478bdstevel@tonic-gate}
1547c478bdstevel@tonic-gate
1557c478bdstevel@tonic-gate/* ARGSUSED */
1567c478bdstevel@tonic-gateint
1577c478bdstevel@tonic-gateheader64_token(adr_t *adr)
1587c478bdstevel@tonic-gate{
1597c478bdstevel@tonic-gate	return (-2);
1607c478bdstevel@tonic-gate}
1617c478bdstevel@tonic-gate
1627c478bdstevel@tonic-gate
1637c478bdstevel@tonic-gate/*
1647c478bdstevel@tonic-gate * ======================================================
1657c478bdstevel@tonic-gate *  The following token processing routines return
1667c478bdstevel@tonic-gate *  -1: if the record is not interesting
1677c478bdstevel@tonic-gate *  -2: if an error is found
1687c478bdstevel@tonic-gate * ======================================================
1697c478bdstevel@tonic-gate */
1707c478bdstevel@tonic-gate
1717c478bdstevel@tonic-gateint
1727c478bdstevel@tonic-gatetrailer_token(adr_t *adr)
1737c478bdstevel@tonic-gate{
1747c478bdstevel@tonic-gate	short	magic_number;
1757c478bdstevel@tonic-gate	uint32_t bytes;
1767c478bdstevel@tonic-gate
1777c478bdstevel@tonic-gate	adrm_u_short(adr, (ushort_t *)&magic_number, 1);
1787c478bdstevel@tonic-gate	if (magic_number != AUT_TRAILER_MAGIC) {
1797c478bdstevel@tonic-gate		(void) fprintf(stderr, "%s\n",
180a7746f6tz		    gettext("auditreduce: Bad trailer token"));
1817c478bdstevel@tonic-gate		return (-2);
1827c478bdstevel@tonic-gate	}
1837c478bdstevel@tonic-gate	adrm_u_int32(adr, &bytes, 1);
1847c478bdstevel@tonic-gate
1857c478bdstevel@tonic-gate	return (-1);
1867c478bdstevel@tonic-gate}
1877c478bdstevel@tonic-gate
1887c478bdstevel@tonic-gate
1897c478bdstevel@tonic-gate/*
1907c478bdstevel@tonic-gate * Format of arbitrary data token:
1917c478bdstevel@tonic-gate *	arbitrary data token id	adr char
1927c478bdstevel@tonic-gate * 	how to print		adr_char
1937c478bdstevel@tonic-gate *	basic unit		adr_char
1947c478bdstevel@tonic-gate *	unit count		adr_char, specifying number of units of
1957c478bdstevel@tonic-gate *	data items		depends on basic unit
1967c478bdstevel@tonic-gate */
1977c478bdstevel@tonic-gateint
1987c478bdstevel@tonic-gatearbitrary_data_token(adr_t *adr)
1997c478bdstevel@tonic-gate{
2007c478bdstevel@tonic-gate	int	i;
2017c478bdstevel@tonic-gate	char	c1;
2027c478bdstevel@tonic-gate	short	c2;
2037c478bdstevel@tonic-gate	int32_t	c3;
2047c478bdstevel@tonic-gate	int64_t c4;
2057c478bdstevel@tonic-gate	char	how_to_print, basic_unit, unit_count;
2067c478bdstevel@tonic-gate
2077c478bdstevel@tonic-gate	/* get how_to_print, basic_unit, and unit_count */
2087c478bdstevel@tonic-gate	adrm_char(adr, &how_to_print, 1);
2097c478bdstevel@tonic-gate	adrm_char(adr, &basic_unit, 1);
2107c478bdstevel@tonic-gate	adrm_char(adr, &unit_count, 1);
2117c478bdstevel@tonic-gate	for (i = 0; i < unit_count; i++) {
2127c478bdstevel@tonic-gate		switch (basic_unit) {
2137c478bdstevel@tonic-gate			/* case AUR_BYTE: has same value as AUR_CHAR */
2147c478bdstevel@tonic-gate		case AUR_CHAR:
2157c478bdstevel@tonic-gate			adrm_char(adr, &c1, 1);
2167c478bdstevel@tonic-gate			break;
2177c478bdstevel@tonic-gate		case AUR_SHORT:
2187c478bdstevel@tonic-gate			adrm_short(adr, &c2, 1);
2197c478bdstevel@tonic-gate			break;
2207c478bdstevel@tonic-gate		case AUR_INT32:
2217c478bdstevel@tonic-gate			adrm_int32(adr, (int32_t *)&c3, 1);
2227c478bdstevel@tonic-gate			break;
2237c478bdstevel@tonic-gate		case AUR_INT64:
2247c478bdstevel@tonic-gate			adrm_int64(adr, (int64_t *)&c4, 1);
2257c478bdstevel@tonic-gate			break;
2267c478bdstevel@tonic-gate		default:
2277c478bdstevel@tonic-gate			return (-2);
2287c478bdstevel@tonic-gate		}
2297c478bdstevel@tonic-gate	}
2307c478bdstevel@tonic-gate	return (-1);
2317c478bdstevel@tonic-gate}
2327c478bdstevel@tonic-gate
2337c478bdstevel@tonic-gate
2347c478bdstevel@tonic-gate/*
2357c478bdstevel@tonic-gate * Format of opaque token:
2367c478bdstevel@tonic-gate *	opaque token id		adr_char
2377c478bdstevel@tonic-gate *	size			adr_short
2387c478bdstevel@tonic-gate *	data			adr_char, size times
2397c478bdstevel@tonic-gate */
2407c478bdstevel@tonic-gateint
2417c478bdstevel@tonic-gateopaque_token(adr_t *adr)
2427c478bdstevel@tonic-gate{
2437c478bdstevel@tonic-gate	skip_string(adr);
2447c478bdstevel@tonic-gate	return (-1);
2457c478bdstevel@tonic-gate}
2467c478bdstevel@tonic-gate
2477c478bdstevel@tonic-gate
2487c478bdstevel@tonic-gate
2497c478bdstevel@tonic-gate/*
2507c478bdstevel@tonic-gate * Format of return32 value token:
2517c478bdstevel@tonic-gate * 	return value token id	adr_char
2527c478bdstevel@tonic-gate *	error number		adr_char
2537c478bdstevel@tonic-gate *	return value		adr_u_int32
2547c478bdstevel@tonic-gate */
2557c478bdstevel@tonic-gateint
2567c478bdstevel@tonic-gatereturn_value32_token(adr_t *adr)
2577c478bdstevel@tonic-gate{
2587c478bdstevel@tonic-gate	char		errnum;
2597c478bdstevel@tonic-gate	uint32_t	value;
2607c478bdstevel@tonic-gate
2617c478bdstevel@tonic-gate	adrm_char(adr, &errnum, 1);
2627c478bdstevel@tonic-gate	adrm_u_int32(adr, &value, 1);
2637c478bdstevel@tonic-gate	if ((flags & M_SORF) &&
264a7746f6tz	    ((global_class & mask.am_success) && (errnum == 0)) ||
265a7746f6tz	    ((global_class & mask.am_failure) && (errnum != 0))) {
266a7746f6tz		checkflags |= M_SORF;
2677c478bdstevel@tonic-gate	}
2687c478bdstevel@tonic-gate	return (-1);
2697c478bdstevel@tonic-gate}
2707c478bdstevel@tonic-gate
2717c478bdstevel@tonic-gate/*
2727c478bdstevel@tonic-gate * Format of return64 value token:
2737c478bdstevel@tonic-gate * 	return value token id	adr_char
2747c478bdstevel@tonic-gate *	error number		adr_char
2757c478bdstevel@tonic-gate *	return value		adr_u_int64
2767c478bdstevel@tonic-gate */
2777c478bdstevel@tonic-gateint
2787c478bdstevel@tonic-gatereturn_value64_token(adr_t *adr)
2797c478bdstevel@tonic-gate{
2807c478bdstevel@tonic-gate	char		errnum;
2817c478bdstevel@tonic-gate	uint64_t	value;
2827c478bdstevel@tonic-gate
2837c478bdstevel@tonic-gate	adrm_char(adr, &errnum, 1);
2847c478bdstevel@tonic-gate	adrm_u_int64(adr, &value, 1);
2857c478bdstevel@tonic-gate	if ((flags & M_SORF) &&
286a7746f6tz	    ((global_class & mask.am_success) && (errnum == 0)) ||
287a7746f6tz	    ((global_class & mask.am_failure) && (errnum != 0))) {
288a7746f6tz		checkflags |= M_SORF;
2897c478bdstevel@tonic-gate	}
2907c478bdstevel@tonic-gate	return (-1);
2917c478bdstevel@tonic-gate}
2927c478bdstevel@tonic-gate
2937c478bdstevel@tonic-gate
2947c478bdstevel@tonic-gate/*
2957c478bdstevel@tonic-gate * Format of sequence token:
2967c478bdstevel@tonic-gate *	sequence token id	adr_char
2977c478bdstevel@tonic-gate *	audit_count		int32_t
2987c478bdstevel@tonic-gate */
2997c478bdstevel@tonic-gateint
3007c478bdstevel@tonic-gatesequence_token(adr_t *adr)
3017c478bdstevel@tonic-gate{
3027c478bdstevel@tonic-gate	int32_t	audit_count;
3037c478bdstevel@tonic-gate
3047c478bdstevel@tonic-gate	adrm_int32(adr, &audit_count, 1);
3057c478bdstevel@tonic-gate	return (-1);
3067c478bdstevel@tonic-gate}
3077c478bdstevel@tonic-gate
3087c478bdstevel@tonic-gate
3097c478bdstevel@tonic-gate/*
3107c478bdstevel@tonic-gate * Format of text token:
3117c478bdstevel@tonic-gate *	text token id		adr_char
3127c478bdstevel@tonic-gate * 	text			adr_string
3137c478bdstevel@tonic-gate */
3147c478bdstevel@tonic-gateint
3157c478bdstevel@tonic-gatetext_token(adr_t *adr)
3167c478bdstevel@tonic-gate{
3177c478bdstevel@tonic-gate	skip_string(adr);
3187c478bdstevel@tonic-gate	return (-1);
3197c478bdstevel@tonic-gate}
3207c478bdstevel@tonic-gate
3217c478bdstevel@tonic-gate
3227c478bdstevel@tonic-gate/*
3237c478bdstevel@tonic-gate * Format of ip_addr token:
3247c478bdstevel@tonic-gate *	ip token id	adr_char
3257c478bdstevel@tonic-gate *	address		adr_int32
3267c478bdstevel@tonic-gate */
3277c478bdstevel@tonic-gateint
3287c478bdstevel@tonic-gateip_addr_token(adr_t *adr)
3297c478bdstevel@tonic-gate{
3307c478bdstevel@tonic-gate	int32_t	address;
3317c478bdstevel@tonic-gate
3327c478bdstevel@tonic-gate	adrm_char(adr, (char *)&address, 4);
3337c478bdstevel@tonic-gate
3347c478bdstevel@tonic-gate	return (-1);
3357c478bdstevel@tonic-gate}
3367c478bdstevel@tonic-gate
3377c478bdstevel@tonic-gate/*
3387c478bdstevel@tonic-gate * Format of ip_addr_ex token:
3397c478bdstevel@tonic-gate *	ip token id	adr_char
3407c478bdstevel@tonic-gate *	ip type		adr_int32
3418249a45Jan Friedel *	ip address	adr_u_char*type
3427c478bdstevel@tonic-gate */
3437c478bdstevel@tonic-gateint
3447c478bdstevel@tonic-gateip_addr_ex_token(adr_t *adr)
3457c478bdstevel@tonic-gate{
3467c478bdstevel@tonic-gate	int32_t type;
3478249a45Jan Friedel	uchar_t	address[16];
3487c478bdstevel@tonic-gate
3497c478bdstevel@tonic-gate	adrm_int32(adr, (int32_t *)&type, 1);
3508249a45Jan Friedel	adrm_u_char(adr, address, type);
3517c478bdstevel@tonic-gate
3527c478bdstevel@tonic-gate	return (-1);
3537c478bdstevel@tonic-gate}
3547c478bdstevel@tonic-gate
3557c478bdstevel@tonic-gate/*
3567c478bdstevel@tonic-gate * Format of ip token:
3577c478bdstevel@tonic-gate *	ip header token id	adr_char
3587c478bdstevel@tonic-gate *	version			adr_char
3597c478bdstevel@tonic-gate *	type of service		adr_char
3607c478bdstevel@tonic-gate *	length			adr_short
3617c478bdstevel@tonic-gate *	id			adr_u_short
3627c478bdstevel@tonic-gate *	offset			adr_u_short
3637c478bdstevel@tonic-gate *	ttl			adr_char
3647c478bdstevel@tonic-gate *	protocol		adr_char
3657c478bdstevel@tonic-gate *	checksum		adr_u_short
3667c478bdstevel@tonic-gate *	source address		adr_int32
3677c478bdstevel@tonic-gate *	destination address	adr_int32
3687c478bdstevel@tonic-gate */
3697c478bdstevel@tonic-gateint
3707c478bdstevel@tonic-gateip_token(adr_t *adr)
3717c478bdstevel@tonic-gate{
3727c478bdstevel@tonic-gate	char	version;
3737c478bdstevel@tonic-gate	char	type;
3747c478bdstevel@tonic-gate	short	len;
3757c478bdstevel@tonic-gate	unsigned short	id, offset, checksum;
3767c478bdstevel@tonic-gate	char	ttl, protocol;
3777c478bdstevel@tonic-gate	int32_t	src, dest;
3787c478bdstevel@tonic-gate
3797c478bdstevel@tonic-gate	adrm_char(adr, &version, 1);
3807c478bdstevel@tonic-gate	adrm_char(adr, &type, 1);
3817c478bdstevel@tonic-gate	adrm_short(adr, &len, 1);
3827c478bdstevel@tonic-gate	adrm_u_short(adr, &id, 1);
3837c478bdstevel@tonic-gate	adrm_u_short(adr, &offset, 1);
3847c478bdstevel@tonic-gate	adrm_char(adr, &ttl, 1);
3857c478bdstevel@tonic-gate	adrm_char(adr, &protocol, 1);
3867c478bdstevel@tonic-gate	adrm_u_short(adr, &checksum, 1);
3877c478bdstevel@tonic-gate	adrm_char(adr, (char *)&src, 4);
3887c478bdstevel@tonic-gate	adrm_char(adr, (char *)&dest, 4);
3897c478bdstevel@tonic-gate
3907c478bdstevel@tonic-gate	return (-1);
3917c478bdstevel@tonic-gate}
3927c478bdstevel@tonic-gate
3937c478bdstevel@tonic-gate
3947c478bdstevel@tonic-gate/*
3957c478bdstevel@tonic-gate * Format of iport token:
3967c478bdstevel@tonic-gate *	ip port address token id	adr_char
3977c478bdstevel@tonic-gate *	port address			adr_short
3987c478bdstevel@tonic-gate */
3997c478bdstevel@tonic-gateint
4007c478bdstevel@tonic-gateiport_token(adr_t *adr)
4017c478bdstevel@tonic-gate{
4027c478bdstevel@tonic-gate	short	address;
4037c478bdstevel@tonic-gate
4047c478bdstevel@tonic-gate	adrm_short(adr, &address, 1);
4057c478bdstevel@tonic-gate
4067c478bdstevel@tonic-gate	return (-1);
4077c478bdstevel@tonic-gate}
4087c478bdstevel@tonic-gate
4097c478bdstevel@tonic-gate
4107c478bdstevel@tonic-gate/*
4117c478bdstevel@tonic-gate * Format of groups token:
4127c478bdstevel@tonic-gate *	group token id		adr_char
4137c478bdstevel@tonic-gate *	group list		adr_int32, 16 times
4147c478bdstevel@tonic-gate */
4157c478bdstevel@tonic-gateint
4167c478bdstevel@tonic-gategroup_token(adr_t *adr)
4177c478bdstevel@tonic-gate{
4187c478bdstevel@tonic-gate	int	gid[16];
4197c478bdstevel@tonic-gate	int	i;
4207c478bdstevel@tonic-gate	int	flag = 0;
4217c478bdstevel@tonic-gate
4227c478bdstevel@tonic-gate	for (i = 0; i < 16; i++) {
4237c478bdstevel@tonic-gate		adrm_int32(adr, (int32_t *)&gid[i], 1);
4247c478bdstevel@tonic-gate		if (flags & M_GROUPR) {
4257c478bdstevel@tonic-gate			if ((unsigned short)m_groupr == gid[i])
4267c478bdstevel@tonic-gate				flag = 1;
4277c478bdstevel@tonic-gate		}
4287c478bdstevel@tonic-gate	}
4297c478bdstevel@tonic-gate
4307c478bdstevel@tonic-gate	if (flags & M_GROUPR) {
4317c478bdstevel@tonic-gate		if (flag)
4327c478bdstevel@tonic-gate			checkflags |= M_GROUPR;
4337c478bdstevel@tonic-gate	}
4347c478bdstevel@tonic-gate	return (-1);
4357c478bdstevel@tonic-gate}
4367c478bdstevel@tonic-gate
4377c478bdstevel@tonic-gate/*
4387c478bdstevel@tonic-gate * Format of newgroups token:
4397c478bdstevel@tonic-gate *	group token id		adr_char
4407c478bdstevel@tonic-gate *	number of groups	adr_short
4417c478bdstevel@tonic-gate *	group list		adr_int32, "number" times
4427c478bdstevel@tonic-gate */
4437c478bdstevel@tonic-gateint
4447c478bdstevel@tonic-gatenewgroup_token(adr_t *adr)
4457c478bdstevel@tonic-gate{
4467c478bdstevel@tonic-gate	gid_t	gid;
4477c478bdstevel@tonic-gate	int	i;
4487c478bdstevel@tonic-gate	short int   number;
4497c478bdstevel@tonic-gate
4507c478bdstevel@tonic-gate	adrm_short(adr, &number, 1);
4517c478bdstevel@tonic-gate
4527c478bdstevel@tonic-gate	for (i = 0; i < number; i++) {
4537c478bdstevel@tonic-gate		adrm_int32(adr, (int32_t *)&gid, 1);
4547c478bdstevel@tonic-gate		if (flags & M_GROUPR) {
4557c478bdstevel@tonic-gate			if (m_groupr == gid)
4567c478bdstevel@tonic-gate				checkflags |= M_GROUPR;
4577c478bdstevel@tonic-gate		}
4587c478bdstevel@tonic-gate	}
4597c478bdstevel@tonic-gate
4607c478bdstevel@tonic-gate	return (-1);
4617c478bdstevel@tonic-gate}
4627c478bdstevel@tonic-gate
4637c478bdstevel@tonic-gate/*
4647c478bdstevel@tonic-gate * Format of argument32 token:
4657c478bdstevel@tonic-gate *	argument token id	adr_char
4667c478bdstevel@tonic-gate *	argument number		adr_char
4677c478bdstevel@tonic-gate *	argument value		adr_int32
4687c478bdstevel@tonic-gate *	argument description	adr_string
4697c478bdstevel@tonic-gate */
4707c478bdstevel@tonic-gateint
4717c478bdstevel@tonic-gateargument32_token(adr_t *adr)
4727c478bdstevel@tonic-gate{
4737c478bdstevel@tonic-gate	char	arg_num;
4747c478bdstevel@tonic-gate	int32_t	arg_val;
4757c478bdstevel@tonic-gate
4767c478bdstevel@tonic-gate	adrm_char(adr, &arg_num, 1);
4777c478bdstevel@tonic-gate	adrm_int32(adr, &arg_val, 1);
4787c478bdstevel@tonic-gate	skip_string(adr);
4797c478bdstevel@tonic-gate
4807c478bdstevel@tonic-gate	return (-1);
4817c478bdstevel@tonic-gate}
4827c478bdstevel@tonic-gate
4837c478bdstevel@tonic-gate/*
4847c478bdstevel@tonic-gate * Format of argument64 token:
4857c478bdstevel@tonic-gate *	argument token id	adr_char
4867c478bdstevel@tonic-gate *	argument number		adr_char
4877c478bdstevel@tonic-gate *	argument value		adr_int64
4887c478bdstevel@tonic-gate *	argument description	adr_string
4897c478bdstevel@tonic-gate */
4907c478bdstevel@tonic-gateint
4917c478bdstevel@tonic-gateargument64_token(adr_t *adr)
4927c478bdstevel@tonic-gate{
4937c478bdstevel@tonic-gate	char	arg_num;
4947c478bdstevel@tonic-gate	int64_t	arg_val;
4957c478bdstevel@tonic-gate
4967c478bdstevel@tonic-gate	adrm_char(adr, &arg_num, 1);
4977c478bdstevel@tonic-gate	adrm_int64(adr, &arg_val, 1);
4987c478bdstevel@tonic-gate	skip_string(adr);
4997c478bdstevel@tonic-gate
5007c478bdstevel@tonic-gate	return (-1);
5017c478bdstevel@tonic-gate}
5027c478bdstevel@tonic-gate
503a7746f6tz/*
504a7746f6tz * Format of acl token:
505a7746f6tz *	acl token id		adr_char
506a7746f6tz *	acl type		adr_u_int32
507a7746f6tz *	acl value		adr_u_int32 (depends on type)
508a7746f6tz *	file mode		adr_u_int (in octal)
509a7746f6tz */
5107c478bdstevel@tonic-gateint
5117c478bdstevel@tonic-gateacl_token(adr_t *adr)
5127c478bdstevel@tonic-gate{
5137c478bdstevel@tonic-gate
5147c478bdstevel@tonic-gate	int32_t	id;
5157c478bdstevel@tonic-gate	int32_t	mode;
5167c478bdstevel@tonic-gate	int32_t	type;
5177c478bdstevel@tonic-gate
5187c478bdstevel@tonic-gate	adrm_int32(adr, &type, 1);
5197c478bdstevel@tonic-gate	adrm_int32(adr, &id, 1);
5207c478bdstevel@tonic-gate	adrm_int32(adr, &mode, 1);
5217c478bdstevel@tonic-gate
5227c478bdstevel@tonic-gate	return (-1);
5237c478bdstevel@tonic-gate}
5247c478bdstevel@tonic-gate
5257c478bdstevel@tonic-gate/*
526a7746f6tz * Format of ace token:
527a7746f6tz *	ace token id		adr_char
528a7746f6tz *	ace who			adr_u_int32 (uid/gid)
529a7746f6tz *	access mask		adr_u_int32
530a7746f6tz *	ace flags		adr_u_int16
531a7746f6tz *	ace type		adr_u_int16
532a7746f6tz */
533a7746f6tzint
534a7746f6tzace_token(adr_t *adr)
535a7746f6tz{
536a7746f6tz	uid_t		who;
537a7746f6tz	uint32_t	access_mask;
538a7746f6tz	uint16_t	flags, type;
539a7746f6tz
540a7746f6tz	adrm_uid(adr, &who, 1);
541a7746f6tz	adrm_u_int32(adr, &access_mask, 1);
542a7746f6tz	adrm_u_short(adr, &flags, 1);
543a7746f6tz	adrm_u_short(adr, &type, 1);
544a7746f6tz
545a7746f6tz	return (-1);
546a7746f6tz}
547a7746f6tz
548a7746f6tz/*
5497c478bdstevel@tonic-gate * Format of attribute token: (old pre SunOS 5.7 format)
5507c478bdstevel@tonic-gate *	attribute token id	adr_char
5517c478bdstevel@tonic-gate * 	mode			adr_int32 (printed in octal)
5527c478bdstevel@tonic-gate *	uid			adr_int32
5537c478bdstevel@tonic-gate *	gid			adr_int32
5547c478bdstevel@tonic-gate *	file system id		adr_int32
5557c478bdstevel@tonic-gate *	node id			adr_int32
5567c478bdstevel@tonic-gate *	device			adr_int32
5577c478bdstevel@tonic-gate */
5587c478bdstevel@tonic-gateint
5597c478bdstevel@tonic-gateattribute_token(adr_t *adr)
5607c478bdstevel@tonic-gate{
5617c478bdstevel@tonic-gate	int32_t	dev;
5627c478bdstevel@tonic-gate	int32_t	file_sysid;
5637c478bdstevel@tonic-gate	int32_t	gid;
5647c478bdstevel@tonic-gate	int32_t	mode;
5657c478bdstevel@tonic-gate	int32_t	nodeid;
5667c478bdstevel@tonic-gate	int32_t	uid;
5677c478bdstevel@tonic-gate
5687c478bdstevel@tonic-gate	adrm_int32(adr, &mode, 1);
5697c478bdstevel@tonic-gate	adrm_int32(adr, &uid, 1);
5707c478bdstevel@tonic-gate	adrm_int32(adr, &gid, 1);
5717c478bdstevel@tonic-gate	adrm_int32(adr, &file_sysid, 1);
5727c478bdstevel@tonic-gate	adrm_int32(adr, &nodeid, 1);
5737c478bdstevel@tonic-gate	adrm_int32(adr, &dev, 1);
5747c478bdstevel@tonic-gate
5757c478bdstevel@tonic-gate	if (!new_mode && (flags & M_USERE)) {
5767c478bdstevel@tonic-gate		if (m_usere == uid)
5777c478bdstevel@tonic-gate			checkflags |= M_USERE;
5787c478bdstevel@tonic-gate	}
5797c478bdstevel@tonic-gate	if (!new_mode && (flags & M_GROUPE)) {
5807c478bdstevel@tonic-gate		if (m_groupe == gid)
5817c478bdstevel@tonic-gate			checkflags |= M_GROUPE;
5827c478bdstevel@tonic-gate	}
5837c478bdstevel@tonic-gate
5847c478bdstevel@tonic-gate	if (flags & M_OBJECT) {
5857c478bdstevel@tonic-gate		if ((obj_flag & OBJ_FGROUP) &&
5867c478bdstevel@tonic-gate		    (obj_group == gid))
5877c478bdstevel@tonic-gate			checkflags |= M_OBJECT;
5887c478bdstevel@tonic-gate		else if ((obj_flag & OBJ_FOWNER) &&
5897c478bdstevel@tonic-gate		    (obj_owner == uid))
5907c478bdstevel@tonic-gate			checkflags |= M_OBJECT;
5917c478bdstevel@tonic-gate	}
5927c478bdstevel@tonic-gate	return (-1);
5937c478bdstevel@tonic-gate}
5947c478bdstevel@tonic-gate
5957c478bdstevel@tonic-gate/*
5967c478bdstevel@tonic-gate * Format of attribute32 token:
5977c478bdstevel@tonic-gate *	attribute token id	adr_char
5987c478bdstevel@tonic-gate * 	mode			adr_int32 (printed in octal)
5997c478bdstevel@tonic-gate *	uid			adr_int32
6007c478bdstevel@tonic-gate *	gid			adr_int32
6017c478bdstevel@tonic-gate *	file system id		adr_int32
6027c478bdstevel@tonic-gate *	node id			adr_int64
6037c478bdstevel@tonic-gate *	device			adr_int32
6047c478bdstevel@tonic-gate */
6057c478bdstevel@tonic-gateint
6067c478bdstevel@tonic-gateattribute32_token(adr_t *adr)
6077c478bdstevel@tonic-gate{
6087c478bdstevel@tonic-gate	int32_t	dev;
6097c478bdstevel@tonic-gate	int32_t	file_sysid;
6107c478bdstevel@tonic-gate	int32_t	gid;
6117c478bdstevel@tonic-gate	int32_t	mode;
6127c478bdstevel@tonic-gate	int64_t	nodeid;
6137c478bdstevel@tonic-gate	int32_t	uid;
6147c478bdstevel@tonic-gate
6157c478bdstevel@tonic-gate	adrm_int32(adr, &mode, 1);
6167c478bdstevel@tonic-gate	adrm_int32(adr, &uid, 1);
6177c478bdstevel@tonic-gate	adrm_int32(adr, &gid, 1);
6187c478bdstevel@tonic-gate	adrm_int32(adr, &file_sysid, 1);
6197c478bdstevel@tonic-gate	adrm_int64(adr, &nodeid, 1);
6207c478bdstevel@tonic-gate	adrm_int32(adr, &dev, 1);
6217c478bdstevel@tonic-gate
6227c478bdstevel@tonic-gate	if (!new_mode && (flags & M_USERE)) {
6237c478bdstevel@tonic-gate		if (m_usere == uid)
6247c478bdstevel@tonic-gate			checkflags |= M_USERE;
6257c478bdstevel@tonic-gate	}
6267c478bdstevel@tonic-gate	if (!new_mode && (flags & M_GROUPE)) {
6277c478bdstevel@tonic-gate		if (m_groupe == gid)
6287c478bdstevel@tonic-gate			checkflags |= M_GROUPE;
6297c478bdstevel@tonic-gate	}
6307c478bdstevel@tonic-gate
6317c478bdstevel@tonic-gate	if (flags & M_OBJECT) {
6327c478bdstevel@tonic-gate		if ((obj_flag & OBJ_FGROUP) &&
6337c478bdstevel@tonic-gate		    (obj_group == gid))
6347c478bdstevel@tonic-gate			checkflags |= M_OBJECT;
6357c478bdstevel@tonic-gate		else if ((obj_flag & OBJ_FOWNER) &&
6367c478bdstevel@tonic-gate		    (obj_owner == uid))
6377c478bdstevel@tonic-gate			checkflags |= M_OBJECT;
6387c478bdstevel@tonic-gate	}
6397c478bdstevel@tonic-gate	return (-1);
6407c478bdstevel@tonic-gate}
6417c478bdstevel@tonic-gate
6427c478bdstevel@tonic-gate/*
6437c478bdstevel@tonic-gate * Format of attribute64 token:
6447c478bdstevel@tonic-gate *	attribute token id	adr_char
6457c478bdstevel@tonic-gate * 	mode			adr_int32 (printed in octal)
6467c478bdstevel@tonic-gate *	uid			adr_int32
6477c478bdstevel@tonic-gate *	gid			adr_int32
6487c478bdstevel@tonic-gate *	file system id		adr_int32
6497c478bdstevel@tonic-gate *	node id			adr_int64
6507c478bdstevel@tonic-gate *	device			adr_int64
6517c478bdstevel@tonic-gate */
6527c478bdstevel@tonic-gateint
6537c478bdstevel@tonic-gateattribute64_token(adr_t *adr)
6547c478bdstevel@tonic-gate{
6557c478bdstevel@tonic-gate	int64_t	dev;
6567c478bdstevel@tonic-gate	int32_t	file_sysid;
6577c478bdstevel@tonic-gate	int32_t	gid;
6587c478bdstevel@tonic-gate	int32_t	mode;
6597c478bdstevel@tonic-gate	int64_t	nodeid;
6607c478bdstevel@tonic-gate	int32_t	uid;
6617c478bdstevel@tonic-gate
6627c478bdstevel@tonic-gate	adrm_int32(adr, &mode, 1);
6637c478bdstevel@tonic-gate	adrm_int32(adr, &uid, 1);
6647c478bdstevel@tonic-gate	adrm_int32(adr, &gid, 1);
6657c478bdstevel@tonic-gate	adrm_int32(adr, &file_sysid, 1);
6667c478bdstevel@tonic-gate	adrm_int64(adr, &nodeid, 1);
6677c478bdstevel@tonic-gate	adrm_int64(adr, &dev, 1);
6687c478bdstevel@tonic-gate
6697c478bdstevel@tonic-gate	if (!new_mode && (flags & M_USERE)) {
6707c478bdstevel@tonic-gate		if (m_usere == uid)
6717c478bdstevel@tonic-gate			checkflags |= M_USERE;
6727c478bdstevel@tonic-gate	}
6737c478bdstevel@tonic-gate	if (!new_mode && (flags & M_GROUPE)) {
6747c478bdstevel@tonic-gate		if (m_groupe == gid)
6757c478bdstevel@tonic-gate			checkflags |= M_GROUPE;
6767c478bdstevel@tonic-gate	}
6777c478bdstevel@tonic-gate
6787c478bdstevel@tonic-gate	if (flags & M_OBJECT) {
6797c478bdstevel@tonic-gate		if ((obj_flag & OBJ_FGROUP) &&
6807c478bdstevel@tonic-gate		    (obj_group == gid))
6817c478bdstevel@tonic-gate			checkflags |= M_OBJECT;
6827c478bdstevel@tonic-gate		else if ((obj_flag & OBJ_FOWNER) &&
6837c478bdstevel@tonic-gate		    (obj_owner == uid))
6847c478bdstevel@tonic-gate			checkflags |= M_OBJECT;
6857c478bdstevel@tonic-gate	}
6867c478bdstevel@tonic-gate	return (-1);
6877c478bdstevel@tonic-gate}
6887c478bdstevel@tonic-gate
6897c478bdstevel@tonic-gate
6907c478bdstevel@tonic-gate/*
6917c478bdstevel@tonic-gate * Format of command token:
6927c478bdstevel@tonic-gate *	attribute token id	adr_char
6937c478bdstevel@tonic-gate *	argc			adr_short
6947c478bdstevel@tonic-gate *	argv len		adr_short	variable amount of argv len
6957c478bdstevel@tonic-gate *	argv text		argv len	and text
6967c478bdstevel@tonic-gate *	.
6977c478bdstevel@tonic-gate *	.
6987c478bdstevel@tonic-gate *	.
6997c478bdstevel@tonic-gate *	envp count		adr_short	variable amount of envp len
7007c478bdstevel@tonic-gate *	envp len		adr_short	and text
7017c478bdstevel@tonic-gate *	envp text		envp		len
7027c478bdstevel@tonic-gate *	.
7037c478bdstevel@tonic-gate *	.
7047c478bdstevel@tonic-gate *	.
7057c478bdstevel@tonic-gate */
7067c478bdstevel@tonic-gateint
7077c478bdstevel@tonic-gatecmd_token(adr_t *adr)
7087c478bdstevel@tonic-gate{
7097c478bdstevel@tonic-gate	short	cnt;
7107c478bdstevel@tonic-gate	short	i;
7117c478bdstevel@tonic-gate
7127c478bdstevel@tonic-gate	adrm_short(adr, &cnt, 1);
7137c478bdstevel@tonic-gate
7147c478bdstevel@tonic-gate	for (i = 0; i < cnt; i++)
7157c478bdstevel@tonic-gate		skip_string(adr);
7167c478bdstevel@tonic-gate
7177c478bdstevel@tonic-gate	adrm_short(adr, &cnt, 1);
7187c478bdstevel@tonic-gate
7197c478bdstevel@tonic-gate	for (i = 0; i < cnt; i++)
7207c478bdstevel@tonic-gate		skip_string(adr);
7217c478bdstevel@tonic-gate
7227c478bdstevel@tonic-gate	return (-1);
7237c478bdstevel@tonic-gate}
7247c478bdstevel@tonic-gate
7257c478bdstevel@tonic-gate
7267c478bdstevel@tonic-gate/*
7277c478bdstevel@tonic-gate * Format of exit token:
7287c478bdstevel@tonic-gate *	attribute token id	adr_char
7297c478bdstevel@tonic-gate *	return value		adr_int32
7307c478bdstevel@tonic-gate *	errno			adr_int32
7317c478bdstevel@tonic-gate */
7327c478bdstevel@tonic-gateint
7337c478bdstevel@tonic-gateexit_token(adr_t *adr)
7347c478bdstevel@tonic-gate{
7357c478bdstevel@tonic-gate	int32_t	retval;
7367c478bdstevel@tonic-gate	int32_t	errno;
7377c478bdstevel@tonic-gate
7387c478bdstevel@tonic-gate	adrm_int32(adr, &retval, 1);
7397c478bdstevel@tonic-gate	adrm_int32(adr, &errno, 1);
7407c478bdstevel@tonic-gate	return (-1);
7417c478bdstevel@tonic-gate}
7427c478bdstevel@tonic-gate
7437c478bdstevel@tonic-gate/*
7447c478bdstevel@tonic-gate * Format of strings array token:
7457c478bdstevel@tonic-gate *	token id		adr_char
7467c478bdstevel@tonic-gate *	count value		adr_int32
7477c478bdstevel@tonic-gate *	strings			null terminated strings
7487c478bdstevel@tonic-gate */
7497c478bdstevel@tonic-gatestatic int
7507c478bdstevel@tonic-gatestrings_common_token(adr_t *adr)
7517c478bdstevel@tonic-gate{
7527c478bdstevel@tonic-gate	int count, i;
7537c478bdstevel@tonic-gate	char c;
7547c478bdstevel@tonic-gate
7557c478bdstevel@tonic-gate	adrm_int32(adr, (int32_t *)&count, 1);
7567c478bdstevel@tonic-gate	for (i = 1; i <= count; i++) {
7577c478bdstevel@tonic-gate		adrm_char(adr, &c, 1);
7587c478bdstevel@tonic-gate		while (c != (char)0)
7597c478bdstevel@tonic-gate			adrm_char(adr, &c, 1);
7607c478bdstevel@tonic-gate	}
7617c478bdstevel@tonic-gate	/* no dump option here, since we will have variable length fields */
7627c478bdstevel@tonic-gate	return (-1);
7637c478bdstevel@tonic-gate}
7647c478bdstevel@tonic-gate
7657c478bdstevel@tonic-gateint
7667c478bdstevel@tonic-gatepath_attr_token(adr_t *adr)
7677c478bdstevel@tonic-gate{
7687c478bdstevel@tonic-gate	return (strings_common_token(adr));
7697c478bdstevel@tonic-gate}
7707c478bdstevel@tonic-gate
7717c478bdstevel@tonic-gateint
7727c478bdstevel@tonic-gateexec_args_token(adr_t *adr)
7737c478bdstevel@tonic-gate{
7747c478bdstevel@tonic-gate	return (strings_common_token(adr));
7757c478bdstevel@tonic-gate}
7767c478bdstevel@tonic-gate
7777c478bdstevel@tonic-gateint
7787c478bdstevel@tonic-gateexec_env_token(adr_t *adr)
7797c478bdstevel@tonic-gate{
7807c478bdstevel@tonic-gate	return (strings_common_token(adr));
7817c478bdstevel@tonic-gate}
7827c478bdstevel@tonic-gate
7837c478bdstevel@tonic-gate/*
7847c478bdstevel@tonic-gate * Format of liaison token:
7857c478bdstevel@tonic-gate */
7867c478bdstevel@tonic-gateint
7877c478bdstevel@tonic-gateliaison_token(adr_t *adr)
7887c478bdstevel@tonic-gate{
7897c478bdstevel@tonic-gate	int32_t	li;
7907c478bdstevel@tonic-gate
7917c478bdstevel@tonic-gate	adrm_int32(adr, &li, 1);
7927c478bdstevel@tonic-gate	return (-1);
7937c478bdstevel@tonic-gate}
7947c478bdstevel@tonic-gate
7957c478bdstevel@tonic-gate
7967c478bdstevel@tonic-gate/*
7977c478bdstevel@tonic-gate * Format of path token:
7987c478bdstevel@tonic-gate *	path				adr_string
7997c478bdstevel@tonic-gate */
8007c478bdstevel@tonic-gateint
8017c478bdstevel@tonic-gatepath_token(adr_t *adr)
8027c478bdstevel@tonic-gate{
8037c478bdstevel@tonic-gate	if ((flags & M_OBJECT) && (obj_flag == OBJ_PATH)) {
8047c478bdstevel@tonic-gate		char *path;
8057c478bdstevel@tonic-gate
8067c478bdstevel@tonic-gate		get_string(adr, &path);
8077c478bdstevel@tonic-gate		if (path[0] != '/')
8087c478bdstevel@tonic-gate			/*
8097c478bdstevel@tonic-gate			 * anchor the path. user apps may not do it.
8107c478bdstevel@tonic-gate			 */
8117c478bdstevel@tonic-gate			anchor_path(path);
8127c478bdstevel@tonic-gate		/*
8137c478bdstevel@tonic-gate		 * match against the collapsed path. that is what user sees.
8147c478bdstevel@tonic-gate		 */
8157c478bdstevel@tonic-gate		if (re_exec2(collapse_path(path)) == 1)
8167c478bdstevel@tonic-gate			checkflags |= M_OBJECT;
8177c478bdstevel@tonic-gate		free(path);
8187c478bdstevel@tonic-gate	} else {
8197c478bdstevel@tonic-gate		skip_string(adr);
8207c478bdstevel@tonic-gate	}
8217c478bdstevel@tonic-gate	return (-1);
8227c478bdstevel@tonic-gate}
8237c478bdstevel@tonic-gate
8247c478bdstevel@tonic-gate
8257c478bdstevel@tonic-gate/*
8267c478bdstevel@tonic-gate * Format of System V IPC permission token:
8277c478bdstevel@tonic-gate *	System V IPC permission token id	adr_char
8287c478bdstevel@tonic-gate * 	uid					adr_int32
8297c478bdstevel@tonic-gate *	gid					adr_int32
8307c478bdstevel@tonic-gate *	cuid					adr_int32
8317c478bdstevel@tonic-gate *	cgid					adr_int32
8327c478bdstevel@tonic-gate *	mode					adr_int32
8337c478bdstevel@tonic-gate *	seq					adr_int32
8347c478bdstevel@tonic-gate *	key					adr_int32
8357c478bdstevel@tonic-gate */
8367c478bdstevel@tonic-gateint
8377c478bdstevel@tonic-gates5_IPC_perm_token(adr_t *adr)
8387c478bdstevel@tonic-gate{
8397c478bdstevel@tonic-gate	int32_t	uid, gid, cuid, cgid, mode, seq;
8407c478bdstevel@tonic-gate	int32_t	key;
8417c478bdstevel@tonic-gate
8427c478bdstevel@tonic-gate	adrm_int32(adr, &uid, 1);
8437c478bdstevel@tonic-gate	adrm_int32(adr, &gid, 1);
8447c478bdstevel@tonic-gate	adrm_int32(adr, &cuid, 1);
8457c478bdstevel@tonic-gate	adrm_int32(adr, &cgid, 1);
8467c478bdstevel@tonic-gate	adrm_int32(adr, &mode, 1);
8477c478bdstevel@tonic-gate	adrm_int32(adr, &seq, 1);
8487c478bdstevel@tonic-gate	adrm_int32(adr, &key, 1);
8497c478bdstevel@tonic-gate
8507c478bdstevel@tonic-gate	if (!new_mode && (flags & M_USERE)) {
8517c478bdstevel@tonic-gate		if (m_usere == uid)
8527c478bdstevel@tonic-gate			checkflags |= M_USERE;
8537c478bdstevel@tonic-gate	}
8547c478bdstevel@tonic-gate
8557c478bdstevel@tonic-gate	if (!new_mode && (flags & M_USERE)) {
8567c478bdstevel@tonic-gate		if (m_usere == cuid)
8577c478bdstevel@tonic-gate			checkflags |= M_USERE;
8587c478bdstevel@tonic-gate	}
8597c478bdstevel@tonic-gate
8607c478bdstevel@tonic-gate	if (!new_mode && (flags & M_GROUPR)) {
8617c478bdstevel@tonic-gate		if (m_groupr == gid)
8627c478bdstevel@tonic-gate			checkflags |= M_GROUPR;
8637c478bdstevel@tonic-gate	}
8647c478bdstevel@tonic-gate
8657c478bdstevel@tonic-gate	if (!new_mode && (flags & M_GROUPR)) {
8667c478bdstevel@tonic-gate		if (m_groupr == cgid)
8677c478bdstevel@tonic-gate			checkflags |= M_GROUPR;
8687c478bdstevel@tonic-gate	}
8697c478bdstevel@tonic-gate
8707c478bdstevel@tonic-gate	if ((flags & M_OBJECT) &&
8717c478bdstevel@tonic-gate	    ((obj_owner == uid) ||
8727c478bdstevel@tonic-gate	    (obj_owner == cuid) ||
8737c478bdstevel@tonic-gate	    (obj_group == gid) ||
8747c478bdstevel@tonic-gate	    (obj_group == cgid))) {
8757c478bdstevel@tonic-gate
8767c478bdstevel@tonic-gate		switch (obj_flag) {
8777c478bdstevel@tonic-gate		case OBJ_MSGGROUP:
8787c478bdstevel@tonic-gate		case OBJ_MSGOWNER:
8797c478bdstevel@tonic-gate			if (ipc_type_match(OBJ_MSG, ipc_type))
8807c478bdstevel@tonic-gate				checkflags |= M_OBJECT;
8817c478bdstevel@tonic-gate			break;
8827c478bdstevel@tonic-gate		case OBJ_SEMGROUP:
8837c478bdstevel@tonic-gate		case OBJ_SEMOWNER:
8847c478bdstevel@tonic-gate			if (ipc_type_match(OBJ_SEM, ipc_type))
8857c478bdstevel@tonic-gate				checkflags |= M_OBJECT;
8867c478bdstevel@tonic-gate			break;
8877c478bdstevel@tonic-gate		case OBJ_SHMGROUP:
8887c478bdstevel@tonic-gate		case OBJ_SHMOWNER:
8897c478bdstevel@tonic-gate			if (ipc_type_match(OBJ_SHM, ipc_type))
8907c478bdstevel@tonic-gate				checkflags |= M_OBJECT;
8917c478bdstevel@tonic-gate			break;
8927c478bdstevel@tonic-gate		}
8937c478bdstevel@tonic-gate	}
8947c478bdstevel@tonic-gate	return (-1);
8957c478bdstevel@tonic-gate}
8967c478bdstevel@tonic-gate
8977c478bdstevel@tonic-gate
8987c478bdstevel@tonic-gate/*
8997c478bdstevel@tonic-gate * Format of process32 token:
9007c478bdstevel@tonic-gate *	process token id	adr_char
9017c478bdstevel@tonic-gate *	auid			adr_int32
9027c478bdstevel@tonic-gate *	euid			adr_int32
9037c478bdstevel@tonic-gate *	egid 			adr_int32
9047c478bdstevel@tonic-gate * 	ruid			adr_int32
9057c478bdstevel@tonic-gate *	rgid			adr_int32
9067c478bdstevel@tonic-gate * 	pid			adr_int32
9077c478bdstevel@tonic-gate * 	sid			adr_int32
9087c478bdstevel@tonic-gate * 	termid			adr_int32*2
9097c478bdstevel@tonic-gate */
9107c478bdstevel@tonic-gateint
9117c478bdstevel@tonic-gateprocess32_token(adr_t *adr)
9127c478bdstevel@tonic-gate{
9137c478bdstevel@tonic-gate	int32_t	auid, euid, egid, ruid, rgid, pid;
9147c478bdstevel@tonic-gate	int32_t	sid;
9157c478bdstevel@tonic-gate	int32_t port, machine;
9167c478bdstevel@tonic-gate
9177c478bdstevel@tonic-gate	adrm_int32(adr, &auid, 1);
9187c478bdstevel@tonic-gate	adrm_int32(adr, &euid, 1);
9197c478bdstevel@tonic-gate	adrm_int32(adr, &egid, 1);
9207c478bdstevel@tonic-gate	adrm_int32(adr, &ruid, 1);
9217c478bdstevel@tonic-gate	adrm_int32(adr, &rgid, 1);
9227c478bdstevel@tonic-gate	adrm_int32(adr, &pid, 1);
9237c478bdstevel@tonic-gate	adrm_int32(adr, &sid, 1);
9247c478bdstevel@tonic-gate	adrm_int32(adr, &port, 1);
9257c478bdstevel@tonic-gate	adrm_int32(adr, &machine, 1);
9267c478bdstevel@tonic-gate
9277c478bdstevel@tonic-gate	if (!new_mode && (flags & M_USERA)) {
9287c478bdstevel@tonic-gate		if (m_usera == auid)
9297c478bdstevel@tonic-gate			checkflags |= M_USERA;
9307c478bdstevel@tonic-gate	}
9317c478bdstevel@tonic-gate	if (!new_mode && (flags & M_USERE)) {
9327c478bdstevel@tonic-gate		if (m_usere == euid)
9337c478bdstevel@tonic-gate			checkflags |= M_USERE;
9347c478bdstevel@tonic-gate	}
9357c478bdstevel@tonic-gate	if (!new_mode && (flags & M_USERR)) {
9367c478bdstevel@tonic-gate		if (m_userr == ruid)
9377c478bdstevel@tonic-gate			checkflags |= M_USERR;
9387c478bdstevel@tonic-gate	}
9397c478bdstevel@tonic-gate	if (!new_mode && (flags & M_GROUPR)) {
9407c478bdstevel@tonic-gate		if (m_groupr == rgid)
9417c478bdstevel@tonic-gate			checkflags |= M_GROUPR;
9427c478bdstevel@tonic-gate	}
9437c478bdstevel@tonic-gate	if (!new_mode && (flags & M_GROUPE)) {
9447c478bdstevel@tonic-gate		if (m_groupe == egid)
9457c478bdstevel@tonic-gate			checkflags |= M_GROUPE;
9467c478bdstevel@tonic-gate	}
9477c478bdstevel@tonic-gate
9487c478bdstevel@tonic-gate	if (flags & M_OBJECT) {
9497c478bdstevel@tonic-gate		if ((obj_flag & OBJ_PROC) &&
9507c478bdstevel@tonic-gate		    (obj_id == pid)) {
9517c478bdstevel@tonic-gate			checkflags |= M_OBJECT;
9527c478bdstevel@tonic-gate		} else if ((obj_flag & OBJ_PGROUP) &&
9537c478bdstevel@tonic-gate		    ((obj_group == egid) ||
9547c478bdstevel@tonic-gate		    (obj_group == rgid))) {
9557c478bdstevel@tonic-gate			checkflags |= M_OBJECT;
9567c478bdstevel@tonic-gate		} else if ((obj_flag & OBJ_POWNER) &&
9577c478bdstevel@tonic-gate		    ((obj_owner == euid) ||
9587c478bdstevel@tonic-gate		    (obj_group == ruid))) {
9597c478bdstevel@tonic-gate			checkflags |= M_OBJECT;
9607c478bdstevel@tonic-gate		}
9617c478bdstevel@tonic-gate	}
9627c478bdstevel@tonic-gate	return (-1);
9637c478bdstevel@tonic-gate}
9647c478bdstevel@tonic-gate
9657c478bdstevel@tonic-gate/*
9668249a45Jan Friedel * Format of process32_ex token:
9677c478bdstevel@tonic-gate *	process token id	adr_char
9687c478bdstevel@tonic-gate *	auid			adr_int32
9697c478bdstevel@tonic-gate *	euid			adr_int32
9707c478bdstevel@tonic-gate *	egid 			adr_int32
9717c478bdstevel@tonic-gate * 	ruid			adr_int32
9727c478bdstevel@tonic-gate *	rgid			adr_int32
9737c478bdstevel@tonic-gate * 	pid			adr_int32
9747c478bdstevel@tonic-gate * 	sid			adr_int32
9758249a45Jan Friedel * 	termid
9768249a45Jan Friedel *		port		adr_int32
9778249a45Jan Friedel *		type		adr_int32
9788249a45Jan Friedel *		ip address	adr_u_char*type
9797c478bdstevel@tonic-gate */
9807c478bdstevel@tonic-gateint
9817c478bdstevel@tonic-gateprocess32_ex_token(adr_t *adr)
9827c478bdstevel@tonic-gate{
9837c478bdstevel@tonic-gate	int32_t	auid, euid, egid, ruid, rgid, pid;
9847c478bdstevel@tonic-gate	int32_t	sid;
9858249a45Jan Friedel	int32_t port, type;
9868249a45Jan Friedel	uchar_t addr[16];
9877c478bdstevel@tonic-gate
9887c478bdstevel@tonic-gate	adrm_int32(adr, &auid, 1);
9897c478bdstevel@tonic-gate	adrm_int32(adr, &euid, 1);
9907c478bdstevel@tonic-gate	adrm_int32(adr, &egid, 1);
9917c478bdstevel@tonic-gate	adrm_int32(adr, &ruid, 1);
9927c478bdstevel@tonic-gate	adrm_int32(adr, &rgid, 1);
9937c478bdstevel@tonic-gate	adrm_int32(adr, &pid, 1);
9947c478bdstevel@tonic-gate	adrm_int32(adr, &sid, 1);
9957c478bdstevel@tonic-gate	adrm_int32(adr, &port, 1);
9967c478bdstevel@tonic-gate	adrm_int32(adr, &type, 1);
9978249a45Jan Friedel	adrm_u_char(adr, addr, type);
9987c478bdstevel@tonic-gate
9997c478bdstevel@tonic-gate	if (!new_mode && (flags & M_USERA)) {
10007c478bdstevel@tonic-gate		if (m_usera == auid)
10017c478bdstevel@tonic-gate			checkflags = checkflags | M_USERA;
10027c478bdstevel@tonic-gate	}
10037c478bdstevel@tonic-gate	if (!new_mode && (flags & M_USERE)) {
10047c478bdstevel@tonic-gate		if (m_usere == euid)
10057c478bdstevel@tonic-gate			checkflags = checkflags | M_USERE;
10067c478bdstevel@tonic-gate	}
10077c478bdstevel@tonic-gate	if (!new_mode && (flags & M_USERR)) {
10087c478bdstevel@tonic-gate		if (m_userr == ruid)
10097c478bdstevel@tonic-gate			checkflags = checkflags | M_USERR;
10107c478bdstevel@tonic-gate	}
10117c478bdstevel@tonic-gate	if (!new_mode && (flags & M_GROUPR)) {
10127c478bdstevel@tonic-gate		if (m_groupr == egid)
10137c478bdstevel@tonic-gate			checkflags = checkflags | M_GROUPR;
10147c478bdstevel@tonic-gate	}
10157c478bdstevel@tonic-gate	if (!new_mode && (flags & M_GROUPE)) {
10167c478bdstevel@tonic-gate		if (m_groupe == egid)
10177c478bdstevel@tonic-gate			checkflags = checkflags | M_GROUPE;
10187c478bdstevel@tonic-gate	}
10197c478bdstevel@tonic-gate
10207c478bdstevel@tonic-gate	if (flags & M_OBJECT) {
10217c478bdstevel@tonic-gate		if ((obj_flag & OBJ_PROC) &&
10227c478bdstevel@tonic-gate		    (obj_id == pid)) {
10237c478bdstevel@tonic-gate			checkflags = checkflags | M_OBJECT;
10247c478bdstevel@tonic-gate		} else if ((obj_flag & OBJ_PGROUP) &&
10257c478bdstevel@tonic-gate		    ((obj_group == egid) ||
10267c478bdstevel@tonic-gate		    (obj_group == rgid))) {
10277c478bdstevel@tonic-gate			checkflags = checkflags | M_OBJECT;
10287c478bdstevel@tonic-gate		} else if ((obj_flag & OBJ_POWNER) &&
10297c478bdstevel@tonic-gate		    ((obj_owner == euid) ||
10307c478bdstevel@tonic-gate		    (obj_group == ruid))) {
10317c478bdstevel@tonic-gate			checkflags = checkflags | M_OBJECT;
10327c478bdstevel@tonic-gate		}
10337c478bdstevel@tonic-gate	}
10347c478bdstevel@tonic-gate	return (-1);
10357c478bdstevel@tonic-gate}
10367c478bdstevel@tonic-gate
10377c478bdstevel@tonic-gate/*
10387c478bdstevel@tonic-gate * Format of process64 token:
10397c478bdstevel@tonic-gate *	process token id	adr_char
10407c478bdstevel@tonic-gate *	auid			adr_int32
10417c478bdstevel@tonic-gate *	euid			adr_int32
10427c478bdstevel@tonic-gate *	egid 			adr_int32
10437c478bdstevel@tonic-gate * 	ruid			adr_int32
10447c478bdstevel@tonic-gate *	rgid			adr_int32
10457c478bdstevel@tonic-gate * 	pid			adr_int32
10467c478bdstevel@tonic-gate * 	sid			adr_int32
10477c478bdstevel@tonic-gate * 	termid			adr_int64+adr_int32
10487c478bdstevel@tonic-gate */
10497c478bdstevel@tonic-gateint
10507c478bdstevel@tonic-gateprocess64_token(adr_t *adr)
10517c478bdstevel@tonic-gate{
10527c478bdstevel@tonic-gate	int32_t	auid, euid, egid, ruid, rgid, pid;
10537c478bdstevel@tonic-gate	int32_t	sid;
10547c478bdstevel@tonic-gate	int64_t port;
10557c478bdstevel@tonic-gate	int32_t machine;
10567c478bdstevel@tonic-gate
10577c478bdstevel@tonic-gate	adrm_int32(adr, &auid, 1);
10587c478bdstevel@tonic-gate	adrm_int32(adr, &euid, 1);
10597c478bdstevel@tonic-gate	adrm_int32(adr, &egid, 1);
10607c478bdstevel@tonic-gate	adrm_int32(adr, &ruid, 1);
10617c478bdstevel@tonic-gate	adrm_int32(adr, &rgid, 1);
10627c478bdstevel@tonic-gate	adrm_int32(adr, &pid, 1);
10637c478bdstevel@tonic-gate	adrm_int32(adr, &sid, 1);
10647c478bdstevel@tonic-gate	adrm_int64(adr, &port, 1);
10657c478bdstevel@tonic-gate	adrm_int32(adr, &machine, 1);
10667c478bdstevel@tonic-gate
10677c478bdstevel@tonic-gate	if (!new_mode && (flags & M_USERA)) {
10687c478bdstevel@tonic-gate		if (m_usera == auid)
10697c478bdstevel@tonic-gate			checkflags |= M_USERA;
10707c478bdstevel@tonic-gate	}
10717c478bdstevel@tonic-gate	if (!new_mode && (flags & M_USERE)) {
10727c478bdstevel@tonic-gate		if (m_usere == euid)
10737c478bdstevel@tonic-gate			checkflags |= M_USERE;
10747c478bdstevel@tonic-gate	}
10757c478bdstevel@tonic-gate	if (!new_mode && (flags & M_USERR)) {
10767c478bdstevel@tonic-gate		if (m_userr == ruid)
10777c478bdstevel@tonic-gate			checkflags |= M_USERR;
10787c478bdstevel@tonic-gate	}
10797c478bdstevel@tonic-gate	if (!new_mode && (flags & M_GROUPR)) {
10807c478bdstevel@tonic-gate		if (m_groupr == rgid)
10817c478bdstevel@tonic-gate			checkflags |= M_GROUPR;
10827c478bdstevel@tonic-gate	}
10837c478bdstevel@tonic-gate	if (!new_mode && (flags & M_GROUPE)) {
10847c478bdstevel@tonic-gate		if (m_groupe == egid)
10857c478bdstevel@tonic-gate			checkflags |= M_GROUPE;
10867c478bdstevel@tonic-gate	}
10877c478bdstevel@tonic-gate
10887c478bdstevel@tonic-gate	if (flags & M_OBJECT) {
10897c478bdstevel@tonic-gate		if ((obj_flag & OBJ_PROC) &&
10907c478bdstevel@tonic-gate		    (obj_id == pid)) {
10917c478bdstevel@tonic-gate			checkflags |= M_OBJECT;
10927c478bdstevel@tonic-gate		} else if ((obj_flag & OBJ_PGROUP) &&
10937c478bdstevel@tonic-gate		    ((obj_group == egid) ||
10947c478bdstevel@tonic-gate		    (obj_group == rgid))) {
10957c478bdstevel@tonic-gate			checkflags |= M_OBJECT;
10967c478bdstevel@tonic-gate		} else if ((obj_flag & OBJ_POWNER) &&
10977c478bdstevel@tonic-gate		    ((obj_owner == euid) ||
10987c478bdstevel@tonic-gate		    (obj_group == ruid))) {
10997c478bdstevel@tonic-gate			checkflags |= M_OBJECT;
11007c478bdstevel@tonic-gate		}
11017c478bdstevel@tonic-gate	}
11027c478bdstevel@tonic-gate	return (-1);
11037c478bdstevel@tonic-gate}
11047c478bdstevel@tonic-gate
11057c478bdstevel@tonic-gate/*
11068249a45Jan Friedel * Format of process64_ex token:
11077c478bdstevel@tonic-gate *	process token id	adr_char
11087c478bdstevel@tonic-gate *	auid			adr_int32
11097c478bdstevel@tonic-gate *	euid			adr_int32
11107c478bdstevel@tonic-gate *	egid 			adr_int32
11117c478bdstevel@tonic-gate * 	ruid			adr_int32
11127c478bdstevel@tonic-gate *	rgid			adr_int32
11137c478bdstevel@tonic-gate * 	pid			adr_int32
11147c478bdstevel@tonic-gate * 	sid			adr_int32
11158249a45Jan Friedel * 	termid
11168249a45Jan Friedel * 		port		adr_int64
11178249a45Jan Friedel * 		type		adr_int32
11188249a45Jan Friedel * 		ip address	adr_u_char*type
11197c478bdstevel@tonic-gate */
11207c478bdstevel@tonic-gateint
11217c478bdstevel@tonic-gateprocess64_ex_token(adr_t *adr)
11227c478bdstevel@tonic-gate{
11237c478bdstevel@tonic-gate	int32_t	auid, euid, egid, ruid, rgid, pid;
11247c478bdstevel@tonic-gate	int32_t	sid;
11257c478bdstevel@tonic-gate	int64_t port;
11268249a45Jan Friedel	int32_t type;
11278249a45Jan Friedel	uchar_t addr[16];
11287c478bdstevel@tonic-gate
11297c478bdstevel@tonic-gate	adrm_int32(adr, &auid, 1);
11307c478bdstevel@tonic-gate	adrm_int32(adr, &euid, 1);
11317c478bdstevel@tonic-gate	adrm_int32(adr, &egid, 1);
11327c478bdstevel@tonic-gate	adrm_int32(adr, &ruid, 1);
11337c478bdstevel@tonic-gate	adrm_int32(adr, &rgid, 1);
11347c478bdstevel@tonic-gate	adrm_int32(adr, &pid, 1);
11357c478bdstevel@tonic-gate	adrm_int32(adr, &sid, 1);
11367c478bdstevel@tonic-gate	adrm_int64(adr, &port, 1);
11377c478bdstevel@tonic-gate	adrm_int32(adr, &type, 1);
11388249a45Jan Friedel	adrm_u_char(adr, addr, type);
11397c478bdstevel@tonic-gate
11407c478bdstevel@tonic-gate	if (!new_mode && (flags & M_USERA)) {
11417c478bdstevel@tonic-gate		if (m_usera == auid)
11427c478bdstevel@tonic-gate			checkflags = checkflags | M_USERA;
11437c478bdstevel@tonic-gate	}
11447c478bdstevel@tonic-gate	if (!new_mode && (flags & M_USERE)) {
11457c478bdstevel@tonic-gate		if (m_usere == euid)
11467c478bdstevel@tonic-gate			checkflags = checkflags | M_USERE;
11477c478bdstevel@tonic-gate	}
11487c478bdstevel@tonic-gate	if (!new_mode && (flags & M_USERR)) {
11497c478bdstevel@tonic-gate		if (m_userr == ruid)
11507c478bdstevel@tonic-gate			checkflags = checkflags | M_USERR;
11517c478bdstevel@tonic-gate	}
11527c478bdstevel@tonic-gate	if (!new_mode && (flags & M_GROUPR)) {
11537c478bdstevel@tonic-gate		if (m_groupr == egid)
11547c478bdstevel@tonic-gate			checkflags = checkflags | M_GROUPR;
11557c478bdstevel@tonic-gate	}
11567c478bdstevel@tonic-gate	if (!new_mode && (flags & M_GROUPE)) {
11577c478bdstevel@tonic-gate		if (m_groupe == egid)
11587c478bdstevel@tonic-gate			checkflags = checkflags | M_GROUPE;
11597c478bdstevel@tonic-gate	}
11607c478bdstevel@tonic-gate
11617c478bdstevel@tonic-gate	if (flags & M_OBJECT) {
11627c478bdstevel@tonic-gate		if ((obj_flag & OBJ_PROC) &&
11637c478bdstevel@tonic-gate		    (obj_id == pid)) {
11647c478bdstevel@tonic-gate			checkflags = checkflags | M_OBJECT;
11657c478bdstevel@tonic-gate		} else if ((obj_flag & OBJ_PGROUP) &&
11667c478bdstevel@tonic-gate		    ((obj_group == egid) ||
11677c478bdstevel@tonic-gate		    (obj_group == rgid))) {
11687c478bdstevel@tonic-gate			checkflags = checkflags | M_OBJECT;
11697c478bdstevel@tonic-gate		} else if ((obj_flag & OBJ_POWNER) &&
11707c478bdstevel@tonic-gate		    ((obj_owner == euid) ||
11717c478bdstevel@tonic-gate		    (obj_group == ruid))) {
11727c478bdstevel@tonic-gate			checkflags = checkflags | M_OBJECT;
11737c478bdstevel@tonic-gate		}
11747c478bdstevel@tonic-gate	}
11757c478bdstevel@tonic-gate	return (-1);
11767c478bdstevel@tonic-gate}
11777c478bdstevel@tonic-gate
11787c478bdstevel@tonic-gate/*
11797c478bdstevel@tonic-gate * Format of System V IPC token:
11807c478bdstevel@tonic-gate *	System V IPC token id	adr_char
11817c478bdstevel@tonic-gate *	object id		adr_int32
11827c478bdstevel@tonic-gate */
11837c478bdstevel@tonic-gateint
11847c478bdstevel@tonic-gates5_IPC_token(adr_t *adr)
11857c478bdstevel@tonic-gate{
11867c478bdstevel@tonic-gate	int32_t	ipc_id;
11877c478bdstevel@tonic-gate
11887c478bdstevel@tonic-gate	adrm_char(adr, &ipc_type, 1);	/* Global */
11897c478bdstevel@tonic-gate	adrm_int32(adr, &ipc_id, 1);
11907c478bdstevel@tonic-gate
11917c478bdstevel@tonic-gate	if ((flags & M_OBJECT) &&
11927c478bdstevel@tonic-gate	    ipc_type_match(obj_flag, ipc_type) &&
11937c478bdstevel@tonic-gate	    (obj_id == ipc_id))
11947c478bdstevel@tonic-gate		checkflags |= M_OBJECT;
11957c478bdstevel@tonic-gate
11967c478bdstevel@tonic-gate	return (-1);
11977c478bdstevel@tonic-gate}
11987c478bdstevel@tonic-gate
11997c478bdstevel@tonic-gate
12007c478bdstevel@tonic-gate/*
12017c478bdstevel@tonic-gate * Format of socket token:
12027c478bdstevel@tonic-gate *	socket_type		adrm_short
12037c478bdstevel@tonic-gate *	remote_port		adrm_short
12047c478bdstevel@tonic-gate *	remote_inaddr		adrm_int32
12057c478bdstevel@tonic-gate */
12067c478bdstevel@tonic-gateint
12077c478bdstevel@tonic-gatesocket_token(adr_t *adr)
12087c478bdstevel@tonic-gate{
12097c478bdstevel@tonic-gate	short	socket_type;
12107c478bdstevel@tonic-gate	short	remote_port;
12117c478bdstevel@tonic-gate	int32_t	remote_inaddr;
12127c478bdstevel@tonic-gate
12137c478bdstevel@tonic-gate	adrm_short(adr, &socket_type, 1);
12147c478bdstevel@tonic-gate	adrm_short(adr, &remote_port, 1);
12157c478bdstevel@tonic-gate	adrm_char(adr, (char *)&remote_inaddr, 4);
12167c478bdstevel@tonic-gate
12177c478bdstevel@tonic-gate	if ((flags & M_OBJECT) && (obj_flag == OBJ_SOCK)) {
12187c478bdstevel@tonic-gate		if (socket_flag == SOCKFLG_MACHINE) {
12197c478bdstevel@tonic-gate			if (remote_inaddr == obj_id)
12207c478bdstevel@tonic-gate				checkflags |= M_OBJECT;
12217c478bdstevel@tonic-gate		} else if (socket_flag == SOCKFLG_PORT) {
12227c478bdstevel@tonic-gate			if (remote_port == obj_id)
12237c478bdstevel@tonic-gate				checkflags |= M_OBJECT;
12247c478bdstevel@tonic-gate		}
12257c478bdstevel@tonic-gate	}
12267c478bdstevel@tonic-gate	return (-1);
12277c478bdstevel@tonic-gate}
12287c478bdstevel@tonic-gate
12297c478bdstevel@tonic-gate
12307c478bdstevel@tonic-gate/*
12318249a45Jan Friedel * Format of socket_ex token:
12328249a45Jan Friedel *	socket_domain		adrm_short
12337c478bdstevel@tonic-gate *	socket_type		adrm_short
12348249a45Jan Friedel *	address_type		adrm_short
12358249a45Jan Friedel *	local_port		adrm_short
12368249a45Jan Friedel *	local_inaddr		adrm_u_char*address_type
12377c478bdstevel@tonic-gate *	remote_port		adrm_short
12388249a45Jan Friedel *	remote_inaddr		adrm_u_char*address_type
12397c478bdstevel@tonic-gate */
12407c478bdstevel@tonic-gateint
12417c478bdstevel@tonic-gatesocket_ex_token(adr_t *adr)
12427c478bdstevel@tonic-gate{
12437c478bdstevel@tonic-gate	short	socket_domain;
12447c478bdstevel@tonic-gate	short	socket_type;
12457c478bdstevel@tonic-gate	short	ip_size;
12467c478bdstevel@tonic-gate	short	local_port;
12478249a45Jan Friedel	uchar_t	local_inaddr[16];
12487c478bdstevel@tonic-gate	short	remote_port;
12498249a45Jan Friedel	uchar_t	remote_inaddr[16];
12508249a45Jan Friedel	uchar_t	*caddr = (uchar_t *)&obj_id;
12517c478bdstevel@tonic-gate
12527c478bdstevel@tonic-gate	adrm_short(adr, &socket_domain, 1);
12537c478bdstevel@tonic-gate	adrm_short(adr, &socket_type, 1);
12547c478bdstevel@tonic-gate	adrm_short(adr, &ip_size, 1);
12557c478bdstevel@tonic-gate
12567c478bdstevel@tonic-gate	/* validate ip size */
12577c478bdstevel@tonic-gate	if ((ip_size != AU_IPv6) && (ip_size != AU_IPv4))
12587c478bdstevel@tonic-gate		return (0);
12597c478bdstevel@tonic-gate
12607c478bdstevel@tonic-gate	adrm_short(adr, &local_port, 1);
12617c478bdstevel@tonic-gate	adrm_char(adr, (char *)local_inaddr, ip_size);
12627c478bdstevel@tonic-gate
12637c478bdstevel@tonic-gate	adrm_short(adr, &remote_port, 1);
12647c478bdstevel@tonic-gate	adrm_char(adr, (char *)remote_inaddr, ip_size);
12657c478bdstevel@tonic-gate
12667c478bdstevel@tonic-gate	/* if IP type mis-match, then nothing to do */
12677c478bdstevel@tonic-gate	if (ip_size != ip_type)
12687c478bdstevel@tonic-gate		return (-1);
12697c478bdstevel@tonic-gate
12707c478bdstevel@tonic-gate	if ((flags & M_OBJECT) && (obj_flag == OBJ_SOCK)) {
12717c478bdstevel@tonic-gate		if (socket_flag == SOCKFLG_MACHINE) {
12728249a45Jan Friedel			if (ip_type == AU_IPv6) {
12738249a45Jan Friedel				caddr = (uchar_t *)ip_ipv6;
12748249a45Jan Friedel			}
12758249a45Jan Friedel			if ((memcmp(local_inaddr, caddr, ip_type) == 0) ||
12768249a45Jan Friedel			    (memcmp(remote_inaddr, caddr, ip_type) == 0)) {
12778249a45Jan Friedel				checkflags |= M_OBJECT;
12787c478bdstevel@tonic-gate			}
12797c478bdstevel@tonic-gate		} else if (socket_flag == SOCKFLG_PORT) {
12808249a45Jan Friedel			if ((local_port == obj_id) || (remote_port == obj_id)) {
12817c478bdstevel@tonic-gate				checkflags |= M_OBJECT;
12828249a45Jan Friedel			}
12837c478bdstevel@tonic-gate		}
12847c478bdstevel@tonic-gate	}
12857c478bdstevel@tonic-gate	return (-1);
12867c478bdstevel@tonic-gate}
12877c478bdstevel@tonic-gate
12887c478bdstevel@tonic-gate
12897c478bdstevel@tonic-gate/*
12907c478bdstevel@tonic-gate * Format of subject32 token:
12917c478bdstevel@tonic-gate *	subject token id	adr_char
12927c478bdstevel@tonic-gate *	auid			adr_int32
12937c478bdstevel@tonic-gate *	euid			adr_int32
12947c478bdstevel@tonic-gate *	egid 			adr_int32
12957c478bdstevel@tonic-gate * 	ruid			adr_int32
12967c478bdstevel@tonic-gate *	rgid			adr_int32
12977c478bdstevel@tonic-gate * 	pid			adr_int32
12987c478bdstevel@tonic-gate * 	sid			adr_int32
12997c478bdstevel@tonic-gate * 	termid			adr_int32*2
13007c478bdstevel@tonic-gate */
13017c478bdstevel@tonic-gateint
13027c478bdstevel@tonic-gatesubject32_token(adr_t *adr)
13037c478bdstevel@tonic-gate{
13047c478bdstevel@tonic-gate	int32_t	auid, euid, egid, ruid, rgid, pid;
13057c478bdstevel@tonic-gate	int32_t	sid;
13067c478bdstevel@tonic-gate	int32_t port, machine;
13077c478bdstevel@tonic-gate
13087c478bdstevel@tonic-gate	adrm_int32(adr, &auid, 1);
13097c478bdstevel@tonic-gate	adrm_int32(adr, &euid, 1);
13107c478bdstevel@tonic-gate	adrm_int32(adr, &egid, 1);
13117c478bdstevel@tonic-gate	adrm_int32(adr, &ruid, 1);
13127c478bdstevel@tonic-gate	adrm_int32(adr, &rgid, 1);
13137c478bdstevel@tonic-gate	adrm_int32(adr, &pid, 1);
13147c478bdstevel@tonic-gate	adrm_int32(adr, &sid, 1);
13157c478bdstevel@tonic-gate	adrm_int32(adr, &port, 1);
13167c478bdstevel@tonic-gate	adrm_int32(adr, &machine, 1);
13177c478bdstevel@tonic-gate
13187c478bdstevel@tonic-gate	if (flags & M_SUBJECT) {
13197c478bdstevel@tonic-gate		if (subj_id == pid)
13207c478bdstevel@tonic-gate			checkflags |= M_SUBJECT;
13217c478bdstevel@tonic-gate	}
13227c478bdstevel@tonic-gate	if (flags & M_USERA) {
13237c478bdstevel@tonic-gate		if (m_usera == auid)
13247c478bdstevel@tonic-gate			checkflags |= M_USERA;
13257c478bdstevel@tonic-gate	}
13267c478bdstevel@tonic-gate	if (flags & M_USERE) {
13277c478bdstevel@tonic-gate		if (m_usere == euid)
13287c478bdstevel@tonic-gate			checkflags |= M_USERE;
13297c478bdstevel@tonic-gate	}
13307c478bdstevel@tonic-gate	if (flags & M_USERR) {
13317c478bdstevel@tonic-gate		if (m_userr == ruid)
13327c478bdstevel@tonic-gate			checkflags |= M_USERR;
13337c478bdstevel@tonic-gate	}
13347c478bdstevel@tonic-gate	if (flags & M_GROUPR) {
13357c478bdstevel@tonic-gate		if (m_groupr == rgid)
13367c478bdstevel@tonic-gate			checkflags |= M_GROUPR;
13377c478bdstevel@tonic-gate	}
13387c478bdstevel@tonic-gate	if (flags & M_GROUPE) {
13397c478bdstevel@tonic-gate		if (m_groupe == egid)
13407c478bdstevel@tonic-gate			checkflags |= M_GROUPE;
13417c478bdstevel@tonic-gate	}
1342924c914gww	if (flags & M_SID) {
1343d0fa49bTony Nguyen		if (m_sid == (au_asid_t)sid)
1344924c914gww			checkflags |= M_SID;
1345924c914gww	}
13467c478bdstevel@tonic-gate	return (-1);
13477c478bdstevel@tonic-gate}
13487c478bdstevel@tonic-gate
13497c478bdstevel@tonic-gate/*
13507c478bdstevel@tonic-gate * Format of subject32_ex token:
13517c478bdstevel@tonic-gate *	subject token id	adr_char
13527c478bdstevel@tonic-gate *	auid			adr_int32
13537c478bdstevel@tonic-gate *	euid			adr_int32
13547c478bdstevel@tonic-gate *	egid 			adr_int32
13557c478bdstevel@tonic-gate * 	ruid			adr_int32
13567c478bdstevel@tonic-gate *	rgid			adr_int32
13577c478bdstevel@tonic-gate * 	pid			adr_int32
13587c478bdstevel@tonic-gate * 	sid			adr_int32
13598249a45Jan Friedel * 	termid
13608249a45Jan Friedel * 		port		adr_int32
13618249a45Jan Friedel * 		type		adr_int32
13628249a45Jan Friedel * 		ip address	adr_u_char*type
13637c478bdstevel@tonic-gate */
13647c478bdstevel@tonic-gateint
13657c478bdstevel@tonic-gatesubject32_ex_token(adr_t *adr)
13667c478bdstevel@tonic-gate{
13677c478bdstevel@tonic-gate	int32_t	auid, euid, egid, ruid, rgid, pid;
13687c478bdstevel@tonic-gate	int32_t	sid;
13698249a45Jan Friedel	int32_t port, type;
13708249a45Jan Friedel	uchar_t addr[16];
13717c478bdstevel@tonic-gate
13727c478bdstevel@tonic-gate	adrm_int32(adr, &auid, 1);
13737c478bdstevel@tonic-gate	adrm_int32(adr, &euid, 1);
13747c478bdstevel@tonic-gate	adrm_int32(adr, &egid, 1);
13757c478bdstevel@tonic-gate	adrm_int32(adr, &ruid, 1);
13767c478bdstevel@tonic-gate	adrm_int32(adr, &rgid, 1);
13777c478bdstevel@tonic-gate	adrm_int32(adr, &pid, 1);
13787c478bdstevel@tonic-gate	adrm_int32(adr, &sid, 1);
13797c478bdstevel@tonic-gate	adrm_int32(adr, &port, 1);
13807c478bdstevel@tonic-gate	adrm_int32(adr, &type, 1);
13818249a45Jan Friedel	adrm_u_char(adr, addr, type);
13827c478bdstevel@tonic-gate
13837c478bdstevel@tonic-gate	if (flags & M_SUBJECT) {
13847c478bdstevel@tonic-gate		if (subj_id == pid)
13857c478bdstevel@tonic-gate			checkflags = checkflags | M_SUBJECT;
13867c478bdstevel@tonic-gate	}
13877c478bdstevel@tonic-gate	if (flags & M_USERA) {
13887c478bdstevel@tonic-gate		if (m_usera == auid)
13897c478bdstevel@tonic-gate			checkflags = checkflags | M_USERA;
13907c478bdstevel@tonic-gate	}
13917c478bdstevel@tonic-gate	if (flags & M_USERE) {
13927c478bdstevel@tonic-gate		if (m_usere == euid)
13937c478bdstevel@tonic-gate			checkflags = checkflags | M_USERE;
13947c478bdstevel@tonic-gate	}
13957c478bdstevel@tonic-gate	if (flags & M_USERR) {
13967c478bdstevel@tonic-gate		if (m_userr == ruid)
13977c478bdstevel@tonic-gate			checkflags = checkflags | M_USERR;
13987c478bdstevel@tonic-gate	}
13997c478bdstevel@tonic-gate	if (flags & M_GROUPR) {
14007c478bdstevel@tonic-gate		if (m_groupr == egid)
14017c478bdstevel@tonic-gate			checkflags = checkflags | M_GROUPR;
14027c478bdstevel@tonic-gate	}
14037c478bdstevel@tonic-gate	if (flags & M_GROUPE) {
14047c478bdstevel@tonic-gate		if (m_groupe == egid)
14057c478bdstevel@tonic-gate			checkflags = checkflags | M_GROUPE;
14067c478bdstevel@tonic-gate	}
1407924c914gww	if (flags & M_SID) {
1408d0fa49bTony Nguyen		if (m_sid == (au_asid_t)sid)
1409924c914gww			checkflags = checkflags | M_SID;
1410924c914gww	}
14117c478bdstevel@tonic-gate	return (-1);
14127c478bdstevel@tonic-gate}
14137c478bdstevel@tonic-gate
14147c478bdstevel@tonic-gate/*
14157c478bdstevel@tonic-gate * Format of subject64 token:
14167c478bdstevel@tonic-gate *	subject token id	adr_char
14177c478bdstevel@tonic-gate *	auid			adr_int32
14187c478bdstevel@tonic-gate *	euid			adr_int32
14197c478bdstevel@tonic-gate *	egid 			adr_int32
14207c478bdstevel@tonic-gate * 	ruid			adr_int32
14217c478bdstevel@tonic-gate *	rgid			adr_int32
14227c478bdstevel@tonic-gate * 	pid			adr_int32
14237c478bdstevel@tonic-gate * 	sid			adr_int32
14247c478bdstevel@tonic-gate * 	termid			adr_int64+adr_int32
14257c478bdstevel@tonic-gate */
14267c478bdstevel@tonic-gateint
14277c478bdstevel@tonic-gatesubject64_token(adr_t *adr)
14287c478bdstevel@tonic-gate{
14297c478bdstevel@tonic-gate	int32_t	auid, euid, egid, ruid, rgid, pid;
14307c478bdstevel@tonic-gate	int32_t	sid;
14317c478bdstevel@tonic-gate	int64_t port;
14327c478bdstevel@tonic-gate	int32_t machine;
14337c478bdstevel@tonic-gate
14347c478bdstevel@tonic-gate	adrm_int32(adr, &auid, 1);
14357c478bdstevel@tonic-gate	adrm_int32(adr, &euid, 1);
14367c478bdstevel@tonic-gate	adrm_int32(adr, &egid, 1);
14377c478bdstevel@tonic-gate	adrm_int32(adr, &ruid, 1);
14387c478bdstevel@tonic-gate	adrm_int32(adr, &rgid, 1);
14397c478bdstevel@tonic-gate	adrm_int32(adr, &pid, 1);
14407c478bdstevel@tonic-gate	adrm_int32(adr, &sid, 1);
14417c478bdstevel@tonic-gate	adrm_int64(adr, &port, 1);
14427c478bdstevel@tonic-gate	adrm_int32(adr, &machine, 1);
14437c478bdstevel@tonic-gate
14447c478bdstevel@tonic-gate	if (flags & M_SUBJECT) {
14457c478bdstevel@tonic-gate		if (subj_id == pid)
14467c478bdstevel@tonic-gate			checkflags |= M_SUBJECT;
14477c478bdstevel@tonic-gate	}
14487c478bdstevel@tonic-gate	if (flags & M_USERA) {
14497c478bdstevel@tonic-gate		if (m_usera == auid)
14507c478bdstevel@tonic-gate			checkflags |= M_USERA;
14517c478bdstevel@tonic-gate	}
14527c478bdstevel@tonic-gate	if (flags & M_USERE) {
14537c478bdstevel@tonic-gate		if (m_usere == euid)
14547c478bdstevel@tonic-gate			checkflags |= M_USERE;
14557c478bdstevel@tonic-gate	}
14567c478bdstevel@tonic-gate	if (flags & M_USERR) {
14577c478bdstevel@tonic-gate		if (m_userr == ruid)
14587c478bdstevel@tonic-gate			checkflags |= M_USERR;
14597c478bdstevel@tonic-gate	}
14607c478bdstevel@tonic-gate	if (flags & M_GROUPR) {
14617c478bdstevel@tonic-gate		if (m_groupr == rgid)
14627c478bdstevel@tonic-gate			checkflags |= M_GROUPR;
14637c478bdstevel@tonic-gate	}
14647c478bdstevel@tonic-gate	if (flags & M_GROUPE) {
14657c478bdstevel@tonic-gate		if (m_groupe == egid)
14667c478bdstevel@tonic-gate			checkflags |= M_GROUPE;
14677c478bdstevel@tonic-gate	}
1468924c914gww	if (flags & M_SID) {
1469d0fa49bTony Nguyen		if (m_sid == (au_asid_t)sid)
1470924c914gww			checkflags |= M_SID;
1471924c914gww	}
14727c478bdstevel@tonic-gate	return (-1);
14737c478bdstevel@tonic-gate}
14747c478bdstevel@tonic-gate
14757c478bdstevel@tonic-gate/*
14768249a45Jan Friedel * Format of subject64_ex token:
14777c478bdstevel@tonic-gate *	subject token id	adr_char
14787c478bdstevel@tonic-gate *	auid			adr_int32
14797c478bdstevel@tonic-gate *	euid			adr_int32
14807c478bdstevel@tonic-gate *	egid 			adr_int32
14817c478bdstevel@tonic-gate * 	ruid			adr_int32
14827c478bdstevel@tonic-gate *	rgid			adr_int32
14837c478bdstevel@tonic-gate * 	pid			adr_int32
14847c478bdstevel@tonic-gate * 	sid			adr_int32
14858249a45Jan Friedel * 	termid
14868249a45Jan Friedel * 		port		adr_int64
14878249a45Jan Friedel * 		type		adr_int32
14888249a45Jan Friedel * 		ip address	adr_u_char*type
14897c478bdstevel@tonic-gate */
14907c478bdstevel@tonic-gateint
14917c478bdstevel@tonic-gatesubject64_ex_token(adr_t *adr)
14927c478bdstevel@tonic-gate{
14937c478bdstevel@tonic-gate	int32_t	auid, euid, egid, ruid, rgid, pid;
14947c478bdstevel@tonic-gate	int32_t	sid;
14957c478bdstevel@tonic-gate	int64_t port;
14968249a45Jan Friedel	int32_t type;
14978249a45Jan Friedel	uchar_t	addr[16];
14987c478bdstevel@tonic-gate
14997c478bdstevel@tonic-gate	adrm_int32(adr, &auid, 1);
15007c478bdstevel@tonic-gate	adrm_int32(adr, &euid, 1);
15017c478bdstevel@tonic-gate	adrm_int32(adr, &egid, 1);
15027c478bdstevel@tonic-gate	adrm_int32(adr, &ruid, 1);
15037c478bdstevel@tonic-gate	adrm_int32(adr, &rgid, 1);
15047c478bdstevel@tonic-gate	adrm_int32(adr, &pid, 1);
15057c478bdstevel@tonic-gate	adrm_int32(adr, &sid, 1);
15067c478bdstevel@tonic-gate	adrm_int64(adr, &port, 1);
15077c478bdstevel@tonic-gate	adrm_int32(adr, &type, 1);
15088249a45Jan Friedel	adrm_u_char(adr, addr, type);
15097c478bdstevel@tonic-gate
15107c478bdstevel@tonic-gate	if (flags & M_SUBJECT) {
15117c478bdstevel@tonic-gate		if (subj_id == pid)
15127c478bdstevel@tonic-gate			checkflags = checkflags | M_SUBJECT;
15137c478bdstevel@tonic-gate	}
15147c478bdstevel@tonic-gate	if (flags & M_USERA) {
15157c478bdstevel@tonic-gate		if (m_usera == auid)
15167c478bdstevel@tonic-gate			checkflags = checkflags | M_USERA;
15177c478bdstevel@tonic-gate	}
15187c478bdstevel@tonic-gate	if (flags & M_USERE) {
15197c478bdstevel@tonic-gate		if (m_usere == euid)
15207c478bdstevel@tonic-gate			checkflags = checkflags | M_USERE;
15217c478bdstevel@tonic-gate	}
15227c478bdstevel@tonic-gate	if (flags & M_USERR) {
15237c478bdstevel@tonic-gate		if (m_userr == ruid)
15247c478bdstevel@tonic-gate			checkflags = checkflags | M_USERR;
15257c478bdstevel@tonic-gate	}
15267c478bdstevel@tonic-gate	if (flags & M_GROUPR) {
15277c478bdstevel@tonic-gate		if (m_groupr == egid)
15287c478bdstevel@tonic-gate			checkflags = checkflags | M_GROUPR;
15297c478bdstevel@tonic-gate	}
15307c478bdstevel@tonic-gate	if (flags & M_GROUPE) {
15317c478bdstevel@tonic-gate		if (m_groupe == egid)
15327c478bdstevel@tonic-gate			checkflags = checkflags | M_GROUPE;
15337c478bdstevel@tonic-gate	}
1534924c914gww	if (flags & M_SID) {
1535d0fa49bTony Nguyen		if (m_sid == (au_asid_t)sid)
1536924c914gww			checkflags = checkflags | M_SID;
1537924c914gww	}
15387c478bdstevel@tonic-gate	return (-1);
15397c478bdstevel@tonic-gate}
15407c478bdstevel@tonic-gate
15417c478bdstevel@tonic-gate/*
15427c478bdstevel@tonic-gate * -----------------------------------------------------------------------
15437c478bdstevel@tonic-gate * tid_token(): Process tid token and display contents
15447c478bdstevel@tonic-gate *
15457c478bdstevel@tonic-gate * Format of tid token:
15467c478bdstevel@tonic-gate *	tid token id			adr_char
15477c478bdstevel@tonic-gate * 	address type			adr_char
15487c478bdstevel@tonic-gate *	For address type of AU_IPADR...
15497c478bdstevel@tonic-gate *		remote port		adr_short
15507c478bdstevel@tonic-gate *		local port		adr_short
15517c478bdstevel@tonic-gate *		IP type			adr_int32
15527c478bdstevel@tonic-gate *		IP addr			adr_int32 if IPv4
15537c478bdstevel@tonic-gate *		IP addr			4 x adr_int32 if IPv6
15547c478bdstevel@tonic-gate * address types other than AU_IPADR are not yet defined
15557c478bdstevel@tonic-gate * -----------------------------------------------------------------------
15567c478bdstevel@tonic-gate */
15577c478bdstevel@tonic-gateint
15587c478bdstevel@tonic-gatetid_token(adr_t *adr)
15597c478bdstevel@tonic-gate{
15607c478bdstevel@tonic-gate	int32_t	address[4];
15617c478bdstevel@tonic-gate	int32_t	ip_type;
15627c478bdstevel@tonic-gate	char	tid_type;
15637c478bdstevel@tonic-gate	short	rport;
15647c478bdstevel@tonic-gate	short	lport;
15657c478bdstevel@tonic-gate
15667c478bdstevel@tonic-gate	adrm_char(adr, &tid_type, 1);
15677c478bdstevel@tonic-gate	switch (tid_type) {
15687c478bdstevel@tonic-gate	case AU_IPADR:
15697c478bdstevel@tonic-gate		adrm_short(adr, &rport, 1);
15707c478bdstevel@tonic-gate		adrm_short(adr, &lport, 1);
15717c478bdstevel@tonic-gate		adrm_int32(adr, &ip_type, 1);
15727c478bdstevel@tonic-gate		adrm_char(adr, (char *)&address, ip_type);
15737c478bdstevel@tonic-gate		break;
15747c478bdstevel@tonic-gate	default:
15757c478bdstevel@tonic-gate		return (0);
15767c478bdstevel@tonic-gate	}
15777c478bdstevel@tonic-gate	return (-1);
15787c478bdstevel@tonic-gate}
15797c478bdstevel@tonic-gate
15807c478bdstevel@tonic-gate/*
15817c478bdstevel@tonic-gate * -----------------------------------------------------------------------
15827c478bdstevel@tonic-gate * zonename_token(): Process zonename token and display contents
15837c478bdstevel@tonic-gate *
15847c478bdstevel@tonic-gate * Format of zonename token:
15857c478bdstevel@tonic-gate *	zonename token id		adr_char
15867c478bdstevel@tonic-gate * 	zone name			adr_string
15877c478bdstevel@tonic-gate * -----------------------------------------------------------------------
15887c478bdstevel@tonic-gate */
15897c478bdstevel@tonic-gateint
15907c478bdstevel@tonic-gatezonename_token(adr_t *adr)
15917c478bdstevel@tonic-gate{
15927c478bdstevel@tonic-gate	char	*name;
15937c478bdstevel@tonic-gate
15947c478bdstevel@tonic-gate	if (flags & M_ZONENAME) {
15957c478bdstevel@tonic-gate		get_string(adr, &name);
15967c478bdstevel@tonic-gate		if (strncmp(zonename, name, ZONENAME_MAX) == 0)
15977c478bdstevel@tonic-gate			checkflags |= M_ZONENAME;
15987c478bdstevel@tonic-gate		free(name);
15997c478bdstevel@tonic-gate	} else {
16007c478bdstevel@tonic-gate		skip_string(adr);
16017c478bdstevel@tonic-gate	}
16027c478bdstevel@tonic-gate	return (-1);
16037c478bdstevel@tonic-gate}
16047c478bdstevel@tonic-gate
16057c478bdstevel@tonic-gate/*
1606103b2b1gww * fmri_token():
1607103b2b1gww *
1608103b2b1gww * Format of fmri token:
1609103b2b1gww * 	fmri				adr_string
1610103b2b1gww */
1611103b2b1gwwint
1612103b2b1gwwfmri_token(adr_t *adr)
1613103b2b1gww{
1614103b2b1gww	if ((flags & M_OBJECT) && (obj_flag == OBJ_FMRI)) {
1615103b2b1gww		char	*fmri_name;
1616103b2b1gww
1617103b2b1gww		get_string(adr, &fmri_name);
1618103b2b1gww
1619103b2b1gww		/* match token against service instance */
1620103b2b1gww		if (scf_cmp_pattern(fmri_name, &fmri) == 1) {
1621103b2b1gww			checkflags |= M_OBJECT;
1622103b2b1gww		}
1623103b2b1gww		free(fmri_name);
1624103b2b1gww	} else {
1625103b2b1gww		skip_string(adr);
1626103b2b1gww	}
1627103b2b1gww	return (-1);
1628103b2b1gww}
1629103b2b1gww
1630103b2b1gww/*
16317c478bdstevel@tonic-gate * Format of xatom token:
16327c478bdstevel@tonic-gate */
16337c478bdstevel@tonic-gateint
16347c478bdstevel@tonic-gatexatom_token(adr_t *adr)
16357c478bdstevel@tonic-gate{
16367c478bdstevel@tonic-gate	skip_string(adr);
16377c478bdstevel@tonic-gate
16387c478bdstevel@tonic-gate	return (-1);
16397c478bdstevel@tonic-gate}
16407c478bdstevel@tonic-gate
16417c478bdstevel@tonic-gate/*
16427c478bdstevel@tonic-gate * Format of xselect token:
16437c478bdstevel@tonic-gate */
16447c478bdstevel@tonic-gateint
16457c478bdstevel@tonic-gatexselect_token(adr_t *adr)
16467c478bdstevel@tonic-gate{
16477c478bdstevel@tonic-gate	skip_string(adr);
16487c478bdstevel@tonic-gate	skip_string(adr);
16497c478bdstevel@tonic-gate	skip_string(adr);
16507c478bdstevel@tonic-gate
16517c478bdstevel@tonic-gate	return (-1);
16527c478bdstevel@tonic-gate}
16537c478bdstevel@tonic-gate
16547c478bdstevel@tonic-gate/*
16557c478bdstevel@tonic-gate * anchor a path name with a slash
16567c478bdstevel@tonic-gate * assume we have enough space
16577c478bdstevel@tonic-gate */
16587c478bdstevel@tonic-gatevoid
16597c478bdstevel@tonic-gateanchor_path(char *path)
16607c478bdstevel@tonic-gate{
16617c478bdstevel@tonic-gate	(void) memmove((void *)(path + 1), (void *)path, strlen(path) + 1);
16627c478bdstevel@tonic-gate	*path = '/';
16637c478bdstevel@tonic-gate}
16647c478bdstevel@tonic-gate
16657c478bdstevel@tonic-gate
16667c478bdstevel@tonic-gate/*
16677c478bdstevel@tonic-gate * copy path to collapsed path.
16687c478bdstevel@tonic-gate * collapsed path does not contain:
16697c478bdstevel@tonic-gate *	successive slashes
16707c478bdstevel@tonic-gate *	instances of dot-slash
16717c478bdstevel@tonic-gate *	instances of dot-dot-slash
16727c478bdstevel@tonic-gate * passed path must be anchored with a '/'
16737c478bdstevel@tonic-gate */
16747c478bdstevel@tonic-gatechar *
16757c478bdstevel@tonic-gatecollapse_path(char *s)
16767c478bdstevel@tonic-gate{
16777c478bdstevel@tonic-gate	int	id;	/* index of where we are in destination string */
16787c478bdstevel@tonic-gate	int	is;	/* index of where we are in source string */
16797c478bdstevel@tonic-gate	int	slashseen;	/* have we seen a slash */
16807c478bdstevel@tonic-gate	int	ls;		/* length of source string */
16817c478bdstevel@tonic-gate
16827c478bdstevel@tonic-gate	ls = strlen(s) + 1;
16837c478bdstevel@tonic-gate
16847c478bdstevel@tonic-gate	slashseen = 0;
16857c478bdstevel@tonic-gate	for (is = 0, id = 0; is < ls; is++) {
16867c478bdstevel@tonic-gate		/* thats all folks, we've reached the end of input */
16877c478bdstevel@tonic-gate		if (s[is] == '\0') {
16887c478bdstevel@tonic-gate			if (id > 1 && s[id-1] == '/') {
16897c478bdstevel@tonic-gate				--id;
16907c478bdstevel@tonic-gate			}
16917c478bdstevel@tonic-gate			s[id++] = '\0';
16927c478bdstevel@tonic-gate			break;
16937c478bdstevel@tonic-gate		}
16947c478bdstevel@tonic-gate		/* previous character was a / */
16957c478bdstevel@tonic-gate		if (slashseen) {
16967c478bdstevel@tonic-gate			if (s[is] == '/')
16977c478bdstevel@tonic-gate				continue;	/* another slash, ignore it */
16987c478bdstevel@tonic-gate		} else if (s[is] == '/') {
16997c478bdstevel@tonic-gate			/* we see a /, just copy it and try again */
17007c478bdstevel@tonic-gate			slashseen = 1;
17017c478bdstevel@tonic-gate			s[id++] = '/';
17027c478bdstevel@tonic-gate			continue;
17037c478bdstevel@tonic-gate		}
17047c478bdstevel@tonic-gate		/* /./ seen */
17057c478bdstevel@tonic-gate		if (s[is] == '.' && s[is+1] == '/') {
17067c478bdstevel@tonic-gate			is += 1;
17077c478bdstevel@tonic-gate			continue;
17087c478bdstevel@tonic-gate		}
17097c478bdstevel@tonic-gate		/* XXX/. seen */
17107c478bdstevel@tonic-gate		if (s[is] == '.' && s[is+1] == '\0') {
17117c478bdstevel@tonic-gate			if (id > 1)
17127c478bdstevel@tonic-gate				id--;
17137c478bdstevel@tonic-gate			continue;
17147c478bdstevel@tonic-gate		}
17157c478bdstevel@tonic-gate		/* XXX/.. seen */
17167c478bdstevel@tonic-gate		if (s[is] == '.' && s[is+1] == '.' && s[is+2] == '\0') {
17177c478bdstevel@tonic-gate			is += 1;
17187c478bdstevel@tonic-gate			if (id > 0)
17197c478bdstevel@tonic-gate				id--;
1720a7746f6tz			while (id > 0 && s[--id] != '/')
1721a7746f6tz				;
17227c478bdstevel@tonic-gate			id++;
17237c478bdstevel@tonic-gate			continue;
17247c478bdstevel@tonic-gate		}
17257c478bdstevel@tonic-gate		/* XXX/../ seen */
17267c478bdstevel@tonic-gate		if (s[is] == '.' && s[is+1] == '.' && s[is+2] == '/') {
17277c478bdstevel@tonic-gate			is += 2;
17287c478bdstevel@tonic-gate			if (id > 0)
17297c478bdstevel@tonic-gate				id--;
1730a7746f6tz			while (id > 0 && s[--id] != '/')
1731a7746f6tz				;
17327c478bdstevel@tonic-gate			id++;
17337c478bdstevel@tonic-gate			continue;
17347c478bdstevel@tonic-gate		}
1735a7746f6tz		while (is < ls && (s[id++] = s[is++]) != '/')
1736a7746f6tz			;
17377c478bdstevel@tonic-gate		is--;
17387c478bdstevel@tonic-gate	}
17397c478bdstevel@tonic-gate	return (s);
17407c478bdstevel@tonic-gate}
17417c478bdstevel@tonic-gate
17427c478bdstevel@tonic-gate
17437c478bdstevel@tonic-gateint
17447c478bdstevel@tonic-gateipc_type_match(int flag, char type)
17457c478bdstevel@tonic-gate{
17467c478bdstevel@tonic-gate	if (flag == OBJ_SEM && type == AT_IPC_SEM)
17477c478bdstevel@tonic-gate		return (1);
17487c478bdstevel@tonic-gate
17497c478bdstevel@tonic-gate	if (flag == OBJ_MSG && type == AT_IPC_MSG)
17507c478bdstevel@tonic-gate		return (1);
17517c478bdstevel@tonic-gate
17527c478bdstevel@tonic-gate	if (flag == OBJ_SHM && type == AT_IPC_SHM)
17537c478bdstevel@tonic-gate		return (1);
17547c478bdstevel@tonic-gate
17557c478bdstevel@tonic-gate	return (0);
17567c478bdstevel@tonic-gate}
17577c478bdstevel@tonic-gate
17587c478bdstevel@tonic-gate
17597c478bdstevel@tonic-gatevoid
17607c478bdstevel@tonic-gateskip_string(adr_t *adr)
17617c478bdstevel@tonic-gate{
17627c478bdstevel@tonic-gate	ushort_t	c;
17637c478bdstevel@tonic-gate
17647c478bdstevel@tonic-gate	adrm_u_short(adr, &c, 1);
17657c478bdstevel@tonic-gate	adr->adr_now += c;
17667c478bdstevel@tonic-gate}
17677c478bdstevel@tonic-gate
17687c478bdstevel@tonic-gate
17697c478bdstevel@tonic-gatevoid
17707c478bdstevel@tonic-gateget_string(adr_t *adr, char **p)
17717c478bdstevel@tonic-gate{
17727c478bdstevel@tonic-gate	ushort_t	c;
17737c478bdstevel@tonic-gate
17747c478bdstevel@tonic-gate	adrm_u_short(adr, &c, 1);
17757c478bdstevel@tonic-gate	*p = a_calloc(1, (size_t)c);
17767c478bdstevel@tonic-gate	adrm_char(adr, *p, c);
17777c478bdstevel@tonic-gate}
17787c478bdstevel@tonic-gate
17797c478bdstevel@tonic-gate
17807c478bdstevel@tonic-gate/*
17817c478bdstevel@tonic-gate * Format of host token:
17827c478bdstevel@tonic-gate *	host  		ard_uint32
17837c478bdstevel@tonic-gate */
17847c478bdstevel@tonic-gateint
17857c478bdstevel@tonic-gatehost_token(adr_t *adr)
17867c478bdstevel@tonic-gate{
17877c478bdstevel@tonic-gate	uint32_t host;
17887c478bdstevel@tonic-gate
17897c478bdstevel@tonic-gate	adrm_u_int32(adr, &host, 1);
17907c478bdstevel@tonic-gate
17917c478bdstevel@tonic-gate	return (-1);
17927c478bdstevel@tonic-gate}
17937c478bdstevel@tonic-gate
17947c478bdstevel@tonic-gate/*
17957c478bdstevel@tonic-gate * Format of useofauth token:
17967c478bdstevel@tonic-gate *	uauth token id		adr_char
17977c478bdstevel@tonic-gate * 	uauth			adr_string
17987c478bdstevel@tonic-gate */
17997c478bdstevel@tonic-gateint
18007c478bdstevel@tonic-gateuseofauth_token(adr_t *adr)
18017c478bdstevel@tonic-gate{
18027c478bdstevel@tonic-gate	skip_string(adr);
18037c478bdstevel@tonic-gate	return (-1);
18047c478bdstevel@tonic-gate}
18057c478bdstevel@tonic-gate
1806047f6e6gww/*
1807047f6e6gww * Format of user token:
1808047f6e6gww *	user token id		adr_char
1809047f6e6gww *	uid			adr_uid
1810047f6e6gww * 	username		adr_string
1811047f6e6gww */
1812047f6e6gwwint
1813047f6e6gwwuser_token(adr_t *adr)
1814047f6e6gww{
1815047f6e6gww	uid_t	uid;
1816047f6e6gww
1817047f6e6gww	adrm_uid(adr, &uid, 1);
1818047f6e6gww	skip_string(adr);
1819047f6e6gww
1820047f6e6gww	if ((flags & M_OBJECT) && (obj_flag == OBJ_USER) &&
1821047f6e6gww	    (uid == obj_user)) {
1822047f6e6gww		checkflags |= M_OBJECT;
1823047f6e6gww	}
1824047f6e6gww
1825047f6e6gww	return (-1);
1826047f6e6gww}
1827047f6e6gww
18287c478bdstevel@tonic-gateint
18297c478bdstevel@tonic-gatexcolormap_token(adr_t *adr)
18307c478bdstevel@tonic-gate{
18317c478bdstevel@tonic-gate	return (xgeneric(adr));
18327c478bdstevel@tonic-gate}
18337c478bdstevel@tonic-gate
18347c478bdstevel@tonic-gateint
18357c478bdstevel@tonic-gatexcursor_token(adr_t *adr)
18367c478bdstevel@tonic-gate{
18377c478bdstevel@tonic-gate	return (xgeneric(adr));
18387c478bdstevel@tonic-gate}
18397c478bdstevel@tonic-gate
18407c478bdstevel@tonic-gateint
18417c478bdstevel@tonic-gatexfont_token(adr_t *adr)
18427c478bdstevel@tonic-gate{
18437c478bdstevel@tonic-gate	return (xgeneric(adr));
18447c478bdstevel@tonic-gate}
18457c478bdstevel@tonic-gate
18467c478bdstevel@tonic-gateint
18477c478bdstevel@tonic-gatexgc_token(adr_t *adr)
18487c478bdstevel@tonic-gate{
18497c478bdstevel@tonic-gate	return (xgeneric(adr));
18507c478bdstevel@tonic-gate}
18517c478bdstevel@tonic-gate
18527c478bdstevel@tonic-gateint
18537c478bdstevel@tonic-gatexpixmap_token(adr_t *adr)
18547c478bdstevel@tonic-gate{
18557c478bdstevel@tonic-gate	return (xgeneric(adr));
18567c478bdstevel@tonic-gate}
18577c478bdstevel@tonic-gate
18587c478bdstevel@tonic-gateint
18597c478bdstevel@tonic-gatexwindow_token(adr_t *adr)
18607c478bdstevel@tonic-gate{
18617c478bdstevel@tonic-gate	return (xgeneric(adr));
18627c478bdstevel@tonic-gate}
18637c478bdstevel@tonic-gate
18647c478bdstevel@tonic-gate
18657c478bdstevel@tonic-gate/*
18667c478bdstevel@tonic-gate * Format of xgeneric token:
18677c478bdstevel@tonic-gate *	XID			adr_int32
18687c478bdstevel@tonic-gate *	creator UID		adr_int32
18697c478bdstevel@tonic-gate *
18707c478bdstevel@tonic-gate * Includes:  xcolormap, xcursor, xfont, xgc, xpixmap, and xwindow
18717c478bdstevel@tonic-gate */
18727c478bdstevel@tonic-gateint
18737c478bdstevel@tonic-gatexgeneric(adr_t *adr)
18747c478bdstevel@tonic-gate{
18757c478bdstevel@tonic-gate	int32_t xid;
18767c478bdstevel@tonic-gate	int32_t uid;
18777c478bdstevel@tonic-gate
18787c478bdstevel@tonic-gate	adrm_int32(adr, &xid, 1);
18797c478bdstevel@tonic-gate	adrm_int32(adr, &uid, 1);
18807c478bdstevel@tonic-gate
18817c478bdstevel@tonic-gate	if (flags & M_USERE) {
18827c478bdstevel@tonic-gate		if (m_usere == uid)
18837c478bdstevel@tonic-gate			checkflags = checkflags | M_USERE;
18847c478bdstevel@tonic-gate	}
18857c478bdstevel@tonic-gate
18867c478bdstevel@tonic-gate	return (-1);
18877c478bdstevel@tonic-gate}
18887c478bdstevel@tonic-gate
18897c478bdstevel@tonic-gate
18907c478bdstevel@tonic-gate/*
18917c478bdstevel@tonic-gate * Format of xproperty token:
18927c478bdstevel@tonic-gate *	XID			adr_int32
18937c478bdstevel@tonic-gate *	creator UID		adr_int32
18947c478bdstevel@tonic-gate *	atom string		adr_string
18957c478bdstevel@tonic-gate */
18967c478bdstevel@tonic-gateint
18977c478bdstevel@tonic-gatexproperty_token(adr_t *adr)
18987c478bdstevel@tonic-gate{
18997c478bdstevel@tonic-gate	int32_t	xid;
19007c478bdstevel@tonic-gate	int32_t uid;
19017c478bdstevel@tonic-gate
19027c478bdstevel@tonic-gate	adrm_int32(adr, &xid, 1);
19037c478bdstevel@tonic-gate	adrm_int32(adr, &uid, 1);
19047c478bdstevel@tonic-gate	skip_string(adr);
19057c478bdstevel@tonic-gate
19067c478bdstevel@tonic-gate	if (flags & M_USERE) {
19077c478bdstevel@tonic-gate		if (m_usere == uid)
19087c478bdstevel@tonic-gate			checkflags = checkflags | M_USERE;
19097c478bdstevel@tonic-gate	}
19107c478bdstevel@tonic-gate
19117c478bdstevel@tonic-gate	return (-1);
19127c478bdstevel@tonic-gate}
19137c478bdstevel@tonic-gate
19147c478bdstevel@tonic-gate
19157c478bdstevel@tonic-gate/*
19167c478bdstevel@tonic-gate * Format of xclient token:
19177c478bdstevel@tonic-gate * 	xclient id		adr_int32
19187c478bdstevel@tonic-gate */
19197c478bdstevel@tonic-gateint
19207c478bdstevel@tonic-gatexclient_token(adr_t *adr)
19217c478bdstevel@tonic-gate{
19227c478bdstevel@tonic-gate	int32_t	client_id;
19237c478bdstevel@tonic-gate
19247c478bdstevel@tonic-gate	adrm_int32(adr, &client_id, 1);
19257c478bdstevel@tonic-gate
19267c478bdstevel@tonic-gate	return (-1);
19277c478bdstevel@tonic-gate}
19287c478bdstevel@tonic-gate
19297c478bdstevel@tonic-gate/*
19307c478bdstevel@tonic-gate * Format of privilege set token:
19317c478bdstevel@tonic-gate *	priv_set type		string
19327c478bdstevel@tonic-gate *	priv_set		string
19337c478bdstevel@tonic-gate */
19347c478bdstevel@tonic-gate
19357c478bdstevel@tonic-gateint
19367c478bdstevel@tonic-gateprivilege_token(adr_t *adr)
19377c478bdstevel@tonic-gate{
19387c478bdstevel@tonic-gate	skip_string(adr);	/* set type name */
19397c478bdstevel@tonic-gate	skip_string(adr);	/* privilege set */
19407c478bdstevel@tonic-gate	return (-1);
19417c478bdstevel@tonic-gate}
19427c478bdstevel@tonic-gate
19437c478bdstevel@tonic-gate/*
1944d2a7078Richard Lowe * Format of security flags token:
1945d2a7078Richard Lowe *	security flag set		string
1946d2a7078Richard Lowe *	security flags		string
1947d2a7078Richard Lowe */
1948d2a7078Richard Lowe
1949d2a7078Richard Loweint
1950d2a7078Richard Lowesecflags_token(adr_t *adr)
1951d2a7078Richard Lowe{
1952d2a7078Richard Lowe	skip_string(adr);	/* set name */
1953d2a7078Richard Lowe	skip_string(adr);	/* security flags */
1954d2a7078Richard Lowe	return (-1);
1955d2a7078Richard Lowe}
1956d2a7078Richard Lowe
1957d2a7078Richard Lowe/*
1958a13cf09gww * Format of label token:
1959a13cf09gww *      label ID                1 byte
1960a13cf09gww *      compartment length      1 byte
1961a13cf09gww *      classification          2 bytes
1962a13cf09gww *      compartment words       <compartment length> * 4 bytes
19637c478bdstevel@tonic-gate */
19647c478bdstevel@tonic-gateint
1965a13cf09gwwlabel_token(adr_t *adr)
19667c478bdstevel@tonic-gate{
1967a13cf09gww	static m_label_t *label = NULL;
19684209664Tony Nguyen	static size32_t l_size;
1969a13cf09gww	int len;
19707c478bdstevel@tonic-gate
1971a13cf09gww	if (label == NULL) {
1972a13cf09gww		label = m_label_alloc(MAC_LABEL);
1973a13cf09gww		l_size = blabel_size() - 4;
1974a13cf09gww	}
1975a13cf09gww
1976a13cf09gww	if (label == NULL) {
1977a13cf09gww		/* out of memory, should never happen; skip label */
1978a13cf09gww		char	l;	/* length */
1979a13cf09gww
1980a13cf09gww		adr->adr_now += sizeof (char);
1981a13cf09gww		adrm_char(adr, (char *)&l, 1);
1982a13cf09gww		adr->adr_now += sizeof (short) + (4 * l);
1983a13cf09gww		return (-1);
1984a13cf09gww	}
1985a13cf09gww
1986a13cf09gww	adrm_char(adr, (char *)label, 4);
1987a13cf09gww	len = (int)(((char *)label)[1] * 4);
1988a13cf09gww	if (len > l_size) {
1989a13cf09gww		return (-1);
1990a13cf09gww	}
1991a13cf09gww	adrm_char(adr, &((char *)label)[4], len);
19927c478bdstevel@tonic-gate
199345916cdjpk	if (flags & M_LABEL) {
1994a13cf09gww		if (blinrange(label, m_label))
199545916cdjpk			checkflags = checkflags | M_LABEL;
19967c478bdstevel@tonic-gate	}
19977c478bdstevel@tonic-gate
19987c478bdstevel@tonic-gate	return (-1);
19997c478bdstevel@tonic-gate}
20007c478bdstevel@tonic-gate
20017c478bdstevel@tonic-gate
20027c478bdstevel@tonic-gate/*
20037c478bdstevel@tonic-gate * Format of useofpriv token:
20047c478bdstevel@tonic-gate *	success/failure		adr_char
20057c478bdstevel@tonic-gate *	privilege(s)		adr_string
20067c478bdstevel@tonic-gate */
20077c478bdstevel@tonic-gate/* ARGSUSED */
20087c478bdstevel@tonic-gateint
20097c478bdstevel@tonic-gateuseofpriv_token(adr_t *adr)
20107c478bdstevel@tonic-gate{
20117c478bdstevel@tonic-gate	char	flag;
20127c478bdstevel@tonic-gate
20137c478bdstevel@tonic-gate	adrm_char(adr, &flag, 1);
20147c478bdstevel@tonic-gate	skip_string(adr);
20157c478bdstevel@tonic-gate	return (-1);
20167c478bdstevel@tonic-gate}
2017