4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
37 #include <sys/types.h>
38 #include <sys/inttypes.h>
40 #include <sys/param.h>
44 #include <sys/socket.h>
45 #include <sys/errno.h>
48 #include <sys/systm.h>
49 #include <netinet/in.h>
50 #include <sys/tiuser.h>
51 #include <rpc/types.h>
53 #include <rpc/auth_unix.h>
57 #include <sys/fs/ufs_quota.h>
59 #include <sys/mkdev.h>
62 #include <bsm/audit.h>
63 #include <bsm/audit_record.h>
64 #include <bsm/libbsm.h>
66 #include <tsol/label.h>
72 #include <arpa/inet.h>
74 static char *anchor_path(char *);
75 static char *collapse_path(char *);
79 * -----------------------------------------------------------------------
81 * Tests whether the specified token id represents a type
83 * return codes : 1 - tokenid is a file token type
85 * -----------------------------------------------------------------------
88 is_file_token(int tokenid
)
90 if ((tokenid
== AUT_OTHER_FILE32
) || (tokenid
== AUT_OTHER_FILE64
))
97 * -----------------------------------------------------------------------
99 * Tests whether the specified token id represents a type
100 * of header token (signifying the start of a record).
101 * return codes : 1 - tokenid is a header type
103 * -----------------------------------------------------------------------
106 is_header_token(int tokenid
)
108 if ((tokenid
== AUT_OHEADER
) || (tokenid
== AUT_HEADER32
) ||
109 (tokenid
== AUT_HEADER32_EX
) || (tokenid
== AUT_HEADER64
) ||
110 (tokenid
== AUT_HEADER64_EX
))
117 * -----------------------------------------------------------------------
119 * Tests whether the specified token id represents a true
120 * token, as opposed to a regular tag.
121 * return codes : 1 - tokenid is a true token
123 * -----------------------------------------------------------------------
126 is_token(int tokenid
)
128 if ((tokenid
> 0) && (tokenid
<= MAXTOKEN
))
136 * -----------------------------------------------------------------------
137 * exit_token() : Process information label token and display contents
138 * return codes : -1 - error
140 * NOTE: At the time of call, the label token id has been retrieved
142 * Format of exit token:
143 * exit token id adr_char
144 * -----------------------------------------------------------------------
147 exit_token(pr_context_t
*context
)
153 if ((returnstat
= open_tag(context
, TAG_ERRVAL
)) != 0)
156 if ((returnstat
= pr_adr_int32(context
, (int32_t *)&retval
, 1)) == 0) {
157 if (!(context
->format
& PRF_RAWM
)) {
158 char *emsg
= strerror(retval
);
161 uval
.string_val
= gettext("Unknown errno");
163 uval
.string_val
= gettext(emsg
);
164 uval
.uvaltype
= PRA_STRING
;
166 uval
.uvaltype
= PRA_INT32
;
167 uval
.int32_val
= retval
;
169 returnstat
= pa_print(context
, &uval
, 0);
172 returnstat
= close_tag(context
, TAG_ERRVAL
);
174 return (process_tag(context
, TAG_RETVAL
, returnstat
, 1));
178 * ------------------------------------------------------------------
179 * file_token() : prints out seconds of time and other file name
180 * return codes : -1 - error
181 * : 0 - successful, valid file token fields
182 * At the time of entry, the file token ID has already been retrieved
184 * Format of file token:
185 * file token id adr_char
186 * seconds of time adr_u_int
187 * name of other file adr_string
188 * ------------------------------------------------------------------
191 file_token(pr_context_t
*context
)
195 returnstat
= pa_utime32(context
, 0, 0); /* time from usecs */
197 /* other file name */
198 returnstat
= pa_file_string(context
, returnstat
, 1);
204 file64_token(pr_context_t
*context
)
208 returnstat
= pa_utime64(context
, 0, 0); /* time from usecs */
210 /* other file name */
211 returnstat
= pa_file_string(context
, returnstat
, 1);
217 * -----------------------------------------------------------------------
218 * header_token() : Process record header token and display contents
219 * return codes : -1 - error
221 * : 1 - warning, password entry not found
223 * NOTE: At the time of call, the header token id has been retrieved
225 * Format of header token:
226 * header token id adr_char
227 * record byte count adr_u_int
228 * event type adr_u_short (printed either ASCII or raw)
229 * event class adr_u_int (printed either ASCII or raw)
230 * event action adr_u_int
231 * if extended: extended host name (IPv4/IPv6)
232 * seconds of time adr_u_int (printed either ASCII or raw)
233 * nanoseconds of time adr_u_int
234 * -----------------------------------------------------------------------
237 header_token(pr_context_t
*context
)
241 returnstat
= pa_reclen(context
, 0); /* record byte */
243 returnstat
= process_tag(context
, TAG_TOKVERS
, returnstat
, 0);
245 returnstat
= process_tag(context
, TAG_EVTYPE
, returnstat
, 0);
247 returnstat
= pa_event_modifier(context
, returnstat
, 0);
249 returnstat
= pa_ntime32(context
, returnstat
, 1);
255 header64_token(pr_context_t
*context
)
259 returnstat
= pa_reclen(context
, 0); /* record byte */
261 returnstat
= process_tag(context
, TAG_TOKVERS
, returnstat
, 0);
263 returnstat
= process_tag(context
, TAG_EVTYPE
, returnstat
, 0);
265 returnstat
= pa_event_modifier(context
, returnstat
, 0);
267 returnstat
= pa_ntime64(context
, returnstat
, 1);
273 header32_ex_token(pr_context_t
*context
)
277 returnstat
= pa_reclen(context
, 0); /* record byte */
279 returnstat
= process_tag(context
, TAG_TOKVERS
, returnstat
, 0);
281 returnstat
= process_tag(context
, TAG_EVTYPE
, returnstat
, 0);
283 returnstat
= pa_event_modifier(context
, returnstat
, 0);
285 returnstat
= pa_hostname_ex(context
, returnstat
, 0);
287 returnstat
= pa_ntime32(context
, returnstat
, 1);
293 header64_ex_token(pr_context_t
*context
)
297 returnstat
= pa_reclen(context
, 0); /* record byte */
299 returnstat
= process_tag(context
, TAG_TOKVERS
, returnstat
, 0);
301 returnstat
= process_tag(context
, TAG_EVTYPE
, returnstat
, 0);
303 returnstat
= pa_event_modifier(context
, returnstat
, 0);
305 returnstat
= pa_hostname_ex(context
, returnstat
, 0);
307 returnstat
= pa_ntime64(context
, returnstat
, 1);
313 * -----------------------------------------------------------------------
314 * trailer_token() : Process record trailer token and display contents
315 * return codes : -1 - error
317 * NOTE: At the time of call, the trailer token id has already been
320 * Format of trailer token:
321 * trailer token id adr_char
322 * record sequence no adr_u_short (should be AUT_TRAILER_MAGIC)
323 * record byte count adr_u_int
324 * -----------------------------------------------------------------------
327 trailer_token(pr_context_t
*context
)
331 if (pr_adr_u_short(context
, (ushort_t
*)&magic_number
, 1) < 0) {
332 (void) fprintf(stderr
, gettext(
333 "praudit: Cannot retrieve trailer magic number\n"));
336 if (magic_number
!= AUT_TRAILER_MAGIC
) {
337 (void) fprintf(stderr
, gettext(
338 "praudit: Invalid trailer magic number\n"));
341 /* Do not display trailer in XML mode */
342 if (context
->format
& PRF_XMLM
) {
346 retstat
= pr_adr_u_int32(context
, &junk
, 1);
349 return (pa_adr_u_int32(context
, 0, 1));
355 * -----------------------------------------------------------------------
356 * arbitrary_data_token():
357 * Process arbitrary data token and display contents
358 * return codes : -1 - error
360 * NOTE: At the time of call, the arbitrary data token id has already
363 * Format of arbitrary data token:
364 * arbitrary data token id adr char
365 * how to print adr_char
366 * From audit_record.h, this may be either:
369 * AUP_DECIMAL decimal
370 * AUP_HEX hexadecimal
371 * basic unit adr_char
372 * From audit_record.h, this may be either:
378 * unit count adr_char, specifying number of units of
379 * data in the "data items" parameter below
380 * data items depends on basic unit
382 * -----------------------------------------------------------------------
385 arbitrary_data_token(pr_context_t
*context
)
393 char how_to_print
, basic_unit
, unit_count
, fwid
;
396 char *pformat
= "%*s";
400 if ((returnstat
= pr_adr_char(context
, &how_to_print
, 1)) != 0)
403 if ((returnstat
= pr_adr_char(context
, &basic_unit
, 1)) != 0)
406 if ((returnstat
= pr_adr_char(context
, &unit_count
, 1)) != 0)
409 if (!(context
->format
& PRF_RAWM
)) {
410 uval
.uvaltype
= PRA_STRING
;
411 uval
.string_val
= htp2string(how_to_print
);
413 uval
.uvaltype
= PRA_INT32
;
414 uval
.int32_val
= (int)how_to_print
;
417 if ((returnstat
= open_tag(context
, TAG_ARBPRINT
)) != 0)
419 if ((returnstat
= pa_print(context
, &uval
, 0)) < 0)
421 if ((returnstat
= close_tag(context
, TAG_ARBPRINT
)) != 0)
424 if (!(context
->format
& PRF_RAWM
)) {
425 uval
.uvaltype
= PRA_STRING
;
426 uval
.string_val
= bu2string(basic_unit
);
428 uval
.uvaltype
= PRA_INT32
;
429 uval
.int32_val
= (int32_t)basic_unit
;
432 if ((returnstat
= open_tag(context
, TAG_ARBTYPE
)) != 0)
434 if ((returnstat
= pa_print(context
, &uval
, 0)) < 0)
436 if ((returnstat
= close_tag(context
, TAG_ARBTYPE
)) != 0)
439 uval
.uvaltype
= PRA_INT32
;
440 uval
.int32_val
= (int32_t)unit_count
;
442 if ((returnstat
= open_tag(context
, TAG_ARBCOUNT
)) != 0)
444 if ((returnstat
= pa_print(context
, &uval
, 1)) < 0)
446 if ((returnstat
= close_tag(context
, TAG_ARBCOUNT
)) != 0)
449 /* Done with attributes; force end of token open */
450 if ((returnstat
= finish_open_tag(context
)) != 0)
453 /* get the field width in case we need to format output */
454 fwid
= findfieldwidth(basic_unit
, how_to_print
);
455 p
= (char *)malloc(80);
457 /* now get the data items and print them */
458 for (i
= 0; (i
< unit_count
); i
++) {
459 switch (basic_unit
) {
462 if (pr_adr_char(context
, &c1
, 1) == 0)
463 (void) convert_char_to_string(how_to_print
,
471 if (pr_adr_short(context
, &c2
, 1) == 0)
472 (void) convert_short_to_string(how_to_print
,
480 if (pr_adr_int32(context
, &c3
, 1) == 0)
481 (void) convert_int32_to_string(how_to_print
,
489 if (pr_adr_int64(context
, &c4
, 1) == 0)
490 (void) convert_int64_to_string(how_to_print
,
504 * At this point, we have successfully retrieved a data
505 * item and converted it into an ASCII string pointed to
506 * by p. If all output is to be printed on one line,
507 * simply separate the data items by a space (or by the
508 * delimiter if this is the last data item), otherwise, we
509 * need to format the output before display.
511 if (context
->format
& PRF_ONELINE
) {
512 returnstat
= pr_printf(context
, "%s", p
);
513 if ((returnstat
>= 0) && (i
== (unit_count
- 1)))
514 returnstat
= pr_printf(context
, "%s",
517 returnstat
= pr_putchar(context
, ' ');
518 } else { /* format output */
519 returnstat
= pr_printf(context
, pformat
, fwid
, p
);
521 if ((returnstat
>= 0) &&
522 (((index
+ fwid
) > 75) ||
523 (i
== (unit_count
- 1)))) {
524 returnstat
= pr_putchar(context
, '\n');
527 } /* else if PRF_ONELINE */
528 if (returnstat
< 0) {
539 * -----------------------------------------------------------------------
540 * opaque_token() : Process opaque token and display contents
541 * return codes : -1 - error
543 * NOTE: At the time of call, the opaque token id has already been
546 * Format of opaque token:
547 * opaque token id adr_char
549 * data adr_char, size times
550 * -----------------------------------------------------------------------
553 opaque_token(pr_context_t
*context
)
561 /* print the size of the token */
562 if (pr_adr_short(context
, &size
, 1) == 0) {
563 uval
.uvaltype
= PRA_SHORT
;
564 uval
.short_val
= size
;
565 returnstat
= pa_print(context
, &uval
, 0);
569 /* now print out the data field in hexadecimal */
570 if (returnstat
>= 0) {
571 /* try to allocate memory for the character string */
572 if ((charp
= (char *)malloc(size
* sizeof (char))) == NULL
)
575 if ((returnstat
= pr_adr_char(context
, charp
,
577 /* print out in hexadecimal format */
578 uval
.uvaltype
= PRA_STRING
;
579 uval
.string_val
= hexconvert(charp
, size
, size
);
580 if (uval
.string_val
) {
581 returnstat
= pa_print(context
,
583 free(uval
.string_val
);
594 * -----------------------------------------------------------------------
595 * path_token() : Process path token and display contents
596 * return codes : -1 - error
598 * NOTE: At the time of call, the path token id has been retrieved
600 * Format of path token:
603 * -----------------------------------------------------------------------
606 path_token(pr_context_t
*context
)
608 char *path
; /* path */
609 char *apath
; /* anchored path */
610 char *cpath
; /* collapsed path */
616 * We need to know how much space to allocate for our string, so
617 * read the length first, then call pr_adr_char to read those bytes.
619 if (pr_adr_short(context
, &length
, 1) == 0) {
620 if ((path
= (char *)malloc(length
+ 1)) == NULL
) {
622 } else if (pr_adr_char(context
, path
, length
) == 0) {
624 uval
.uvaltype
= PRA_STRING
;
626 apath
= anchor_path(path
);
630 cpath
= collapse_path(apath
);
631 uval
.string_val
= cpath
;
632 returnstat
= pa_print(context
, &uval
, 1);
644 * anchor a path name with a slash
647 anchor_path(char *sp
)
649 char *dp
; /* destination path */
650 char *tp
; /* temporary path */
653 len
= strlen(sp
) + 2;
654 if ((dp
= tp
= (char *)calloc(1, len
)) == (char *)0)
659 (void) strlcpy(dp
, sp
, len
);
665 * copy path to collapsed path.
666 * collapsed path does not contain:
668 * instances of dot-slash
669 * instances of dot-dot-slash
670 * passed path must be anchored with a '/'
673 collapse_path(char *s
)
675 int id
; /* index of where we are in destination string */
676 int is
; /* index of where we are in source string */
677 int slashseen
; /* have we seen a slash */
678 int ls
; /* length of source string */
683 for (is
= 0, id
= 0; is
< ls
; is
++) {
684 /* thats all folks, we've reached the end of input */
686 if (id
> 1 && s
[id
-1] == '/') {
692 /* previous character was a / */
695 continue; /* another slash, ignore it */
696 } else if (s
[is
] == '/') {
697 /* we see a /, just copy it and try again */
703 if (s
[is
] == '.' && s
[is
+1] == '/') {
708 if (s
[is
] == '.' && s
[is
+1] == '\0') {
714 if (s
[is
] == '.' && s
[is
+1] == '.' && s
[is
+2] == '\0') {
718 while (id
> 0 && s
[--id
] != '/')
724 if (s
[is
] == '.' && s
[is
+1] == '.' && s
[is
+2] == '/') {
728 while (id
> 0 && s
[--id
] != '/')
733 while (is
< ls
&& (s
[id
++] = s
[is
++]) != '/')
741 * -----------------------------------------------------------------------
742 * cmd_token() : Process cmd token and display contents
743 * return codes : -1 - error
745 * NOTE: At the time of call, the cmd token id has been retrieved
747 * Format of command token:
750 * N*argv[i] adr_string (short, string)
752 * N*arge[i] adr_string (short, string)
753 * -----------------------------------------------------------------------
756 cmd_token(pr_context_t
*context
)
761 returnstat
= pr_adr_short(context
, &num
, 1);
765 if (!(context
->format
& PRF_XMLM
)) {
766 returnstat
= pr_printf(context
, "%s%s%d%s",
767 (context
->format
& PRF_ONELINE
) ? "" : gettext("argcnt"),
768 (context
->format
& PRF_ONELINE
) ? "" : context
->SEPARATOR
,
769 num
, context
->SEPARATOR
);
774 for (; num
> 0; num
--) {
775 if ((returnstat
= process_tag(context
, TAG_ARGV
,
780 if ((returnstat
= pr_adr_short(context
, &num
, 1)) < 0)
783 if (!(context
->format
& PRF_XMLM
)) {
784 returnstat
= pr_printf(context
, "%s%s%d%s",
785 (context
->format
& PRF_ONELINE
) ? "" : gettext("envcnt"),
786 (context
->format
& PRF_ONELINE
) ? "" : context
->SEPARATOR
,
787 num
, context
->SEPARATOR
);
792 if ((num
== 0) && !(context
->format
& PRF_XMLM
)) {
793 returnstat
= do_newline(context
, 1);
798 for (; num
> 1; num
--) {
799 if ((returnstat
= process_tag(context
, TAG_ARGE
,
804 returnstat
= process_tag(context
, TAG_ARGE
, returnstat
, 1);
811 * -----------------------------------------------------------------------
812 * argument32_token() : Process argument token and display contents
813 * return codes : -1 - error
815 * NOTE: At the time of call, the arg token id has been retrieved
817 * Format of argument token:
818 * current directory token id adr_char
819 * argument number adr_char
820 * argument value adr_int32
821 * argument description adr_string
822 * -----------------------------------------------------------------------
825 argument32_token(pr_context_t
*context
)
829 returnstat
= process_tag(context
, TAG_ARGNUM
, 0, 0);
830 returnstat
= process_tag(context
, TAG_ARGVAL32
, returnstat
, 0);
831 returnstat
= process_tag(context
, TAG_ARGDESC
, returnstat
, 1);
838 * -----------------------------------------------------------------------
839 * argument64_token() : Process argument token and display contents
840 * return codes : -1 - error
842 * NOTE: At the time of call, the arg token id has been retrieved
844 * Format of 64 bit argument token:
845 * current directory token id adr_char
846 * argument number adr_char
847 * argument value adr_int64
848 * argument description adr_string
849 * -----------------------------------------------------------------------
852 argument64_token(pr_context_t
*context
)
856 returnstat
= process_tag(context
, TAG_ARGNUM
, 0, 0);
857 returnstat
= process_tag(context
, TAG_ARGVAL64
, returnstat
, 0);
858 returnstat
= process_tag(context
, TAG_ARGDESC
, returnstat
, 1);
865 * -----------------------------------------------------------------------
866 * process_token() : Process process token and display contents
867 * return codes : -1 - error
869 * NOTE: At the time of call, the process token id has been retrieved
871 * Format of process token:
872 * process token id adr_char
880 * tid adr_u_int32, adr_u_int32
881 * -----------------------------------------------------------------------
884 process32_token(pr_context_t
*context
)
889 returnstat
= process_tag(context
, TAG_AUID
, 0, 0);
891 returnstat
= process_tag(context
, TAG_UID
, returnstat
, 0);
893 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
895 returnstat
= process_tag(context
, TAG_RUID
, returnstat
, 0);
897 returnstat
= process_tag(context
, TAG_RGID
, returnstat
, 0);
899 returnstat
= process_tag(context
, TAG_PID
, returnstat
, 0);
901 returnstat
= process_tag(context
, TAG_SID
, returnstat
, 0);
903 returnstat
= process_tag(context
, TAG_TID32
, returnstat
, 1);
909 process64_token(pr_context_t
*context
)
914 returnstat
= process_tag(context
, TAG_AUID
, 0, 0);
916 returnstat
= process_tag(context
, TAG_UID
, returnstat
, 0);
918 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
920 returnstat
= process_tag(context
, TAG_RUID
, returnstat
, 0);
922 returnstat
= process_tag(context
, TAG_RGID
, returnstat
, 0);
924 returnstat
= process_tag(context
, TAG_PID
, returnstat
, 0);
926 returnstat
= process_tag(context
, TAG_SID
, returnstat
, 0);
928 returnstat
= process_tag(context
, TAG_TID64
, returnstat
, 1);
934 * -----------------------------------------------------------------------
935 * process_ex_token() : Process process token and display contents
936 * return codes : -1 - error
938 * NOTE: At the time of call, the process token id has been retrieved
940 * Format of extended process token:
941 * process token id adr_char
949 * tid adr_u_int32, adr_u_int32, 4*adr_u_int32
950 * -----------------------------------------------------------------------
953 process32_ex_token(pr_context_t
*context
)
958 returnstat
= process_tag(context
, TAG_AUID
, 0, 0);
960 returnstat
= process_tag(context
, TAG_UID
, returnstat
, 0);
962 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
964 returnstat
= process_tag(context
, TAG_RUID
, returnstat
, 0);
966 returnstat
= process_tag(context
, TAG_RGID
, returnstat
, 0);
968 returnstat
= process_tag(context
, TAG_PID
, returnstat
, 0);
970 returnstat
= process_tag(context
, TAG_SID
, returnstat
, 0);
972 returnstat
= process_tag(context
, TAG_TID32_EX
, returnstat
, 1);
978 process64_ex_token(pr_context_t
*context
)
983 returnstat
= process_tag(context
, TAG_AUID
, 0, 0);
985 returnstat
= process_tag(context
, TAG_UID
, returnstat
, 0);
987 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
989 returnstat
= process_tag(context
, TAG_RUID
, returnstat
, 0);
991 returnstat
= process_tag(context
, TAG_RGID
, returnstat
, 0);
993 returnstat
= process_tag(context
, TAG_PID
, returnstat
, 0);
995 returnstat
= process_tag(context
, TAG_SID
, returnstat
, 0);
997 returnstat
= process_tag(context
, TAG_TID64_EX
, returnstat
, 1);
1003 * -----------------------------------------------------------------------
1004 * return_value32_token(): Process return value and display contents
1005 * return codes : -1 - error
1007 * NOTE: At the time of call, the return value token id has been retrieved
1009 * Format of return value token:
1010 * return value token id adr_char
1011 * error number adr_char
1012 * return value adr_int32
1013 * -----------------------------------------------------------------------
1016 return_value32_token(pr_context_t
*context
)
1021 char pb
[512]; /* print buffer */
1023 bool_t used_ret_val
= 0;
1026 * Every audit record generated contains a return token.
1028 * The return token is a special token. It indicates the success
1029 * or failure of the event that contains it.
1030 * The return32 token contains two pieces of data:
1033 * int32_t return_value;
1035 * For audit records generated by the kernel:
1036 * The kernel always puts a positive value in "number".
1037 * Upon success "number" is 0.
1038 * Upon failure "number" is a positive errno value that is less than
1041 * For audit records generated at the user level:
1042 * Upon success "number" is 0.
1043 * Upon failure "number" is -1.
1045 * For both kernel and user land the value of "return_value" is
1046 * arbitrary. For the kernel it contains the return value of
1047 * the system call. For user land it contains an arbitrary return
1048 * value if it is less than ADT_FAIL_VALUE; ADT_FAIL_VALUE
1049 * and above are messages defined in adt_event.h. ADT_FAIL_PAM and
1050 * above are messages from pam_strerror(). No interpretation is done
1051 * on "return_value" if it is outside the range of ADT_FAIL_VALUE_* or
1052 * ADT_FAIL_PAM values.
1054 if ((returnstat
= open_tag(context
, TAG_ERRVAL
)) != 0)
1055 return (returnstat
);
1057 if ((returnstat
= pr_adr_u_char(context
, &number
, 1)) == 0) {
1058 if (!(context
->format
& PRF_RAWM
)) {
1060 pa_error(number
, pb
, sizeof (pb
));
1061 uval
.uvaltype
= PRA_STRING
;
1062 uval
.string_val
= pb
;
1063 if ((returnstat
= pa_print(context
, &uval
, 0)) != 0)
1064 return (returnstat
);
1065 if ((returnstat
= close_tag(context
, TAG_ERRVAL
)) != 0)
1066 return (returnstat
);
1067 if ((returnstat
= open_tag(context
, TAG_RETVAL
)) != 0)
1068 return (returnstat
);
1070 if ((returnstat
= pr_adr_int32(
1071 context
, &value
, 1)) != 0)
1072 return (returnstat
);
1074 pa_retval(number
, value
, pb
, sizeof (pb
));
1076 uval
.uvaltype
= PRA_INT32
;
1077 if ((char)number
== -1)
1078 uval
.int32_val
= -1;
1080 uval
.int32_val
= number
;
1082 returnstat
= pa_print(context
, &uval
, used_ret_val
);
1085 if (returnstat
== 0)
1086 returnstat
= close_tag(context
, TAG_RETVAL
);
1087 return (returnstat
);
1090 if (returnstat
= close_tag(context
, TAG_ERRVAL
))
1091 return (returnstat
);
1093 return (process_tag(context
, TAG_RETVAL
, returnstat
, 1));
1097 * -----------------------------------------------------------------------
1098 * return_value64_token(): Process return value and display contents
1099 * return codes : -1 - error
1101 * NOTE: At the time of call, the return value token id has been retrieved
1103 * Format of return value token:
1104 * return value token id adr_char
1105 * error number adr_char
1106 * return value adr_int64
1108 * HOWEVER, the 64 bit return value is a concatenation of two
1109 * 32 bit return values; the first of which is the same as is
1110 * carried in the return32 token. The second 32 bits are ignored
1111 * here so that the displayed return token will have the same
1112 * number whether the application is 32 or 64 bits.
1113 * -----------------------------------------------------------------------
1116 return_value64_token(pr_context_t
*context
)
1121 char pb
[512]; /* print buffer */
1125 * Every audit record generated contains a return token.
1127 * The return token is a special token. It indicates the success
1128 * or failure of the event that contains it.
1129 * The return64 token contains two pieces of data:
1132 * int64_t return_value;
1134 * For audit records generated by the kernel:
1135 * The kernel always puts a positive value in "number".
1136 * Upon success "number" is 0.
1137 * Upon failure "number" is a positive errno value that is less than
1140 * For audit records generated at the user level:
1141 * Upon success "number" is 0.
1142 * Upon failure "number" is -1.
1144 * For both kernel and user land the value of "return_value" is
1145 * arbitrary. For the kernel it contains the return value of
1146 * the system call. For user land it contains an arbitrary return
1147 * value if it is less than ADT_FAIL_VALUE; ADT_FAIL_VALUE
1148 * and above are messages defined in adt_event.h. ADT_FAIL_PAM and
1149 * above are messages from pam_strerror(). No interpretation is done
1150 * on "return_value" if it is outside the range of ADT_FAIL_VALUE_* or
1151 * ADT_FAIL_PAM values.
1153 * The 64 bit return value consists of two 32bit parts; for
1154 * system calls, the first part is the value returned by the
1155 * system call and the second part depends on the system call
1156 * implementation. In most cases, the second part is either 0
1157 * or garbage; because of that, it is omitted from the praudit
1160 if ((returnstat
= open_tag(context
, TAG_ERRVAL
)) != 0)
1161 return (returnstat
);
1163 if ((returnstat
= pr_adr_u_char(context
, &number
, 1)) == 0) {
1164 if (!(context
->format
& PRF_RAWM
)) {
1165 pa_error(number
, pb
, sizeof (pb
));
1166 uval
.uvaltype
= PRA_STRING
;
1167 uval
.string_val
= pb
;
1168 if ((returnstat
= pa_print(context
, &uval
, 0)) != 0)
1169 return (returnstat
);
1171 if ((returnstat
= close_tag(context
, TAG_ERRVAL
)) != 0)
1172 return (returnstat
);
1173 if ((returnstat
= open_tag(context
, TAG_RETVAL
)) != 0)
1174 return (returnstat
);
1176 if ((returnstat
= pr_adr_int64(context
,
1177 &rval
.r_vals
, 1)) != 0)
1178 return (returnstat
);
1179 pa_retval(number
, rval
.r_val1
, pb
, sizeof (pb
));
1181 uval
.uvaltype
= PRA_INT32
;
1182 if ((char)number
== -1)
1183 uval
.int32_val
= -1;
1185 uval
.int32_val
= number
;
1187 if ((returnstat
= pa_print(context
, &uval
, 0)) != 0)
1188 return (returnstat
);
1190 if ((returnstat
= close_tag(context
, TAG_ERRVAL
)) != 0)
1191 return (returnstat
);
1192 if ((returnstat
= open_tag(context
, TAG_RETVAL
)) != 0)
1193 return (returnstat
);
1195 if ((returnstat
= pr_adr_int64(context
,
1196 &rval
.r_vals
, 1)) != 0)
1197 return (returnstat
);
1198 uval
.int32_val
= rval
.r_val1
;
1200 returnstat
= pa_print(context
, &uval
, 1);
1202 return (returnstat
);
1205 if (returnstat
== 0)
1206 returnstat
= close_tag(context
, TAG_RETVAL
);
1208 return (returnstat
);
1212 * -----------------------------------------------------------------------
1213 * subject32_token() : Process subject token and display contents
1214 * return codes : -1 - error
1216 * NOTE: At the time of call, the subject token id has been retrieved
1218 * Format of subject token:
1219 * subject token id adr_char
1227 * tid adr_u_int32, adr_u_int32
1228 * -----------------------------------------------------------------------
1231 subject32_token(pr_context_t
*context
)
1236 returnstat
= process_tag(context
, TAG_AUID
, 0, 0);
1238 returnstat
= process_tag(context
, TAG_UID
, returnstat
, 0);
1240 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
1242 returnstat
= process_tag(context
, TAG_RUID
, returnstat
, 0);
1244 returnstat
= process_tag(context
, TAG_RGID
, returnstat
, 0);
1246 returnstat
= process_tag(context
, TAG_PID
, returnstat
, 0);
1248 returnstat
= process_tag(context
, TAG_SID
, returnstat
, 0);
1250 returnstat
= process_tag(context
, TAG_TID32
, returnstat
, 1);
1252 return (returnstat
);
1256 subject64_token(pr_context_t
*context
)
1261 returnstat
= process_tag(context
, TAG_AUID
, 0, 0);
1263 returnstat
= process_tag(context
, TAG_UID
, returnstat
, 0);
1265 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
1267 returnstat
= process_tag(context
, TAG_RUID
, returnstat
, 0);
1269 returnstat
= process_tag(context
, TAG_RGID
, returnstat
, 0);
1271 returnstat
= process_tag(context
, TAG_PID
, returnstat
, 0);
1273 returnstat
= process_tag(context
, TAG_SID
, returnstat
, 0);
1275 returnstat
= process_tag(context
, TAG_TID64
, returnstat
, 1);
1277 return (returnstat
);
1281 * -----------------------------------------------------------------------
1282 * subject_ex_token(): Process subject token and display contents
1283 * return codes : -1 - error
1285 * NOTE: At the time of call, the subject token id has been retrieved
1287 * Format of extended subject token:
1288 * subject token id adr_char
1296 * tid adr_u_int32, adr_u_int32
1297 * -----------------------------------------------------------------------
1300 subject32_ex_token(pr_context_t
*context
)
1305 returnstat
= process_tag(context
, TAG_AUID
, 0, 0);
1307 returnstat
= process_tag(context
, TAG_UID
, returnstat
, 0);
1309 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
1311 returnstat
= process_tag(context
, TAG_RUID
, returnstat
, 0);
1313 returnstat
= process_tag(context
, TAG_RGID
, returnstat
, 0);
1315 returnstat
= process_tag(context
, TAG_PID
, returnstat
, 0);
1317 returnstat
= process_tag(context
, TAG_SID
, returnstat
, 0);
1319 returnstat
= process_tag(context
, TAG_TID32_EX
, returnstat
, 1);
1321 return (returnstat
);
1325 subject64_ex_token(pr_context_t
*context
)
1330 returnstat
= process_tag(context
, TAG_AUID
, 0, 0);
1332 returnstat
= process_tag(context
, TAG_UID
, returnstat
, 0);
1334 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
1336 returnstat
= process_tag(context
, TAG_RUID
, returnstat
, 0);
1338 returnstat
= process_tag(context
, TAG_RGID
, returnstat
, 0);
1340 returnstat
= process_tag(context
, TAG_PID
, returnstat
, 0);
1342 returnstat
= process_tag(context
, TAG_SID
, returnstat
, 0);
1344 returnstat
= process_tag(context
, TAG_TID64_EX
, returnstat
, 1);
1346 return (returnstat
);
1350 * -----------------------------------------------------------------------
1351 * s5_IPC_token() : Process System V IPC token and display contents
1352 * return codes : -1 - error
1354 * NOTE: At the time of call, the System V IPC id has been retrieved
1356 * Format of System V IPC token:
1357 * System V IPC token id adr_char
1358 * object id adr_int32
1359 * -----------------------------------------------------------------------
1362 s5_IPC_token(pr_context_t
*context
)
1370 * These names refer to the type of System V IPC object:
1371 * message queue, semaphore, shared memory.
1374 if (pr_adr_u_char(context
, &ipctype
, 1) == 0) {
1375 if ((returnstat
= open_tag(context
, TAG_IPCTYPE
)) != 0)
1376 return (returnstat
);
1378 if (!(context
->format
& PRF_RAWM
)) {
1379 /* print in ASCII form */
1380 uval
.uvaltype
= PRA_STRING
;
1383 uval
.string_val
= gettext("msg");
1386 uval
.string_val
= gettext("sem");
1389 uval
.string_val
= gettext("shm");
1392 returnstat
= pa_print(context
, &uval
, 0);
1394 /* print in integer form */
1395 if ((context
->format
& PRF_RAWM
) || (returnstat
== 1)) {
1396 uval
.uvaltype
= PRA_BYTE
;
1397 uval
.char_val
= ipctype
;
1398 returnstat
= pa_print(context
, &uval
, 0);
1400 if ((returnstat
= close_tag(context
, TAG_IPCTYPE
)) != 0)
1401 return (returnstat
);
1403 /* next get and print ipc id */
1404 return (process_tag(context
, TAG_IPCID
, returnstat
, 1));
1406 /* cannot retrieve ipc type */
1412 * -----------------------------------------------------------------------
1413 * text_token() : Process text token and display contents
1414 * return codes : -1 - error
1416 * NOTE: At the time of call, the text token id has been retrieved
1418 * Format of text token:
1419 * text token id adr_char
1421 * -----------------------------------------------------------------------
1424 text_token(pr_context_t
*context
)
1426 return (pa_adr_string(context
, 0, 1));
1430 * -----------------------------------------------------------------------
1431 * tid_token() : Process a generic terminal id token / AUT_TID
1432 * return codes : -1 - error
1434 * NOTE: At the time of call, the token id has been retrieved
1436 * Format of tid token:
1437 * ip token id adr_char
1438 * terminal type adr_char
1439 * terminal type = AU_IPADR:
1440 * remote port: adr_short
1441 * local port: adr_short
1442 * IP type: adt_int32 -- AU_IPv4 or AU_IPv6
1443 * address: adr_int32 if IPv4, else 4 * adr_int32
1444 * -----------------------------------------------------------------------
1447 tid_token(pr_context_t
*context
)
1453 if ((returnstat
= pr_adr_u_char(context
, &type
, 1)) != 0)
1454 return (returnstat
);
1455 uval
.uvaltype
= PRA_STRING
;
1456 if ((returnstat
= open_tag(context
, TAG_TID_TYPE
)) != 0)
1457 return (returnstat
);
1461 return (-1); /* other than IP type is not implemented */
1463 uval
.string_val
= "ip";
1464 returnstat
= pa_print(context
, &uval
, 0);
1465 returnstat
= close_tag(context
, TAG_TID_TYPE
);
1466 returnstat
= open_tag(context
, TAG_IP
);
1467 returnstat
= process_tag(context
, TAG_IP_REMOTE
, returnstat
, 0);
1468 returnstat
= process_tag(context
, TAG_IP_LOCAL
, returnstat
, 0);
1469 returnstat
= process_tag(context
, TAG_IP_ADR
, returnstat
, 1);
1470 returnstat
= close_tag(context
, TAG_IP
);
1473 return (returnstat
);
1477 * -----------------------------------------------------------------------
1478 * ip_addr_token() : Process ip token and display contents
1479 * return codes : -1 - error
1481 * NOTE: At the time of call, the ip token id has been retrieved
1483 * Format of ip address token:
1484 * ip token id adr_char
1485 * address adr_int32 (printed in hex)
1486 * -----------------------------------------------------------------------
1490 ip_addr_token(pr_context_t
*context
)
1492 return (pa_hostname(context
, 0, 1));
1496 ip_addr_ex_token(pr_context_t
*context
)
1499 uint32_t ip_addr
[16];
1506 /* get address type */
1507 if ((returnstat
= pr_adr_u_int32(context
, &ip_type
, 1)) != 0)
1508 return (returnstat
);
1510 /* legal address types are either AU_IPv4 or AU_IPv6 only */
1511 if ((ip_type
!= AU_IPv4
) && (ip_type
!= AU_IPv6
))
1514 /* get address (4/16) */
1515 if ((returnstat
= pr_adr_char(context
, (char *)ip_addr
, ip_type
)) != 0)
1516 return (returnstat
);
1518 uval
.uvaltype
= PRA_STRING
;
1519 if (ip_type
== AU_IPv4
) {
1520 uval
.string_val
= buf
;
1522 if (!(context
->format
& PRF_RAWM
)) {
1523 get_Hname(ip_addr
[0], buf
, sizeof (buf
));
1524 return (pa_print(context
, &uval
, 1));
1527 ia
.s_addr
= ip_addr
[0];
1528 if ((ipstring
= inet_ntoa(ia
)) == NULL
)
1531 (void) snprintf(buf
, sizeof (buf
), "%s", ipstring
);
1534 uval
.string_val
= buf
;
1536 if (!(context
->format
& PRF_RAWM
)) {
1537 get_Hname_ex(ip_addr
, buf
, sizeof (buf
));
1538 return (pa_print(context
, &uval
, 1));
1541 (void) inet_ntop(AF_INET6
, (void *) ip_addr
, buf
,
1546 return (pa_print(context
, &uval
, 1));
1550 * -----------------------------------------------------------------------
1551 * ip_token() : Process ip header token and display contents
1552 * return codes : -1 - error
1554 * NOTE: At the time of call, the ip token id has been retrieved
1556 * Format of ip header token:
1557 * ip header token id adr_char
1558 * version adr_char (printed in hex)
1559 * type of service adr_char (printed in hex)
1562 * offset adr_u_short
1563 * ttl adr_char (printed in hex)
1564 * protocol adr_char (printed in hex)
1565 * checksum adr_u_short
1566 * source address adr_int32 (printed in hex)
1567 * destination address adr_int32 (printed in hex)
1568 * -----------------------------------------------------------------------
1571 ip_token(pr_context_t
*context
)
1575 returnstat
= process_tag(context
, TAG_IPVERS
, 0, 0);
1576 returnstat
= process_tag(context
, TAG_IPSERV
, returnstat
, 0);
1577 returnstat
= process_tag(context
, TAG_IPLEN
, returnstat
, 0);
1578 returnstat
= process_tag(context
, TAG_IPID
, returnstat
, 0);
1579 returnstat
= process_tag(context
, TAG_IPOFFS
, returnstat
, 0);
1580 returnstat
= process_tag(context
, TAG_IPTTL
, returnstat
, 0);
1581 returnstat
= process_tag(context
, TAG_IPPROTO
, returnstat
, 0);
1582 returnstat
= process_tag(context
, TAG_IPCKSUM
, returnstat
, 0);
1583 returnstat
= process_tag(context
, TAG_IPSRC
, returnstat
, 0);
1584 returnstat
= process_tag(context
, TAG_IPDEST
, returnstat
, 1);
1586 return (returnstat
);
1590 * -----------------------------------------------------------------------
1591 * iport_token() : Process ip port address token and display contents
1592 * return codes : -1 - error
1594 * NOTE: At time of call, the ip port address token id has been retrieved
1596 * Format of ip port token:
1597 * ip port address token id adr_char
1598 * port address adr_short (in_port_t == uint16_t)
1599 * -----------------------------------------------------------------------
1602 iport_token(pr_context_t
*context
)
1604 return (pa_adr_u_short(context
, 0, 1));
1608 * -----------------------------------------------------------------------
1609 * socket_token() : Process socket token and display contents
1610 * return codes : -1 - error
1612 * NOTE: At time of call, the socket token id has been retrieved
1614 * Format of socket token:
1615 * ip socket token id adr_char
1616 * socket type adr_short (in hex)
1617 * foreign port adr_short (in hex)
1618 * foreign internet address adr_hostname/adr_int32 (in ascii/hex)
1619 * -----------------------------------------------------------------------
1621 * Note: local port and local internet address have been removed for 5.x
1624 socket_token(pr_context_t
*context
)
1628 returnstat
= process_tag(context
, TAG_SOCKTYPE
, 0, 0);
1629 returnstat
= process_tag(context
, TAG_SOCKPORT
, returnstat
, 0);
1630 if (returnstat
!= 0)
1631 return (returnstat
);
1633 if ((returnstat
= open_tag(context
, TAG_SOCKADDR
)) != 0)
1634 return (returnstat
);
1636 if ((returnstat
= pa_hostname(context
, returnstat
, 1)) != 0)
1637 return (returnstat
);
1639 return (close_tag(context
, TAG_SOCKADDR
));
1643 * -----------------------------------------------------------------------
1644 * socket_ex_token() : Process socket token and display contents
1645 * return codes : -1 - error
1647 * NOTE: At time of call, the extended socket token id has been retrieved
1649 * Format of extended socket token:
1651 * socket domain adr_short (in hex)
1652 * socket type adr_short (in hex)
1653 * IP address type adr_short (in hex) [not displayed]
1654 * local port adr_short (in hex)
1655 * local internet address adr_hostname/adr_int32 (in ascii/hex)
1656 * foreign port adr_short (in hex)
1657 * foreign internet address adr_hostname/adr_int32 (in ascii/hex)
1658 * -----------------------------------------------------------------------
1660 * Note: local port and local internet address have been removed for 5.x
1663 socket_ex_token(pr_context_t
*context
)
1667 returnstat
= process_tag(context
, TAG_SOCKEXDOM
, 0, 0);
1668 returnstat
= process_tag(context
, TAG_SOCKEXTYPE
, returnstat
, 0);
1669 returnstat
= pa_hostname_so(context
, returnstat
, 1);
1671 return (returnstat
);
1675 * -----------------------------------------------------------------------
1676 * sequence_token() : Process sequence token and display contents
1677 * return codes : -1 - error
1679 * NOTE: At time of call, the socket token id has been retrieved
1681 * Format of sequence token:
1682 * sequence token id adr_char
1683 * sequence number adr_u_int32 (in hex)
1684 * -----------------------------------------------------------------------
1687 sequence_token(pr_context_t
*context
)
1689 return (process_tag(context
, TAG_SEQNUM
, 0, 1));
1693 * -----------------------------------------------------------------------
1694 * acl_token() : Process access control list term
1695 * return codes : -1 - error
1698 * Format of acl token:
1700 * term type adr_u_int32
1701 * term value adr_u_int32 (depends on type)
1702 * file mode adr_u_int (in octal)
1703 * -----------------------------------------------------------------------
1706 acl_token(pr_context_t
*context
)
1710 returnstat
= pa_pw_uid_gr_gid(context
, 0, 0);
1712 return (process_tag(context
, TAG_MODE
, returnstat
, 1));
1716 * -----------------------------------------------------------------------
1717 * ace_token() : Process ZFS/NFSv4 access control list term
1718 * return codes : -1 - error
1721 * Format of ace token:
1723 * term who adr_u_int32 (uid/gid)
1724 * term mask adr_u_int32
1725 * term flags adr_u_int16
1726 * term type adr_u_int16
1727 * -----------------------------------------------------------------------
1730 ace_token(pr_context_t
*context
)
1732 return (pa_ace(context
, 0, 1));
1736 * -----------------------------------------------------------------------
1737 * attribute_token() : Process attribute token and display contents
1738 * return codes : -1 - error
1740 * NOTE: At the time of call, the attribute token id has been retrieved
1742 * Format of attribute token:
1743 * attribute token id adr_char
1744 * mode adr_u_int (printed in octal)
1747 * file system id adr_int
1749 * node id adr_int (attribute_token
1753 * node id adr_int64 (attribute32_token)
1756 * node id adr_int64 (attribute64_token)
1757 * device adr_u_int64
1758 * -----------------------------------------------------------------------
1761 attribute_token(pr_context_t
*context
)
1765 returnstat
= process_tag(context
, TAG_MODE
, 0, 0);
1766 returnstat
= process_tag(context
, TAG_UID
, returnstat
, 0);
1767 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
1768 returnstat
= process_tag(context
, TAG_FSID
, returnstat
, 0);
1769 returnstat
= process_tag(context
, TAG_NODEID32
, returnstat
, 0);
1770 returnstat
= process_tag(context
, TAG_DEVICE32
, returnstat
, 1);
1772 return (returnstat
);
1776 attribute32_token(pr_context_t
*context
)
1780 returnstat
= process_tag(context
, TAG_MODE
, 0, 0);
1781 returnstat
= process_tag(context
, TAG_UID
, returnstat
, 0);
1782 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
1783 returnstat
= process_tag(context
, TAG_FSID
, returnstat
, 0);
1784 returnstat
= process_tag(context
, TAG_NODEID64
, returnstat
, 0);
1785 returnstat
= process_tag(context
, TAG_DEVICE32
, returnstat
, 1);
1787 return (returnstat
);
1791 attribute64_token(pr_context_t
*context
)
1795 returnstat
= process_tag(context
, TAG_MODE
, 0, 0);
1796 returnstat
= process_tag(context
, TAG_UID
, returnstat
, 0);
1797 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
1798 returnstat
= process_tag(context
, TAG_FSID
, returnstat
, 0);
1799 returnstat
= process_tag(context
, TAG_NODEID64
, returnstat
, 0);
1800 returnstat
= process_tag(context
, TAG_DEVICE64
, returnstat
, 1);
1802 return (returnstat
);
1806 * -----------------------------------------------------------------------
1807 * group_token() : Process group token and display contents
1808 * return codes : -1 - error
1810 * NOTE: At the time of call, the group token id has been retrieved
1811 * NOTE: This token is obsolete; it supports exactly NGROUPS_MAX
1814 * Format of group token:
1815 * group token id adr_char
1816 * group list adr_long, 16 times
1817 * -----------------------------------------------------------------------
1820 group_token(pr_context_t
*context
)
1825 for (i
= 0; i
< NGROUPS_MAX
- 1; i
++) {
1826 if ((returnstat
= process_tag(context
, TAG_GROUPID
,
1827 returnstat
, 0)) < 0)
1828 return (returnstat
);
1831 return (process_tag(context
, TAG_GROUPID
, returnstat
, 1));
1835 * -----------------------------------------------------------------------
1836 * newgroup_token() : Process group token and display contents
1837 * return codes : -1 - error
1839 * NOTE: At the time of call, the group token id has been retrieved
1841 * Format of new group token:
1842 * group token id adr_char
1843 * group number adr_short
1844 * group list adr_int32, group number times
1845 * -----------------------------------------------------------------------
1848 newgroup_token(pr_context_t
*context
)
1854 returnstat
= pr_adr_short(context
, &n_groups
, 1);
1855 if (returnstat
!= 0)
1856 return (returnstat
);
1858 num
= (int)n_groups
;
1860 if (!(context
->format
& PRF_XMLM
)) {
1861 returnstat
= do_newline(context
, 1);
1863 return (returnstat
);
1865 for (i
= 0; i
< num
- 1; i
++) {
1866 if ((returnstat
= process_tag(context
, TAG_GROUPID
,
1867 returnstat
, 0)) < 0)
1868 return (returnstat
);
1871 return (process_tag(context
, TAG_GROUPID
, returnstat
, 1));
1875 string_token_common(pr_context_t
*context
, int tag
)
1880 returnstat
= pr_adr_int32(context
, (int32_t *)&num
, 1);
1881 if (returnstat
!= 0)
1882 return (returnstat
);
1884 if (!(context
->format
& PRF_XMLM
)) {
1885 returnstat
= pr_printf(context
, "%d%s", num
,
1886 context
->SEPARATOR
);
1887 if (returnstat
!= 0)
1888 return (returnstat
);
1892 return (do_newline(context
, 1));
1894 for (; num
> 1; num
--) {
1895 if ((returnstat
= (process_tag(context
, tag
,
1896 returnstat
, 0))) < 0)
1897 return (returnstat
);
1900 return (process_tag(context
, tag
, returnstat
, 1));
1904 path_attr_token(pr_context_t
*context
)
1906 return (string_token_common(context
, TAG_XAT
));
1910 exec_args_token(pr_context_t
*context
)
1912 return (string_token_common(context
, TAG_ARG
));
1916 exec_env_token(pr_context_t
*context
)
1918 return (string_token_common(context
, TAG_ENV
));
1922 * -----------------------------------------------------------------------
1923 * s5_IPC_perm_token() : Process System V IPC permission token and display
1925 * return codes : -1 - error
1927 * NOTE: At the time of call, the System V IPC permission token id
1928 * has been retrieved
1930 * Format of System V IPC permission token:
1931 * System V IPC permission token id adr_char
1939 * -----------------------------------------------------------------------
1942 s5_IPC_perm_token(pr_context_t
*context
)
1946 returnstat
= process_tag(context
, TAG_UID
, 0, 0);
1947 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
1948 returnstat
= process_tag(context
, TAG_CUID
, returnstat
, 0);
1949 returnstat
= process_tag(context
, TAG_CGID
, returnstat
, 0);
1950 returnstat
= process_tag(context
, TAG_MODE
, returnstat
, 0);
1951 returnstat
= process_tag(context
, TAG_SEQ
, returnstat
, 0);
1952 returnstat
= process_tag(context
, TAG_KEY
, returnstat
, 1);
1954 return (returnstat
);
1958 * -----------------------------------------------------------------------
1959 * host_token() : Process host token and display contents
1960 * return codes : -1 - error
1962 * NOTE: At the time of call, the host token id has been retrieved
1964 * Format of host token:
1965 * host token id adr_char
1966 * hostid adr_u_int32
1967 * -----------------------------------------------------------------------
1970 host_token(pr_context_t
*context
)
1972 return (pa_hostname(context
, 0, 1));
1976 * -----------------------------------------------------------------------
1977 * liaison_token() : Process liaison token and display contents
1978 * return codes : -1 - error
1980 * NOTE: At the time of call, the liaison token id has been retrieved
1982 * Format of liaison token:
1983 * liaison token id adr_char
1984 * liaison adr_u_int32
1985 * -----------------------------------------------------------------------
1988 liaison_token(pr_context_t
*context
)
1990 return (pa_liaison(context
, 0, 1));
1994 * -----------------------------------------------------------------------
1995 * useofauth_token(): Process useofauth token and display contents
1996 * return codes : -1 - error
1998 * NOTE: At the time of call, the uauth token id has been retrieved
2000 * Format of useofauth token:
2001 * uauth token id adr_char
2003 * -----------------------------------------------------------------------
2006 useofauth_token(pr_context_t
*context
)
2008 return (pa_adr_string(context
, 0, 1));
2012 * -----------------------------------------------------------------------
2013 * user_token(): Process user token and display contents
2014 * return codes : -1 - error
2016 * NOTE: At the time of call, the user token id has been retrieved
2018 * Format of user token:
2019 * user token id adr_char
2021 * user name adr_string
2022 * -----------------------------------------------------------------------
2025 user_token(pr_context_t
*context
)
2029 returnstat
= process_tag(context
, TAG_UID
, 0, 0);
2030 return (process_tag(context
, TAG_USERNAME
, returnstat
, 1));
2034 * -----------------------------------------------------------------------
2035 * zonename_token(): Process zonename token and display contents
2036 * return codes : -1 - error
2038 * NOTE: At the time of call, the zonename token id has been retrieved
2040 * Format of zonename token:
2041 * zonename token id adr_char
2042 * zone name adr_string
2043 * -----------------------------------------------------------------------
2046 zonename_token(pr_context_t
*context
)
2048 return (process_tag(context
, TAG_ZONENAME
, 0, 1));
2052 * -----------------------------------------------------------------------
2053 * fmri_token(): Process fmri token and display contents
2054 * return codes : -1 - error
2056 * NOTE: At the time of call, the fmri token id has been retrieved
2058 * Format of fmri token:
2059 * fmri token id adr_char
2060 * service instance name adr_string
2061 * -----------------------------------------------------------------------
2064 fmri_token(pr_context_t
*context
)
2066 return (pa_adr_string(context
, 0, 1));
2070 * -----------------------------------------------------------------------
2071 * xatom_token() : Process Xatom token and display contents in hex.
2072 * return codes : -1 - error
2074 * NOTE: At the time of call, the xatom token id has been retrieved
2076 * Format of xatom token:
2079 * atom adr_char length times
2080 * -----------------------------------------------------------------------
2083 xatom_token(pr_context_t
*context
)
2085 return (pa_adr_string(context
, 0, 1));
2089 xcolormap_token(pr_context_t
*context
)
2091 return (pa_xgeneric(context
));
2095 xcursor_token(pr_context_t
*context
)
2097 return (pa_xgeneric(context
));
2101 xfont_token(pr_context_t
*context
)
2103 return (pa_xgeneric(context
));
2107 xgc_token(pr_context_t
*context
)
2109 return (pa_xgeneric(context
));
2113 xpixmap_token(pr_context_t
*context
)
2115 return (pa_xgeneric(context
));
2119 xwindow_token(pr_context_t
*context
)
2121 return (pa_xgeneric(context
));
2125 * -----------------------------------------------------------------------
2126 * xproperty_token(): Process Xproperty token and display contents
2128 * return codes : -1 - error
2130 * NOTE: At the time of call, the xproperty token id has been retrieved
2132 * Format of xproperty token:
2135 * creator UID adr_u_int32
2137 * -----------------------------------------------------------------------
2140 xproperty_token(pr_context_t
*context
)
2144 returnstat
= process_tag(context
, TAG_XID
, 0, 0);
2145 returnstat
= process_tag(context
, TAG_XCUID
, returnstat
, 0);
2147 /* Done with attributes; force end of token open */
2148 if (returnstat
== 0)
2149 returnstat
= finish_open_tag(context
);
2151 returnstat
= pa_adr_string(context
, returnstat
, 1);
2153 return (returnstat
);
2157 * -----------------------------------------------------------------------
2158 * xselect_token(): Process Xselect token and display contents in hex
2160 * return codes : -1 - error
2162 * NOTE: At the time of call, the xselect token id has been retrieved
2164 * Format of xselect token
2165 * text token id adr_char
2166 * property text adr_string
2167 * property type adr_string
2168 * property data adr_string
2169 * -----------------------------------------------------------------------
2172 xselect_token(pr_context_t
*context
)
2176 returnstat
= process_tag(context
, TAG_XSELTEXT
, 0, 0);
2177 returnstat
= process_tag(context
, TAG_XSELTYPE
, returnstat
, 0);
2178 returnstat
= process_tag(context
, TAG_XSELDATA
, returnstat
, 1);
2180 return (returnstat
);
2184 * -----------------------------------------------------------------------
2185 * xclient_token(): Process Xclient token and display contents in hex.
2187 * return codes : -1 - error
2190 * Format of xclient token:
2193 * -----------------------------------------------------------------------
2196 xclient_token(pr_context_t
*context
)
2198 return (pa_adr_int32(context
, 0, 1));
2202 * -----------------------------------------------------------------------
2203 * label_token() : Process label token and display contents
2204 * return codes : -1 - error
2206 * NOTE: At the time of call, the label token id has been retrieved
2208 * Format of label token:
2209 * label token id adr_char
2211 * label compartment length adr_char
2212 * label classification adr_short
2213 * label compartment words <compartment length> * 4 adr_char
2214 * -----------------------------------------------------------------------
2218 label_token(pr_context_t
*context
)
2220 static m_label_t
*label
= NULL
;
2221 static size32_t l_size
;
2226 if (label
== NULL
) {
2227 if ((label
= m_label_alloc(MAC_LABEL
)) == NULL
) {
2230 l_size
= blabel_size() - 4;
2232 if ((returnstat
= pr_adr_char(context
, (char *)label
, 4)) == 0) {
2233 len
= (int)(((char *)label
)[1] * 4);
2234 if ((len
> l_size
) ||
2235 (pr_adr_char(context
, &((char *)label
)[4], len
) != 0)) {
2238 uval
.uvaltype
= PRA_STRING
;
2239 if (!(context
->format
& PRF_RAWM
)) {
2240 /* print in ASCII form */
2241 if (label_to_str(label
, &uval
.string_val
, M_LABEL
,
2243 returnstat
= pa_print(context
, &uval
, 1);
2244 } else /* cannot convert to string */
2247 /* print in hexadecimal form */
2248 if ((context
->format
& PRF_RAWM
) || (returnstat
== 1)) {
2249 uval
.string_val
= hexconvert((char *)label
, len
, len
);
2250 if (uval
.string_val
) {
2251 returnstat
= pa_print(context
, &uval
, 1);
2254 free(uval
.string_val
);
2256 return (returnstat
);
2260 * -----------------------------------------------------------------------
2261 * useofpriv_token() : Process priv token and display contents
2262 * return codes : -1 - error
2264 * NOTE: At the time of call, the useofpriv token id has been retrieved
2266 * Format of useofpriv token:
2267 * useofpriv token id adr_char
2268 * success/failure flag adr_char
2269 * priv adr_int32 (Trusted Solaris)
2270 * priv_set '\0' separated privileges.
2271 * -----------------------------------------------------------------------
2275 useofpriv_token(pr_context_t
*context
)
2281 if ((returnstat
= pr_adr_char(context
, &sf
, 1)) != 0) {
2282 return (returnstat
);
2284 if (!(context
->format
& PRF_RAWM
)) {
2285 /* print in ASCII form */
2287 if ((returnstat
= open_tag(context
, TAG_RESULT
)) != 0)
2288 return (returnstat
);
2290 uval
.uvaltype
= PRA_STRING
;
2292 uval
.string_val
= gettext("successful use of priv");
2293 returnstat
= pa_print(context
, &uval
, 0);
2295 uval
.string_val
= gettext("failed use of priv");
2296 returnstat
= pa_print(context
, &uval
, 0);
2298 if (returnstat
== 0)
2299 returnstat
= close_tag(context
, TAG_RESULT
);
2301 /* Done with attributes; force end of token open */
2302 if (returnstat
== 0)
2303 returnstat
= finish_open_tag(context
);
2305 /* print in hexadecimal form */
2306 if ((returnstat
= open_tag(context
, TAG_RESULT
)) != 0)
2307 return (returnstat
);
2308 uval
.uvaltype
= PRA_SHORT
;
2309 uval
.short_val
= sf
;
2310 returnstat
= pa_print(context
, &uval
, 0);
2311 if (returnstat
== 0)
2312 returnstat
= close_tag(context
, TAG_RESULT
);
2314 /* Done with attributes; force end of token open */
2315 if (returnstat
== 0)
2316 returnstat
= finish_open_tag(context
);
2318 return (pa_adr_string(context
, 0, 1));
2322 * -----------------------------------------------------------------------
2323 * privilege_token() : Process privilege token and display contents
2324 * return codes : -1 - error
2326 * NOTE: At the time of call, the privilege token id has been retrieved
2328 * Format of privilege token:
2329 * privilege token id adr_char
2330 * privilege type adr_string
2331 * privilege adr_string
2332 * -----------------------------------------------------------------------
2335 privilege_token(pr_context_t
*context
)
2339 /* privilege type: */
2340 returnstat
= process_tag(context
, TAG_SETTYPE
, 0, 0);
2342 /* Done with attributes; force end of token open */
2343 if (returnstat
== 0)
2344 returnstat
= finish_open_tag(context
);
2347 return (pa_adr_string(context
, returnstat
, 1));
2351 * -----------------------------------------------------------------------
2352 * secflags_token() : Process privilege token and display contents
2353 * return codes : -1 - error
2355 * NOTE: At the time of call, the secflags token id has been retrieved
2357 * Format of secflags token:
2358 * secflags token id adr_char
2359 * secflag set name adr_string
2360 * secflags adr_string
2361 * -----------------------------------------------------------------------
2364 secflags_token(pr_context_t
*context
)
2369 returnstat
= process_tag(context
, TAG_SETTYPE
, 0, 0);
2371 /* Done with attributes; force end of token open */
2372 if (returnstat
== 0)
2373 returnstat
= finish_open_tag(context
);
2376 return (pa_adr_string(context
, returnstat
, 1));