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>
70 #include <arpa/inet.h>
72 static char *anchor_path(char *);
73 static char *collapse_path(char *);
77 * -----------------------------------------------------------------------
79 * Tests whether the specified token id represents a type
81 * return codes : 1 - tokenid is a file token type
83 * -----------------------------------------------------------------------
86 is_file_token(int tokenid
)
88 if ((tokenid
== AUT_OTHER_FILE32
) || (tokenid
== AUT_OTHER_FILE64
))
95 * -----------------------------------------------------------------------
97 * Tests whether the specified token id represents a type
98 * of header token (signifying the start of a record).
99 * return codes : 1 - tokenid is a header type
101 * -----------------------------------------------------------------------
104 is_header_token(int tokenid
)
106 if ((tokenid
== AUT_OHEADER
) || (tokenid
== AUT_HEADER32
) ||
107 (tokenid
== AUT_HEADER32_EX
) || (tokenid
== AUT_HEADER64
) ||
108 (tokenid
== AUT_HEADER64_EX
))
115 * -----------------------------------------------------------------------
117 * Tests whether the specified token id represents a true
118 * token, as opposed to a regular tag.
119 * return codes : 1 - tokenid is a true token
121 * -----------------------------------------------------------------------
124 is_token(int tokenid
)
126 if ((tokenid
> 0) && (tokenid
<= MAXTOKEN
))
134 * -----------------------------------------------------------------------
135 * exit_token() : Process information label token and display contents
136 * return codes : -1 - error
138 * NOTE: At the time of call, the label token id has been retrieved
140 * Format of exit token:
141 * exit token id adr_char
142 * -----------------------------------------------------------------------
145 exit_token(pr_context_t
*context
)
151 if ((returnstat
= open_tag(context
, TAG_ERRVAL
)) != 0)
154 if ((returnstat
= pr_adr_int32(context
, (int32_t *)&retval
, 1)) == 0) {
155 if (!(context
->format
& PRF_RAWM
)) {
156 char *emsg
= strerror(retval
);
159 uval
.string_val
= gettext("Unknown errno");
161 uval
.string_val
= gettext(emsg
);
162 uval
.uvaltype
= PRA_STRING
;
164 uval
.uvaltype
= PRA_INT32
;
165 uval
.int32_val
= retval
;
167 returnstat
= pa_print(context
, &uval
, 0);
170 returnstat
= close_tag(context
, TAG_ERRVAL
);
172 return (process_tag(context
, TAG_RETVAL
, returnstat
, 1));
176 * ------------------------------------------------------------------
177 * file_token() : prints out seconds of time and other file name
178 * return codes : -1 - error
179 * : 0 - successful, valid file token fields
180 * At the time of entry, the file token ID has already been retrieved
182 * Format of file token:
183 * file token id adr_char
184 * seconds of time adr_u_int
185 * name of other file adr_string
186 * ------------------------------------------------------------------
189 file_token(pr_context_t
*context
)
193 returnstat
= pa_utime32(context
, 0, 0); /* time from usecs */
195 /* other file name */
196 returnstat
= pa_file_string(context
, returnstat
, 1);
202 file64_token(pr_context_t
*context
)
206 returnstat
= pa_utime64(context
, 0, 0); /* time from usecs */
208 /* other file name */
209 returnstat
= pa_file_string(context
, returnstat
, 1);
215 * -----------------------------------------------------------------------
216 * header_token() : Process record header token and display contents
217 * return codes : -1 - error
219 * : 1 - warning, password entry not found
221 * NOTE: At the time of call, the header token id has been retrieved
223 * Format of header token:
224 * header token id adr_char
225 * record byte count adr_u_int
226 * event type adr_u_short (printed either ASCII or raw)
227 * event class adr_u_int (printed either ASCII or raw)
228 * event action adr_u_int
229 * if extended: extended host name (IPv4/IPv6)
230 * seconds of time adr_u_int (printed either ASCII or raw)
231 * nanoseconds of time adr_u_int
232 * -----------------------------------------------------------------------
235 header_token(pr_context_t
*context
)
239 returnstat
= pa_reclen(context
, 0); /* record byte */
241 returnstat
= process_tag(context
, TAG_TOKVERS
, returnstat
, 0);
243 returnstat
= process_tag(context
, TAG_EVTYPE
, returnstat
, 0);
245 returnstat
= pa_event_modifier(context
, returnstat
, 0);
247 returnstat
= pa_ntime32(context
, returnstat
, 1);
253 header64_token(pr_context_t
*context
)
257 returnstat
= pa_reclen(context
, 0); /* record byte */
259 returnstat
= process_tag(context
, TAG_TOKVERS
, returnstat
, 0);
261 returnstat
= process_tag(context
, TAG_EVTYPE
, returnstat
, 0);
263 returnstat
= pa_event_modifier(context
, returnstat
, 0);
265 returnstat
= pa_ntime64(context
, returnstat
, 1);
271 header32_ex_token(pr_context_t
*context
)
275 returnstat
= pa_reclen(context
, 0); /* record byte */
277 returnstat
= process_tag(context
, TAG_TOKVERS
, returnstat
, 0);
279 returnstat
= process_tag(context
, TAG_EVTYPE
, returnstat
, 0);
281 returnstat
= pa_event_modifier(context
, returnstat
, 0);
283 returnstat
= pa_hostname_ex(context
, returnstat
, 0);
285 returnstat
= pa_ntime32(context
, returnstat
, 1);
291 header64_ex_token(pr_context_t
*context
)
295 returnstat
= pa_reclen(context
, 0); /* record byte */
297 returnstat
= process_tag(context
, TAG_TOKVERS
, returnstat
, 0);
299 returnstat
= process_tag(context
, TAG_EVTYPE
, returnstat
, 0);
301 returnstat
= pa_event_modifier(context
, returnstat
, 0);
303 returnstat
= pa_hostname_ex(context
, returnstat
, 0);
305 returnstat
= pa_ntime64(context
, returnstat
, 1);
311 * -----------------------------------------------------------------------
312 * trailer_token() : Process record trailer token and display contents
313 * return codes : -1 - error
315 * NOTE: At the time of call, the trailer token id has already been
318 * Format of trailer token:
319 * trailer token id adr_char
320 * record sequence no adr_u_short (should be AUT_TRAILER_MAGIC)
321 * record byte count adr_u_int
322 * -----------------------------------------------------------------------
325 trailer_token(pr_context_t
*context
)
329 if (pr_adr_u_short(context
, (ushort_t
*)&magic_number
, 1) < 0) {
330 (void) fprintf(stderr
, gettext(
331 "praudit: Cannot retrieve trailer magic number\n"));
334 if (magic_number
!= AUT_TRAILER_MAGIC
) {
335 (void) fprintf(stderr
, gettext(
336 "praudit: Invalid trailer magic number\n"));
339 /* Do not display trailer in XML mode */
340 if (context
->format
& PRF_XMLM
) {
344 retstat
= pr_adr_u_int32(context
, &junk
, 1);
347 return (pa_adr_u_int32(context
, 0, 1));
353 * -----------------------------------------------------------------------
354 * arbitrary_data_token():
355 * Process arbitrary data token and display contents
356 * return codes : -1 - error
358 * NOTE: At the time of call, the arbitrary data token id has already
361 * Format of arbitrary data token:
362 * arbitrary data token id adr char
363 * how to print adr_char
364 * From audit_record.h, this may be either:
367 * AUP_DECIMAL decimal
368 * AUP_HEX hexadecimal
369 * basic unit adr_char
370 * From audit_record.h, this may be either:
376 * unit count adr_char, specifying number of units of
377 * data in the "data items" parameter below
378 * data items depends on basic unit
380 * -----------------------------------------------------------------------
383 arbitrary_data_token(pr_context_t
*context
)
391 char how_to_print
, basic_unit
, unit_count
, fwid
;
394 char *pformat
= "%*s";
398 if ((returnstat
= pr_adr_char(context
, &how_to_print
, 1)) != 0)
401 if ((returnstat
= pr_adr_char(context
, &basic_unit
, 1)) != 0)
404 if ((returnstat
= pr_adr_char(context
, &unit_count
, 1)) != 0)
407 if (!(context
->format
& PRF_RAWM
)) {
408 uval
.uvaltype
= PRA_STRING
;
409 uval
.string_val
= htp2string(how_to_print
);
411 uval
.uvaltype
= PRA_INT32
;
412 uval
.int32_val
= (int)how_to_print
;
415 if ((returnstat
= open_tag(context
, TAG_ARBPRINT
)) != 0)
417 if ((returnstat
= pa_print(context
, &uval
, 0)) < 0)
419 if ((returnstat
= close_tag(context
, TAG_ARBPRINT
)) != 0)
422 if (!(context
->format
& PRF_RAWM
)) {
423 uval
.uvaltype
= PRA_STRING
;
424 uval
.string_val
= bu2string(basic_unit
);
426 uval
.uvaltype
= PRA_INT32
;
427 uval
.int32_val
= (int32_t)basic_unit
;
430 if ((returnstat
= open_tag(context
, TAG_ARBTYPE
)) != 0)
432 if ((returnstat
= pa_print(context
, &uval
, 0)) < 0)
434 if ((returnstat
= close_tag(context
, TAG_ARBTYPE
)) != 0)
437 uval
.uvaltype
= PRA_INT32
;
438 uval
.int32_val
= (int32_t)unit_count
;
440 if ((returnstat
= open_tag(context
, TAG_ARBCOUNT
)) != 0)
442 if ((returnstat
= pa_print(context
, &uval
, 1)) < 0)
444 if ((returnstat
= close_tag(context
, TAG_ARBCOUNT
)) != 0)
447 /* Done with attributes; force end of token open */
448 if ((returnstat
= finish_open_tag(context
)) != 0)
451 /* get the field width in case we need to format output */
452 fwid
= findfieldwidth(basic_unit
, how_to_print
);
453 p
= (char *)malloc(80);
455 /* now get the data items and print them */
456 for (i
= 0; (i
< unit_count
); i
++) {
457 switch (basic_unit
) {
460 if (pr_adr_char(context
, &c1
, 1) == 0)
461 (void) convert_char_to_string(how_to_print
,
469 if (pr_adr_short(context
, &c2
, 1) == 0)
470 (void) convert_short_to_string(how_to_print
,
478 if (pr_adr_int32(context
, &c3
, 1) == 0)
479 (void) convert_int32_to_string(how_to_print
,
487 if (pr_adr_int64(context
, &c4
, 1) == 0)
488 (void) convert_int64_to_string(how_to_print
,
502 * At this point, we have successfully retrieved a data
503 * item and converted it into an ASCII string pointed to
504 * by p. If all output is to be printed on one line,
505 * simply separate the data items by a space (or by the
506 * delimiter if this is the last data item), otherwise, we
507 * need to format the output before display.
509 if (context
->format
& PRF_ONELINE
) {
510 returnstat
= pr_printf(context
, "%s", p
);
511 if ((returnstat
>= 0) && (i
== (unit_count
- 1)))
512 returnstat
= pr_printf(context
, "%s",
515 returnstat
= pr_putchar(context
, ' ');
516 } else { /* format output */
517 returnstat
= pr_printf(context
, pformat
, fwid
, p
);
519 if ((returnstat
>= 0) &&
520 (((index
+ fwid
) > 75) ||
521 (i
== (unit_count
- 1)))) {
522 returnstat
= pr_putchar(context
, '\n');
525 } /* else if PRF_ONELINE */
526 if (returnstat
< 0) {
537 * -----------------------------------------------------------------------
538 * opaque_token() : Process opaque token and display contents
539 * return codes : -1 - error
541 * NOTE: At the time of call, the opaque token id has already been
544 * Format of opaque token:
545 * opaque token id adr_char
547 * data adr_char, size times
548 * -----------------------------------------------------------------------
551 opaque_token(pr_context_t
*context
)
559 /* print the size of the token */
560 if (pr_adr_short(context
, &size
, 1) == 0) {
561 uval
.uvaltype
= PRA_SHORT
;
562 uval
.short_val
= size
;
563 returnstat
= pa_print(context
, &uval
, 0);
567 /* now print out the data field in hexadecimal */
568 if (returnstat
>= 0) {
569 /* try to allocate memory for the character string */
570 if ((charp
= (char *)malloc(size
* sizeof (char))) == NULL
)
573 if ((returnstat
= pr_adr_char(context
, charp
,
575 /* print out in hexadecimal format */
576 uval
.uvaltype
= PRA_STRING
;
577 uval
.string_val
= hexconvert(charp
, size
, size
);
578 if (uval
.string_val
) {
579 returnstat
= pa_print(context
,
581 free(uval
.string_val
);
592 * -----------------------------------------------------------------------
593 * path_token() : Process path token and display contents
594 * return codes : -1 - error
596 * NOTE: At the time of call, the path token id has been retrieved
598 * Format of path token:
601 * -----------------------------------------------------------------------
604 path_token(pr_context_t
*context
)
606 char *path
; /* path */
607 char *apath
; /* anchored path */
608 char *cpath
; /* collapsed path */
614 * We need to know how much space to allocate for our string, so
615 * read the length first, then call pr_adr_char to read those bytes.
617 if (pr_adr_short(context
, &length
, 1) == 0) {
618 if ((path
= (char *)malloc(length
+ 1)) == NULL
) {
620 } else if (pr_adr_char(context
, path
, length
) == 0) {
622 uval
.uvaltype
= PRA_STRING
;
624 apath
= anchor_path(path
);
628 cpath
= collapse_path(apath
);
629 uval
.string_val
= cpath
;
630 returnstat
= pa_print(context
, &uval
, 1);
642 * anchor a path name with a slash
645 anchor_path(char *sp
)
647 char *dp
; /* destination path */
648 char *tp
; /* temporary path */
651 len
= strlen(sp
) + 2;
652 if ((dp
= tp
= (char *)calloc(1, len
)) == NULL
)
657 (void) strlcpy(dp
, sp
, len
);
663 * copy path to collapsed path.
664 * collapsed path does not contain:
666 * instances of dot-slash
667 * instances of dot-dot-slash
668 * passed path must be anchored with a '/'
671 collapse_path(char *s
)
673 int id
; /* index of where we are in destination string */
674 int is
; /* index of where we are in source string */
675 int slashseen
; /* have we seen a slash */
676 int ls
; /* length of source string */
681 for (is
= 0, id
= 0; is
< ls
; is
++) {
682 /* thats all folks, we've reached the end of input */
684 if (id
> 1 && s
[id
-1] == '/') {
690 /* previous character was a / */
693 continue; /* another slash, ignore it */
694 } else if (s
[is
] == '/') {
695 /* we see a /, just copy it and try again */
701 if (s
[is
] == '.' && s
[is
+1] == '/') {
706 if (s
[is
] == '.' && s
[is
+1] == '\0') {
712 if (s
[is
] == '.' && s
[is
+1] == '.' && s
[is
+2] == '\0') {
716 while (id
> 0 && s
[--id
] != '/')
722 if (s
[is
] == '.' && s
[is
+1] == '.' && s
[is
+2] == '/') {
726 while (id
> 0 && s
[--id
] != '/')
731 while (is
< ls
&& (s
[id
++] = s
[is
++]) != '/')
739 * -----------------------------------------------------------------------
740 * cmd_token() : Process cmd token and display contents
741 * return codes : -1 - error
743 * NOTE: At the time of call, the cmd token id has been retrieved
745 * Format of command token:
748 * N*argv[i] adr_string (short, string)
750 * N*arge[i] adr_string (short, string)
751 * -----------------------------------------------------------------------
754 cmd_token(pr_context_t
*context
)
759 returnstat
= pr_adr_short(context
, &num
, 1);
763 if (!(context
->format
& PRF_XMLM
)) {
764 returnstat
= pr_printf(context
, "%s%s%d%s",
765 (context
->format
& PRF_ONELINE
) ? "" : gettext("argcnt"),
766 (context
->format
& PRF_ONELINE
) ? "" : context
->SEPARATOR
,
767 num
, context
->SEPARATOR
);
772 for (; num
> 0; num
--) {
773 if ((returnstat
= process_tag(context
, TAG_ARGV
,
778 if ((returnstat
= pr_adr_short(context
, &num
, 1)) < 0)
781 if (!(context
->format
& PRF_XMLM
)) {
782 returnstat
= pr_printf(context
, "%s%s%d%s",
783 (context
->format
& PRF_ONELINE
) ? "" : gettext("envcnt"),
784 (context
->format
& PRF_ONELINE
) ? "" : context
->SEPARATOR
,
785 num
, context
->SEPARATOR
);
790 if ((num
== 0) && !(context
->format
& PRF_XMLM
)) {
791 returnstat
= do_newline(context
, 1);
796 for (; num
> 1; num
--) {
797 if ((returnstat
= process_tag(context
, TAG_ARGE
,
802 returnstat
= process_tag(context
, TAG_ARGE
, returnstat
, 1);
809 * -----------------------------------------------------------------------
810 * argument32_token() : Process argument token and display contents
811 * return codes : -1 - error
813 * NOTE: At the time of call, the arg token id has been retrieved
815 * Format of argument token:
816 * current directory token id adr_char
817 * argument number adr_char
818 * argument value adr_int32
819 * argument description adr_string
820 * -----------------------------------------------------------------------
823 argument32_token(pr_context_t
*context
)
827 returnstat
= process_tag(context
, TAG_ARGNUM
, 0, 0);
828 returnstat
= process_tag(context
, TAG_ARGVAL32
, returnstat
, 0);
829 returnstat
= process_tag(context
, TAG_ARGDESC
, returnstat
, 1);
836 * -----------------------------------------------------------------------
837 * argument64_token() : Process argument token and display contents
838 * return codes : -1 - error
840 * NOTE: At the time of call, the arg token id has been retrieved
842 * Format of 64 bit argument token:
843 * current directory token id adr_char
844 * argument number adr_char
845 * argument value adr_int64
846 * argument description adr_string
847 * -----------------------------------------------------------------------
850 argument64_token(pr_context_t
*context
)
854 returnstat
= process_tag(context
, TAG_ARGNUM
, 0, 0);
855 returnstat
= process_tag(context
, TAG_ARGVAL64
, returnstat
, 0);
856 returnstat
= process_tag(context
, TAG_ARGDESC
, returnstat
, 1);
863 * -----------------------------------------------------------------------
864 * process_token() : Process process token and display contents
865 * return codes : -1 - error
867 * NOTE: At the time of call, the process token id has been retrieved
869 * Format of process token:
870 * process token id adr_char
878 * tid adr_u_int32, adr_u_int32
879 * -----------------------------------------------------------------------
882 process32_token(pr_context_t
*context
)
887 returnstat
= process_tag(context
, TAG_AUID
, 0, 0);
889 returnstat
= process_tag(context
, TAG_UID
, returnstat
, 0);
891 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
893 returnstat
= process_tag(context
, TAG_RUID
, returnstat
, 0);
895 returnstat
= process_tag(context
, TAG_RGID
, returnstat
, 0);
897 returnstat
= process_tag(context
, TAG_PID
, returnstat
, 0);
899 returnstat
= process_tag(context
, TAG_SID
, returnstat
, 0);
901 returnstat
= process_tag(context
, TAG_TID32
, returnstat
, 1);
907 process64_token(pr_context_t
*context
)
912 returnstat
= process_tag(context
, TAG_AUID
, 0, 0);
914 returnstat
= process_tag(context
, TAG_UID
, returnstat
, 0);
916 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
918 returnstat
= process_tag(context
, TAG_RUID
, returnstat
, 0);
920 returnstat
= process_tag(context
, TAG_RGID
, returnstat
, 0);
922 returnstat
= process_tag(context
, TAG_PID
, returnstat
, 0);
924 returnstat
= process_tag(context
, TAG_SID
, returnstat
, 0);
926 returnstat
= process_tag(context
, TAG_TID64
, returnstat
, 1);
932 * -----------------------------------------------------------------------
933 * process_ex_token() : Process process token and display contents
934 * return codes : -1 - error
936 * NOTE: At the time of call, the process token id has been retrieved
938 * Format of extended process token:
939 * process token id adr_char
947 * tid adr_u_int32, adr_u_int32, 4*adr_u_int32
948 * -----------------------------------------------------------------------
951 process32_ex_token(pr_context_t
*context
)
956 returnstat
= process_tag(context
, TAG_AUID
, 0, 0);
958 returnstat
= process_tag(context
, TAG_UID
, returnstat
, 0);
960 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
962 returnstat
= process_tag(context
, TAG_RUID
, returnstat
, 0);
964 returnstat
= process_tag(context
, TAG_RGID
, returnstat
, 0);
966 returnstat
= process_tag(context
, TAG_PID
, returnstat
, 0);
968 returnstat
= process_tag(context
, TAG_SID
, returnstat
, 0);
970 returnstat
= process_tag(context
, TAG_TID32_EX
, returnstat
, 1);
976 process64_ex_token(pr_context_t
*context
)
981 returnstat
= process_tag(context
, TAG_AUID
, 0, 0);
983 returnstat
= process_tag(context
, TAG_UID
, returnstat
, 0);
985 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
987 returnstat
= process_tag(context
, TAG_RUID
, returnstat
, 0);
989 returnstat
= process_tag(context
, TAG_RGID
, returnstat
, 0);
991 returnstat
= process_tag(context
, TAG_PID
, returnstat
, 0);
993 returnstat
= process_tag(context
, TAG_SID
, returnstat
, 0);
995 returnstat
= process_tag(context
, TAG_TID64_EX
, returnstat
, 1);
1001 * -----------------------------------------------------------------------
1002 * return_value32_token(): Process return value and display contents
1003 * return codes : -1 - error
1005 * NOTE: At the time of call, the return value token id has been retrieved
1007 * Format of return value token:
1008 * return value token id adr_char
1009 * error number adr_char
1010 * return value adr_int32
1011 * -----------------------------------------------------------------------
1014 return_value32_token(pr_context_t
*context
)
1019 char pb
[512]; /* print buffer */
1021 bool_t used_ret_val
= 0;
1024 * Every audit record generated contains a return token.
1026 * The return token is a special token. It indicates the success
1027 * or failure of the event that contains it.
1028 * The return32 token contains two pieces of data:
1031 * int32_t return_value;
1033 * For audit records generated by the kernel:
1034 * The kernel always puts a positive value in "number".
1035 * Upon success "number" is 0.
1036 * Upon failure "number" is a positive errno value that is less than
1039 * For audit records generated at the user level:
1040 * Upon success "number" is 0.
1041 * Upon failure "number" is -1.
1043 * For both kernel and user land the value of "return_value" is
1044 * arbitrary. For the kernel it contains the return value of
1045 * the system call. For user land it contains an arbitrary return
1046 * value if it is less than ADT_FAIL_VALUE; ADT_FAIL_VALUE
1047 * and above are messages defined in adt_event.h. ADT_FAIL_PAM and
1048 * above are messages from pam_strerror(). No interpretation is done
1049 * on "return_value" if it is outside the range of ADT_FAIL_VALUE_* or
1050 * ADT_FAIL_PAM values.
1052 if ((returnstat
= open_tag(context
, TAG_ERRVAL
)) != 0)
1053 return (returnstat
);
1055 if ((returnstat
= pr_adr_u_char(context
, &number
, 1)) == 0) {
1056 if (!(context
->format
& PRF_RAWM
)) {
1058 pa_error(number
, pb
, sizeof (pb
));
1059 uval
.uvaltype
= PRA_STRING
;
1060 uval
.string_val
= pb
;
1061 if ((returnstat
= pa_print(context
, &uval
, 0)) != 0)
1062 return (returnstat
);
1063 if ((returnstat
= close_tag(context
, TAG_ERRVAL
)) != 0)
1064 return (returnstat
);
1065 if ((returnstat
= open_tag(context
, TAG_RETVAL
)) != 0)
1066 return (returnstat
);
1068 if ((returnstat
= pr_adr_int32(
1069 context
, &value
, 1)) != 0)
1070 return (returnstat
);
1072 pa_retval(number
, value
, pb
, sizeof (pb
));
1074 uval
.uvaltype
= PRA_INT32
;
1075 if ((char)number
== -1)
1076 uval
.int32_val
= -1;
1078 uval
.int32_val
= number
;
1080 returnstat
= pa_print(context
, &uval
, used_ret_val
);
1083 if (returnstat
== 0)
1084 returnstat
= close_tag(context
, TAG_RETVAL
);
1085 return (returnstat
);
1088 if (returnstat
= close_tag(context
, TAG_ERRVAL
))
1089 return (returnstat
);
1091 return (process_tag(context
, TAG_RETVAL
, returnstat
, 1));
1095 * -----------------------------------------------------------------------
1096 * return_value64_token(): Process return value and display contents
1097 * return codes : -1 - error
1099 * NOTE: At the time of call, the return value token id has been retrieved
1101 * Format of return value token:
1102 * return value token id adr_char
1103 * error number adr_char
1104 * return value adr_int64
1106 * HOWEVER, the 64 bit return value is a concatenation of two
1107 * 32 bit return values; the first of which is the same as is
1108 * carried in the return32 token. The second 32 bits are ignored
1109 * here so that the displayed return token will have the same
1110 * number whether the application is 32 or 64 bits.
1111 * -----------------------------------------------------------------------
1114 return_value64_token(pr_context_t
*context
)
1119 char pb
[512]; /* print buffer */
1123 * Every audit record generated contains a return token.
1125 * The return token is a special token. It indicates the success
1126 * or failure of the event that contains it.
1127 * The return64 token contains two pieces of data:
1130 * int64_t return_value;
1132 * For audit records generated by the kernel:
1133 * The kernel always puts a positive value in "number".
1134 * Upon success "number" is 0.
1135 * Upon failure "number" is a positive errno value that is less than
1138 * For audit records generated at the user level:
1139 * Upon success "number" is 0.
1140 * Upon failure "number" is -1.
1142 * For both kernel and user land the value of "return_value" is
1143 * arbitrary. For the kernel it contains the return value of
1144 * the system call. For user land it contains an arbitrary return
1145 * value if it is less than ADT_FAIL_VALUE; ADT_FAIL_VALUE
1146 * and above are messages defined in adt_event.h. ADT_FAIL_PAM and
1147 * above are messages from pam_strerror(). No interpretation is done
1148 * on "return_value" if it is outside the range of ADT_FAIL_VALUE_* or
1149 * ADT_FAIL_PAM values.
1151 * The 64 bit return value consists of two 32bit parts; for
1152 * system calls, the first part is the value returned by the
1153 * system call and the second part depends on the system call
1154 * implementation. In most cases, the second part is either 0
1155 * or garbage; because of that, it is omitted from the praudit
1158 if ((returnstat
= open_tag(context
, TAG_ERRVAL
)) != 0)
1159 return (returnstat
);
1161 if ((returnstat
= pr_adr_u_char(context
, &number
, 1)) == 0) {
1162 if (!(context
->format
& PRF_RAWM
)) {
1163 pa_error(number
, pb
, sizeof (pb
));
1164 uval
.uvaltype
= PRA_STRING
;
1165 uval
.string_val
= pb
;
1166 if ((returnstat
= pa_print(context
, &uval
, 0)) != 0)
1167 return (returnstat
);
1169 if ((returnstat
= close_tag(context
, TAG_ERRVAL
)) != 0)
1170 return (returnstat
);
1171 if ((returnstat
= open_tag(context
, TAG_RETVAL
)) != 0)
1172 return (returnstat
);
1174 if ((returnstat
= pr_adr_int64(context
,
1175 &rval
.r_vals
, 1)) != 0)
1176 return (returnstat
);
1177 pa_retval(number
, rval
.r_val1
, pb
, sizeof (pb
));
1179 uval
.uvaltype
= PRA_INT32
;
1180 if ((char)number
== -1)
1181 uval
.int32_val
= -1;
1183 uval
.int32_val
= number
;
1185 if ((returnstat
= pa_print(context
, &uval
, 0)) != 0)
1186 return (returnstat
);
1188 if ((returnstat
= close_tag(context
, TAG_ERRVAL
)) != 0)
1189 return (returnstat
);
1190 if ((returnstat
= open_tag(context
, TAG_RETVAL
)) != 0)
1191 return (returnstat
);
1193 if ((returnstat
= pr_adr_int64(context
,
1194 &rval
.r_vals
, 1)) != 0)
1195 return (returnstat
);
1196 uval
.int32_val
= rval
.r_val1
;
1198 returnstat
= pa_print(context
, &uval
, 1);
1200 return (returnstat
);
1203 if (returnstat
== 0)
1204 returnstat
= close_tag(context
, TAG_RETVAL
);
1206 return (returnstat
);
1210 * -----------------------------------------------------------------------
1211 * subject32_token() : Process subject token and display contents
1212 * return codes : -1 - error
1214 * NOTE: At the time of call, the subject token id has been retrieved
1216 * Format of subject token:
1217 * subject token id adr_char
1225 * tid adr_u_int32, adr_u_int32
1226 * -----------------------------------------------------------------------
1229 subject32_token(pr_context_t
*context
)
1234 returnstat
= process_tag(context
, TAG_AUID
, 0, 0);
1236 returnstat
= process_tag(context
, TAG_UID
, returnstat
, 0);
1238 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
1240 returnstat
= process_tag(context
, TAG_RUID
, returnstat
, 0);
1242 returnstat
= process_tag(context
, TAG_RGID
, returnstat
, 0);
1244 returnstat
= process_tag(context
, TAG_PID
, returnstat
, 0);
1246 returnstat
= process_tag(context
, TAG_SID
, returnstat
, 0);
1248 returnstat
= process_tag(context
, TAG_TID32
, returnstat
, 1);
1250 return (returnstat
);
1254 subject64_token(pr_context_t
*context
)
1259 returnstat
= process_tag(context
, TAG_AUID
, 0, 0);
1261 returnstat
= process_tag(context
, TAG_UID
, returnstat
, 0);
1263 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
1265 returnstat
= process_tag(context
, TAG_RUID
, returnstat
, 0);
1267 returnstat
= process_tag(context
, TAG_RGID
, returnstat
, 0);
1269 returnstat
= process_tag(context
, TAG_PID
, returnstat
, 0);
1271 returnstat
= process_tag(context
, TAG_SID
, returnstat
, 0);
1273 returnstat
= process_tag(context
, TAG_TID64
, returnstat
, 1);
1275 return (returnstat
);
1279 * -----------------------------------------------------------------------
1280 * subject_ex_token(): Process subject token and display contents
1281 * return codes : -1 - error
1283 * NOTE: At the time of call, the subject token id has been retrieved
1285 * Format of extended subject token:
1286 * subject token id adr_char
1294 * tid adr_u_int32, adr_u_int32
1295 * -----------------------------------------------------------------------
1298 subject32_ex_token(pr_context_t
*context
)
1303 returnstat
= process_tag(context
, TAG_AUID
, 0, 0);
1305 returnstat
= process_tag(context
, TAG_UID
, returnstat
, 0);
1307 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
1309 returnstat
= process_tag(context
, TAG_RUID
, returnstat
, 0);
1311 returnstat
= process_tag(context
, TAG_RGID
, returnstat
, 0);
1313 returnstat
= process_tag(context
, TAG_PID
, returnstat
, 0);
1315 returnstat
= process_tag(context
, TAG_SID
, returnstat
, 0);
1317 returnstat
= process_tag(context
, TAG_TID32_EX
, returnstat
, 1);
1319 return (returnstat
);
1323 subject64_ex_token(pr_context_t
*context
)
1328 returnstat
= process_tag(context
, TAG_AUID
, 0, 0);
1330 returnstat
= process_tag(context
, TAG_UID
, returnstat
, 0);
1332 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
1334 returnstat
= process_tag(context
, TAG_RUID
, returnstat
, 0);
1336 returnstat
= process_tag(context
, TAG_RGID
, returnstat
, 0);
1338 returnstat
= process_tag(context
, TAG_PID
, returnstat
, 0);
1340 returnstat
= process_tag(context
, TAG_SID
, returnstat
, 0);
1342 returnstat
= process_tag(context
, TAG_TID64_EX
, returnstat
, 1);
1344 return (returnstat
);
1348 * -----------------------------------------------------------------------
1349 * s5_IPC_token() : Process System V IPC token and display contents
1350 * return codes : -1 - error
1352 * NOTE: At the time of call, the System V IPC id has been retrieved
1354 * Format of System V IPC token:
1355 * System V IPC token id adr_char
1356 * object id adr_int32
1357 * -----------------------------------------------------------------------
1360 s5_IPC_token(pr_context_t
*context
)
1368 * These names refer to the type of System V IPC object:
1369 * message queue, semaphore, shared memory.
1372 if (pr_adr_u_char(context
, &ipctype
, 1) == 0) {
1373 if ((returnstat
= open_tag(context
, TAG_IPCTYPE
)) != 0)
1374 return (returnstat
);
1376 if (!(context
->format
& PRF_RAWM
)) {
1377 /* print in ASCII form */
1378 uval
.uvaltype
= PRA_STRING
;
1381 uval
.string_val
= gettext("msg");
1384 uval
.string_val
= gettext("sem");
1387 uval
.string_val
= gettext("shm");
1390 returnstat
= pa_print(context
, &uval
, 0);
1392 /* print in integer form */
1393 if ((context
->format
& PRF_RAWM
) || (returnstat
== 1)) {
1394 uval
.uvaltype
= PRA_BYTE
;
1395 uval
.char_val
= ipctype
;
1396 returnstat
= pa_print(context
, &uval
, 0);
1398 if ((returnstat
= close_tag(context
, TAG_IPCTYPE
)) != 0)
1399 return (returnstat
);
1401 /* next get and print ipc id */
1402 return (process_tag(context
, TAG_IPCID
, returnstat
, 1));
1404 /* cannot retrieve ipc type */
1410 * -----------------------------------------------------------------------
1411 * text_token() : Process text token and display contents
1412 * return codes : -1 - error
1414 * NOTE: At the time of call, the text token id has been retrieved
1416 * Format of text token:
1417 * text token id adr_char
1419 * -----------------------------------------------------------------------
1422 text_token(pr_context_t
*context
)
1424 return (pa_adr_string(context
, 0, 1));
1428 * -----------------------------------------------------------------------
1429 * tid_token() : Process a generic terminal id token / AUT_TID
1430 * return codes : -1 - error
1432 * NOTE: At the time of call, the token id has been retrieved
1434 * Format of tid token:
1435 * ip token id adr_char
1436 * terminal type adr_char
1437 * terminal type = AU_IPADR:
1438 * remote port: adr_short
1439 * local port: adr_short
1440 * IP type: adt_int32 -- AU_IPv4 or AU_IPv6
1441 * address: adr_int32 if IPv4, else 4 * adr_int32
1442 * -----------------------------------------------------------------------
1445 tid_token(pr_context_t
*context
)
1451 if ((returnstat
= pr_adr_u_char(context
, &type
, 1)) != 0)
1452 return (returnstat
);
1453 uval
.uvaltype
= PRA_STRING
;
1454 if ((returnstat
= open_tag(context
, TAG_TID_TYPE
)) != 0)
1455 return (returnstat
);
1459 return (-1); /* other than IP type is not implemented */
1461 uval
.string_val
= "ip";
1462 returnstat
= pa_print(context
, &uval
, 0);
1463 returnstat
= close_tag(context
, TAG_TID_TYPE
);
1464 returnstat
= open_tag(context
, TAG_IP
);
1465 returnstat
= process_tag(context
, TAG_IP_REMOTE
, returnstat
, 0);
1466 returnstat
= process_tag(context
, TAG_IP_LOCAL
, returnstat
, 0);
1467 returnstat
= process_tag(context
, TAG_IP_ADR
, returnstat
, 1);
1468 returnstat
= close_tag(context
, TAG_IP
);
1471 return (returnstat
);
1475 * -----------------------------------------------------------------------
1476 * ip_addr_token() : Process ip token and display contents
1477 * return codes : -1 - error
1479 * NOTE: At the time of call, the ip token id has been retrieved
1481 * Format of ip address token:
1482 * ip token id adr_char
1483 * address adr_int32 (printed in hex)
1484 * -----------------------------------------------------------------------
1488 ip_addr_token(pr_context_t
*context
)
1490 return (pa_hostname(context
, 0, 1));
1494 ip_addr_ex_token(pr_context_t
*context
)
1497 uint32_t ip_addr
[16];
1504 /* get address type */
1505 if ((returnstat
= pr_adr_u_int32(context
, &ip_type
, 1)) != 0)
1506 return (returnstat
);
1508 /* legal address types are either AU_IPv4 or AU_IPv6 only */
1509 if ((ip_type
!= AU_IPv4
) && (ip_type
!= AU_IPv6
))
1512 /* get address (4/16) */
1513 if ((returnstat
= pr_adr_char(context
, (char *)ip_addr
, ip_type
)) != 0)
1514 return (returnstat
);
1516 uval
.uvaltype
= PRA_STRING
;
1517 if (ip_type
== AU_IPv4
) {
1518 uval
.string_val
= buf
;
1520 if (!(context
->format
& PRF_RAWM
)) {
1521 get_Hname(ip_addr
[0], buf
, sizeof (buf
));
1522 return (pa_print(context
, &uval
, 1));
1525 ia
.s_addr
= ip_addr
[0];
1526 if ((ipstring
= inet_ntoa(ia
)) == NULL
)
1529 (void) snprintf(buf
, sizeof (buf
), "%s", ipstring
);
1532 uval
.string_val
= buf
;
1534 if (!(context
->format
& PRF_RAWM
)) {
1535 get_Hname_ex(ip_addr
, buf
, sizeof (buf
));
1536 return (pa_print(context
, &uval
, 1));
1539 (void) inet_ntop(AF_INET6
, (void *) ip_addr
, buf
,
1544 return (pa_print(context
, &uval
, 1));
1548 * -----------------------------------------------------------------------
1549 * ip_token() : Process ip header token and display contents
1550 * return codes : -1 - error
1552 * NOTE: At the time of call, the ip token id has been retrieved
1554 * Format of ip header token:
1555 * ip header token id adr_char
1556 * version adr_char (printed in hex)
1557 * type of service adr_char (printed in hex)
1560 * offset adr_u_short
1561 * ttl adr_char (printed in hex)
1562 * protocol adr_char (printed in hex)
1563 * checksum adr_u_short
1564 * source address adr_int32 (printed in hex)
1565 * destination address adr_int32 (printed in hex)
1566 * -----------------------------------------------------------------------
1569 ip_token(pr_context_t
*context
)
1573 returnstat
= process_tag(context
, TAG_IPVERS
, 0, 0);
1574 returnstat
= process_tag(context
, TAG_IPSERV
, returnstat
, 0);
1575 returnstat
= process_tag(context
, TAG_IPLEN
, returnstat
, 0);
1576 returnstat
= process_tag(context
, TAG_IPID
, returnstat
, 0);
1577 returnstat
= process_tag(context
, TAG_IPOFFS
, returnstat
, 0);
1578 returnstat
= process_tag(context
, TAG_IPTTL
, returnstat
, 0);
1579 returnstat
= process_tag(context
, TAG_IPPROTO
, returnstat
, 0);
1580 returnstat
= process_tag(context
, TAG_IPCKSUM
, returnstat
, 0);
1581 returnstat
= process_tag(context
, TAG_IPSRC
, returnstat
, 0);
1582 returnstat
= process_tag(context
, TAG_IPDEST
, returnstat
, 1);
1584 return (returnstat
);
1588 * -----------------------------------------------------------------------
1589 * iport_token() : Process ip port address token and display contents
1590 * return codes : -1 - error
1592 * NOTE: At time of call, the ip port address token id has been retrieved
1594 * Format of ip port token:
1595 * ip port address token id adr_char
1596 * port address adr_short (in_port_t == uint16_t)
1597 * -----------------------------------------------------------------------
1600 iport_token(pr_context_t
*context
)
1602 return (pa_adr_u_short(context
, 0, 1));
1606 * -----------------------------------------------------------------------
1607 * socket_token() : Process socket token and display contents
1608 * return codes : -1 - error
1610 * NOTE: At time of call, the socket token id has been retrieved
1612 * Format of socket token:
1613 * ip socket token id adr_char
1614 * socket type adr_short (in hex)
1615 * foreign port adr_short (in hex)
1616 * foreign internet address adr_hostname/adr_int32 (in ascii/hex)
1617 * -----------------------------------------------------------------------
1619 * Note: local port and local internet address have been removed for 5.x
1622 socket_token(pr_context_t
*context
)
1626 returnstat
= process_tag(context
, TAG_SOCKTYPE
, 0, 0);
1627 returnstat
= process_tag(context
, TAG_SOCKPORT
, returnstat
, 0);
1628 if (returnstat
!= 0)
1629 return (returnstat
);
1631 if ((returnstat
= open_tag(context
, TAG_SOCKADDR
)) != 0)
1632 return (returnstat
);
1634 if ((returnstat
= pa_hostname(context
, returnstat
, 1)) != 0)
1635 return (returnstat
);
1637 return (close_tag(context
, TAG_SOCKADDR
));
1641 * -----------------------------------------------------------------------
1642 * socket_ex_token() : Process socket token and display contents
1643 * return codes : -1 - error
1645 * NOTE: At time of call, the extended socket token id has been retrieved
1647 * Format of extended socket token:
1649 * socket domain adr_short (in hex)
1650 * socket type adr_short (in hex)
1651 * IP address type adr_short (in hex) [not displayed]
1652 * local port adr_short (in hex)
1653 * local internet address adr_hostname/adr_int32 (in ascii/hex)
1654 * foreign port adr_short (in hex)
1655 * foreign internet address adr_hostname/adr_int32 (in ascii/hex)
1656 * -----------------------------------------------------------------------
1658 * Note: local port and local internet address have been removed for 5.x
1661 socket_ex_token(pr_context_t
*context
)
1665 returnstat
= process_tag(context
, TAG_SOCKEXDOM
, 0, 0);
1666 returnstat
= process_tag(context
, TAG_SOCKEXTYPE
, returnstat
, 0);
1667 returnstat
= pa_hostname_so(context
, returnstat
, 1);
1669 return (returnstat
);
1673 * -----------------------------------------------------------------------
1674 * sequence_token() : Process sequence token and display contents
1675 * return codes : -1 - error
1677 * NOTE: At time of call, the socket token id has been retrieved
1679 * Format of sequence token:
1680 * sequence token id adr_char
1681 * sequence number adr_u_int32 (in hex)
1682 * -----------------------------------------------------------------------
1685 sequence_token(pr_context_t
*context
)
1687 return (process_tag(context
, TAG_SEQNUM
, 0, 1));
1691 * -----------------------------------------------------------------------
1692 * acl_token() : Process access control list term
1693 * return codes : -1 - error
1696 * Format of acl token:
1698 * term type adr_u_int32
1699 * term value adr_u_int32 (depends on type)
1700 * file mode adr_u_int (in octal)
1701 * -----------------------------------------------------------------------
1704 acl_token(pr_context_t
*context
)
1708 returnstat
= pa_pw_uid_gr_gid(context
, 0, 0);
1710 return (process_tag(context
, TAG_MODE
, returnstat
, 1));
1714 * -----------------------------------------------------------------------
1715 * ace_token() : Process ZFS/NFSv4 access control list term
1716 * return codes : -1 - error
1719 * Format of ace token:
1721 * term who adr_u_int32 (uid/gid)
1722 * term mask adr_u_int32
1723 * term flags adr_u_int16
1724 * term type adr_u_int16
1725 * -----------------------------------------------------------------------
1728 ace_token(pr_context_t
*context
)
1730 return (pa_ace(context
, 0, 1));
1734 * -----------------------------------------------------------------------
1735 * attribute_token() : Process attribute token and display contents
1736 * return codes : -1 - error
1738 * NOTE: At the time of call, the attribute token id has been retrieved
1740 * Format of attribute token:
1741 * attribute token id adr_char
1742 * mode adr_u_int (printed in octal)
1745 * file system id adr_int
1747 * node id adr_int (attribute_token
1751 * node id adr_int64 (attribute32_token)
1754 * node id adr_int64 (attribute64_token)
1755 * device adr_u_int64
1756 * -----------------------------------------------------------------------
1759 attribute_token(pr_context_t
*context
)
1763 returnstat
= process_tag(context
, TAG_MODE
, 0, 0);
1764 returnstat
= process_tag(context
, TAG_UID
, returnstat
, 0);
1765 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
1766 returnstat
= process_tag(context
, TAG_FSID
, returnstat
, 0);
1767 returnstat
= process_tag(context
, TAG_NODEID32
, returnstat
, 0);
1768 returnstat
= process_tag(context
, TAG_DEVICE32
, returnstat
, 1);
1770 return (returnstat
);
1774 attribute32_token(pr_context_t
*context
)
1778 returnstat
= process_tag(context
, TAG_MODE
, 0, 0);
1779 returnstat
= process_tag(context
, TAG_UID
, returnstat
, 0);
1780 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
1781 returnstat
= process_tag(context
, TAG_FSID
, returnstat
, 0);
1782 returnstat
= process_tag(context
, TAG_NODEID64
, returnstat
, 0);
1783 returnstat
= process_tag(context
, TAG_DEVICE32
, returnstat
, 1);
1785 return (returnstat
);
1789 attribute64_token(pr_context_t
*context
)
1793 returnstat
= process_tag(context
, TAG_MODE
, 0, 0);
1794 returnstat
= process_tag(context
, TAG_UID
, returnstat
, 0);
1795 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
1796 returnstat
= process_tag(context
, TAG_FSID
, returnstat
, 0);
1797 returnstat
= process_tag(context
, TAG_NODEID64
, returnstat
, 0);
1798 returnstat
= process_tag(context
, TAG_DEVICE64
, returnstat
, 1);
1800 return (returnstat
);
1804 * -----------------------------------------------------------------------
1805 * group_token() : Process group token and display contents
1806 * return codes : -1 - error
1808 * NOTE: At the time of call, the group token id has been retrieved
1809 * NOTE: This token is obsolete; it supports exactly NGROUPS_MAX
1812 * Format of group token:
1813 * group token id adr_char
1814 * group list adr_long, 16 times
1815 * -----------------------------------------------------------------------
1818 group_token(pr_context_t
*context
)
1823 for (i
= 0; i
< NGROUPS_MAX
- 1; i
++) {
1824 if ((returnstat
= process_tag(context
, TAG_GROUPID
,
1825 returnstat
, 0)) < 0)
1826 return (returnstat
);
1829 return (process_tag(context
, TAG_GROUPID
, returnstat
, 1));
1833 * -----------------------------------------------------------------------
1834 * newgroup_token() : Process group token and display contents
1835 * return codes : -1 - error
1837 * NOTE: At the time of call, the group token id has been retrieved
1839 * Format of new group token:
1840 * group token id adr_char
1841 * group number adr_short
1842 * group list adr_int32, group number times
1843 * -----------------------------------------------------------------------
1846 newgroup_token(pr_context_t
*context
)
1852 returnstat
= pr_adr_short(context
, &n_groups
, 1);
1853 if (returnstat
!= 0)
1854 return (returnstat
);
1856 num
= (int)n_groups
;
1858 if (!(context
->format
& PRF_XMLM
)) {
1859 returnstat
= do_newline(context
, 1);
1861 return (returnstat
);
1863 for (i
= 0; i
< num
- 1; i
++) {
1864 if ((returnstat
= process_tag(context
, TAG_GROUPID
,
1865 returnstat
, 0)) < 0)
1866 return (returnstat
);
1869 return (process_tag(context
, TAG_GROUPID
, returnstat
, 1));
1873 string_token_common(pr_context_t
*context
, int tag
)
1878 returnstat
= pr_adr_int32(context
, (int32_t *)&num
, 1);
1879 if (returnstat
!= 0)
1880 return (returnstat
);
1882 if (!(context
->format
& PRF_XMLM
)) {
1883 returnstat
= pr_printf(context
, "%d%s", num
,
1884 context
->SEPARATOR
);
1885 if (returnstat
!= 0)
1886 return (returnstat
);
1890 return (do_newline(context
, 1));
1892 for (; num
> 1; num
--) {
1893 if ((returnstat
= (process_tag(context
, tag
,
1894 returnstat
, 0))) < 0)
1895 return (returnstat
);
1898 return (process_tag(context
, tag
, returnstat
, 1));
1902 path_attr_token(pr_context_t
*context
)
1904 return (string_token_common(context
, TAG_XAT
));
1908 exec_args_token(pr_context_t
*context
)
1910 return (string_token_common(context
, TAG_ARG
));
1914 exec_env_token(pr_context_t
*context
)
1916 return (string_token_common(context
, TAG_ENV
));
1920 * -----------------------------------------------------------------------
1921 * s5_IPC_perm_token() : Process System V IPC permission token and display
1923 * return codes : -1 - error
1925 * NOTE: At the time of call, the System V IPC permission token id
1926 * has been retrieved
1928 * Format of System V IPC permission token:
1929 * System V IPC permission token id adr_char
1937 * -----------------------------------------------------------------------
1940 s5_IPC_perm_token(pr_context_t
*context
)
1944 returnstat
= process_tag(context
, TAG_UID
, 0, 0);
1945 returnstat
= process_tag(context
, TAG_GID
, returnstat
, 0);
1946 returnstat
= process_tag(context
, TAG_CUID
, returnstat
, 0);
1947 returnstat
= process_tag(context
, TAG_CGID
, returnstat
, 0);
1948 returnstat
= process_tag(context
, TAG_MODE
, returnstat
, 0);
1949 returnstat
= process_tag(context
, TAG_SEQ
, returnstat
, 0);
1950 returnstat
= process_tag(context
, TAG_KEY
, returnstat
, 1);
1952 return (returnstat
);
1956 * -----------------------------------------------------------------------
1957 * host_token() : Process host token and display contents
1958 * return codes : -1 - error
1960 * NOTE: At the time of call, the host token id has been retrieved
1962 * Format of host token:
1963 * host token id adr_char
1964 * hostid adr_u_int32
1965 * -----------------------------------------------------------------------
1968 host_token(pr_context_t
*context
)
1970 return (pa_hostname(context
, 0, 1));
1974 * -----------------------------------------------------------------------
1975 * liaison_token() : Process liaison token and display contents
1976 * return codes : -1 - error
1978 * NOTE: At the time of call, the liaison token id has been retrieved
1980 * Format of liaison token:
1981 * liaison token id adr_char
1982 * liaison adr_u_int32
1983 * -----------------------------------------------------------------------
1986 liaison_token(pr_context_t
*context
)
1988 return (pa_liaison(context
, 0, 1));
1992 * -----------------------------------------------------------------------
1993 * useofauth_token(): Process useofauth token and display contents
1994 * return codes : -1 - error
1996 * NOTE: At the time of call, the uauth token id has been retrieved
1998 * Format of useofauth token:
1999 * uauth token id adr_char
2001 * -----------------------------------------------------------------------
2004 useofauth_token(pr_context_t
*context
)
2006 return (pa_adr_string(context
, 0, 1));
2010 * -----------------------------------------------------------------------
2011 * user_token(): Process user token and display contents
2012 * return codes : -1 - error
2014 * NOTE: At the time of call, the user token id has been retrieved
2016 * Format of user token:
2017 * user token id adr_char
2019 * user name adr_string
2020 * -----------------------------------------------------------------------
2023 user_token(pr_context_t
*context
)
2027 returnstat
= process_tag(context
, TAG_UID
, 0, 0);
2028 return (process_tag(context
, TAG_USERNAME
, returnstat
, 1));
2032 * -----------------------------------------------------------------------
2033 * zonename_token(): Process zonename token and display contents
2034 * return codes : -1 - error
2036 * NOTE: At the time of call, the zonename token id has been retrieved
2038 * Format of zonename token:
2039 * zonename token id adr_char
2040 * zone name adr_string
2041 * -----------------------------------------------------------------------
2044 zonename_token(pr_context_t
*context
)
2046 return (process_tag(context
, TAG_ZONENAME
, 0, 1));
2050 * -----------------------------------------------------------------------
2051 * fmri_token(): Process fmri token and display contents
2052 * return codes : -1 - error
2054 * NOTE: At the time of call, the fmri token id has been retrieved
2056 * Format of fmri token:
2057 * fmri token id adr_char
2058 * service instance name adr_string
2059 * -----------------------------------------------------------------------
2062 fmri_token(pr_context_t
*context
)
2064 return (pa_adr_string(context
, 0, 1));
2068 * -----------------------------------------------------------------------
2069 * xatom_token() : Process Xatom token and display contents in hex.
2070 * return codes : -1 - error
2072 * NOTE: At the time of call, the xatom token id has been retrieved
2074 * Format of xatom token:
2077 * atom adr_char length times
2078 * -----------------------------------------------------------------------
2081 xatom_token(pr_context_t
*context
)
2083 return (pa_adr_string(context
, 0, 1));
2087 xcolormap_token(pr_context_t
*context
)
2089 return (pa_xgeneric(context
));
2093 xcursor_token(pr_context_t
*context
)
2095 return (pa_xgeneric(context
));
2099 xfont_token(pr_context_t
*context
)
2101 return (pa_xgeneric(context
));
2105 xgc_token(pr_context_t
*context
)
2107 return (pa_xgeneric(context
));
2111 xpixmap_token(pr_context_t
*context
)
2113 return (pa_xgeneric(context
));
2117 xwindow_token(pr_context_t
*context
)
2119 return (pa_xgeneric(context
));
2123 * -----------------------------------------------------------------------
2124 * xproperty_token(): Process Xproperty token and display contents
2126 * return codes : -1 - error
2128 * NOTE: At the time of call, the xproperty token id has been retrieved
2130 * Format of xproperty token:
2133 * creator UID adr_u_int32
2135 * -----------------------------------------------------------------------
2138 xproperty_token(pr_context_t
*context
)
2142 returnstat
= process_tag(context
, TAG_XID
, 0, 0);
2143 returnstat
= process_tag(context
, TAG_XCUID
, returnstat
, 0);
2145 /* Done with attributes; force end of token open */
2146 if (returnstat
== 0)
2147 returnstat
= finish_open_tag(context
);
2149 returnstat
= pa_adr_string(context
, returnstat
, 1);
2151 return (returnstat
);
2155 * -----------------------------------------------------------------------
2156 * xselect_token(): Process Xselect token and display contents in hex
2158 * return codes : -1 - error
2160 * NOTE: At the time of call, the xselect token id has been retrieved
2162 * Format of xselect token
2163 * text token id adr_char
2164 * property text adr_string
2165 * property type adr_string
2166 * property data adr_string
2167 * -----------------------------------------------------------------------
2170 xselect_token(pr_context_t
*context
)
2174 returnstat
= process_tag(context
, TAG_XSELTEXT
, 0, 0);
2175 returnstat
= process_tag(context
, TAG_XSELTYPE
, returnstat
, 0);
2176 returnstat
= process_tag(context
, TAG_XSELDATA
, returnstat
, 1);
2178 return (returnstat
);
2182 * -----------------------------------------------------------------------
2183 * xclient_token(): Process Xclient token and display contents in hex.
2185 * return codes : -1 - error
2188 * Format of xclient token:
2191 * -----------------------------------------------------------------------
2194 xclient_token(pr_context_t
*context
)
2196 return (pa_adr_int32(context
, 0, 1));
2200 * -----------------------------------------------------------------------
2201 * useofpriv_token() : Process priv token and display contents
2202 * return codes : -1 - error
2204 * NOTE: At the time of call, the useofpriv token id has been retrieved
2206 * Format of useofpriv token:
2207 * useofpriv token id adr_char
2208 * success/failure flag adr_char
2209 * priv adr_int32 (Trusted Solaris)
2210 * priv_set '\0' separated privileges.
2211 * -----------------------------------------------------------------------
2215 useofpriv_token(pr_context_t
*context
)
2221 if ((returnstat
= pr_adr_char(context
, &sf
, 1)) != 0) {
2222 return (returnstat
);
2224 if (!(context
->format
& PRF_RAWM
)) {
2225 /* print in ASCII form */
2227 if ((returnstat
= open_tag(context
, TAG_RESULT
)) != 0)
2228 return (returnstat
);
2230 uval
.uvaltype
= PRA_STRING
;
2232 uval
.string_val
= gettext("successful use of priv");
2233 returnstat
= pa_print(context
, &uval
, 0);
2235 uval
.string_val
= gettext("failed use of priv");
2236 returnstat
= pa_print(context
, &uval
, 0);
2238 if (returnstat
== 0)
2239 returnstat
= close_tag(context
, TAG_RESULT
);
2241 /* Done with attributes; force end of token open */
2242 if (returnstat
== 0)
2243 returnstat
= finish_open_tag(context
);
2245 /* print in hexadecimal form */
2246 if ((returnstat
= open_tag(context
, TAG_RESULT
)) != 0)
2247 return (returnstat
);
2248 uval
.uvaltype
= PRA_SHORT
;
2249 uval
.short_val
= sf
;
2250 returnstat
= pa_print(context
, &uval
, 0);
2251 if (returnstat
== 0)
2252 returnstat
= close_tag(context
, TAG_RESULT
);
2254 /* Done with attributes; force end of token open */
2255 if (returnstat
== 0)
2256 returnstat
= finish_open_tag(context
);
2258 return (pa_adr_string(context
, 0, 1));
2262 * -----------------------------------------------------------------------
2263 * privilege_token() : Process privilege token and display contents
2264 * return codes : -1 - error
2266 * NOTE: At the time of call, the privilege token id has been retrieved
2268 * Format of privilege token:
2269 * privilege token id adr_char
2270 * privilege type adr_string
2271 * privilege adr_string
2272 * -----------------------------------------------------------------------
2275 privilege_token(pr_context_t
*context
)
2279 /* privilege type: */
2280 returnstat
= process_tag(context
, TAG_SETTYPE
, 0, 0);
2282 /* Done with attributes; force end of token open */
2283 if (returnstat
== 0)
2284 returnstat
= finish_open_tag(context
);
2287 return (pa_adr_string(context
, returnstat
, 1));
2291 * -----------------------------------------------------------------------
2292 * secflags_token() : Process privilege token and display contents
2293 * return codes : -1 - error
2295 * NOTE: At the time of call, the secflags token id has been retrieved
2297 * Format of secflags token:
2298 * secflags token id adr_char
2299 * secflag set name adr_string
2300 * secflags adr_string
2301 * -----------------------------------------------------------------------
2304 secflags_token(pr_context_t
*context
)
2309 returnstat
= process_tag(context
, TAG_SETTYPE
, 0, 0);
2311 /* Done with attributes; force end of token open */
2312 if (returnstat
== 0)
2313 returnstat
= finish_open_tag(context
);
2316 return (pa_adr_string(context
, returnstat
, 1));