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.
24 * Copyright 2012 Milan Jurik. All rights reserved.
29 * Token processing for sysupd; each token function does one
30 * or more operations. All of them bump the buffer pointer
31 * to the next token; some of them extract one or more data
37 #define DPRINT(x) { (void) fprintf x; }
46 #include <sys/types.h>
47 #include <bsm/libbsm.h>
48 #include "toktable.h" /* ../praudit */
49 #include "sysplugin.h"
51 #include <audit_plugin.h>
54 static FILE *dbfp
; /* debug file */
57 static void anchor_path(char *);
58 static size_t collapse_path(char *, size_t);
59 static void get_bytes_to_string(parse_context_t
*, size_t *, char **,
61 static void skip_bytes(parse_context_t
*);
62 static void skip_string(parse_context_t
*);
63 static int xgeneric(parse_context_t
*);
66 * Process a token in a record to (1) extract data of interest if any
67 * and (2) point to the next token.
69 * returns 0 if ok. + or - values are of debug value:
71 * returns -1 if the parsing of the token failed.
73 * returns +<previous id> if the token is not found. This value
74 * is used to help determine where in the record the problem
75 * occurred. The common failure case is that the parsing of
76 * token M is incorrect and the buffer pointer ends up pointing
77 * to garbage. The positive error value of M *may* be the id of
78 * the incorrectly parsed token.
82 parse_token(parse_context_t
*ctx
)
85 static char prev_tokenid
= -1;
89 static boolean_t first
= 1;
92 dbfp
= __auditd_debug_file_open();
97 adrm_char(&(ctx
->adr
), &tokenid
, 1);
99 if ((tokenid
> 0) && (tokentable
[tokenid
].func
!= NOFUNC
)) {
100 rc
= (*tokentable
[tokenid
].func
)(ctx
);
101 prev_tokenid
= tokenid
;
104 /* here if token id is not in table */
105 return (prev_tokenid
);
108 /* There should not be any file tokens in the middle of a record */
112 file_token(parse_context_t
*ctx
)
120 file64_token(parse_context_t
*ctx
)
126 common_header(parse_context_t
*ctx
)
128 adrm_u_int32(&(ctx
->adr
), &(ctx
->out
.sf_reclen
), 1);
129 ctx
->adr
.adr_now
+= sizeof (char); /* version number */
130 adrm_u_short(&(ctx
->adr
), &(ctx
->out
.sf_eventid
), 1);
131 ctx
->adr
.adr_now
+= sizeof (short); /* modifier */
138 header_token(parse_context_t
*ctx
)
141 ctx
->adr
.adr_now
+= 2 * sizeof (int32_t); /* time */
148 header32_ex_token(parse_context_t
*ctx
)
154 adrm_int32(&(ctx
->adr
), &type
, 1); /* tid type */
155 ctx
->adr
.adr_now
+= type
* sizeof (char); /* ip address */
157 ctx
->adr
.adr_now
+= 2 * sizeof (int32_t); /* time */
164 header64_ex_token(parse_context_t
*ctx
)
170 adrm_int32(&(ctx
->adr
), &type
, 1); /* tid type */
171 ctx
->adr
.adr_now
+= type
* sizeof (char); /* ip address */
173 ctx
->adr
.adr_now
+= 2 * sizeof (int64_t); /* time */
180 header64_token(parse_context_t
*ctx
)
184 ctx
->adr
.adr_now
+= 2 * sizeof (int64_t); /* time */
191 * ======================================================
192 * The following token processing routines return
194 * -1: can't parse and can't determine location of next token
195 * ======================================================
199 trailer_token(parse_context_t
*ctx
)
204 adrm_u_short(&(ctx
->adr
), (ushort_t
*)&magic_number
, 1);
205 if (magic_number
!= AUT_TRAILER_MAGIC
)
208 adrm_u_int32(&(ctx
->adr
), &bytes
, 1);
215 * Format of arbitrary data token:
216 * arbitrary data token id &(ctx->adr) char
217 * how to print adr_char
218 * basic unit adr_char
219 * unit count adr_char, specifying number of units of
220 * data items depends on basic unit
224 arbitrary_data_token(parse_context_t
*ctx
)
226 char basic_unit
, unit_count
;
228 ctx
->adr
.adr_now
+= sizeof (char); /* how to print */
230 adrm_char(&(ctx
->adr
), &basic_unit
, 1);
231 adrm_char(&(ctx
->adr
), &unit_count
, 1);
233 switch (basic_unit
) {
234 case AUR_CHAR
: /* same as AUR_BYTE */
235 ctx
->adr
.adr_now
+= unit_count
* sizeof (char);
238 ctx
->adr
.adr_now
+= unit_count
* sizeof (short);
240 case AUR_INT32
: /* same as AUR_INT */
241 ctx
->adr
.adr_now
+= unit_count
* sizeof (int32_t);
244 ctx
->adr
.adr_now
+= unit_count
* sizeof (int64_t);
254 * Format of opaque token:
255 * opaque token id adr_char
257 * data adr_char, size times
261 opaque_token(parse_context_t
*ctx
)
269 * Format of return32 value token:
270 * return value token id adr_char
271 * error number adr_char
272 * return value adr_u_int32
276 return_value32_token(parse_context_t
*ctx
)
280 adrm_char(&(ctx
->adr
), &errnum
, 1); /* pass / fail */
281 ctx
->adr
.adr_now
+= sizeof (int32_t); /* error code */
283 ctx
->out
.sf_pass
= (errnum
== 0) ? 1 : -1;
289 * Format of return64 value token:
290 * return value token id adr_char
291 * error number adr_char
292 * return value adr_u_int64
296 return_value64_token(parse_context_t
*ctx
)
300 adrm_char(&(ctx
->adr
), &errnum
, 1); /* pass / fail */
301 ctx
->adr
.adr_now
+= sizeof (int64_t); /* error code */
303 ctx
->out
.sf_pass
= (errnum
== 0) ? 1 : -1;
310 * Format of sequence token:
311 * sequence token id adr_char
312 * audit_count int32_t
316 sequence_token(parse_context_t
*ctx
)
318 adrm_int32(&(ctx
->adr
), &(ctx
->out
.sf_sequence
), 1);
324 * Format of text token:
325 * text token id adr_char
329 text_token(parse_context_t
*ctx
)
332 size_t separator_sz
= 0;
333 char *bp
; /* pointer to output string */
335 adrm_u_short(&(ctx
->adr
), &len
, 1);
337 if (ctx
->out
.sf_textlen
> 0)
338 separator_sz
= sizeof (AU_TEXT_NAME
) - 1;
340 DPRINT((dbfp
, "text_token: start length=%d, add length=%d+%d\n",
341 ctx
->out
.sf_textlen
, (size_t)len
, separator_sz
));
343 ctx
->out
.sf_text
= realloc(ctx
->out
.sf_text
,
344 ctx
->out
.sf_textlen
+ (size_t)len
+ separator_sz
);
346 if (ctx
->out
.sf_text
== NULL
)
349 bp
= ctx
->out
.sf_text
;
351 if (ctx
->out
.sf_textlen
!= 0) { /* concatenation? */
352 bp
+= ctx
->out
.sf_textlen
;
353 bp
+= strlcpy(bp
, AU_TEXT_NAME
, separator_sz
+ 1);
354 ctx
->out
.sf_textlen
+= separator_sz
;
355 DPRINT((dbfp
, "text_token: l is %d\n%s\n", ctx
->out
.sf_textlen
,
358 adrm_char(&(ctx
->adr
), bp
, len
);
359 len
--; /* includes EOS */
362 ctx
->out
.sf_textlen
+= len
;
363 DPRINT((dbfp
, "text_token: l=%d\n%s\n", ctx
->out
.sf_textlen
,
370 * Format of tid token:
371 * ip token id adr_char
372 * terminal type adr_char
373 * terminal type = AU_IPADR:
374 * remote port: ushort
376 * IP type: int32 -- AU_IPv4 or AU_IPv6
377 * address: int32 if IPv4, else 4 * int32
380 tid_token(parse_context_t
*ctx
)
385 adrm_char(&(ctx
->adr
), (char *)&type
, 1);
389 return (-1); /* other than IP type is not implemented */
391 ctx
->adr
.adr_now
+= 2 * sizeof (ushort_t
);
392 adrm_int32(&(ctx
->adr
), &ip_length
, 1);
393 ctx
->adr
.adr_now
+= ip_length
;
400 * Format of ip_addr token:
401 * ip token id adr_char
406 ip_addr_token(parse_context_t
*ctx
)
408 ctx
->adr
.adr_now
+= sizeof (int32_t);
414 * Format of ip_addr_ex token:
415 * ip token id adr_char
417 * ip address adr_u_char*type
421 ip_addr_ex_token(parse_context_t
*ctx
)
425 adrm_int32(&(ctx
->adr
), &type
, 1); /* ip type */
426 ctx
->adr
.adr_now
+= type
* sizeof (uchar_t
); /* ip address */
432 * Format of ip token:
433 * ip header token id adr_char
435 * type of service adr_char
441 * checksum adr_u_short
442 * source address adr_int32
443 * destination address adr_int32
447 ip_token(parse_context_t
*ctx
)
449 ctx
->adr
.adr_now
+= (2 * sizeof (char)) + (3 * sizeof (short)) +
450 (2 * sizeof (char)) + sizeof (short) + (2 * sizeof (int32_t));
456 * Format of iport token:
457 * ip port address token id adr_char
458 * port address adr_short
462 iport_token(parse_context_t
*ctx
)
464 ctx
->adr
.adr_now
+= sizeof (short);
471 * Format of groups token:
472 * group token id adr_char
473 * group list adr_int32, 16 times
477 group_token(parse_context_t
*ctx
)
479 ctx
->adr
.adr_now
+= 16 * sizeof (int32_t);
485 * Format of newgroups token:
486 * group token id adr_char
487 * number of groups adr_short
488 * group list adr_int32, "number" times
492 newgroup_token(parse_context_t
*ctx
)
496 adrm_short(&(ctx
->adr
), &number
, 1);
498 ctx
->adr
.adr_now
+= number
* sizeof (int32_t);
504 * Format of argument32 token:
505 * argument token id adr_char
506 * argument number adr_char
507 * argument value adr_int32
508 * argument description adr_string
512 argument32_token(parse_context_t
*ctx
)
514 ctx
->adr
.adr_now
+= sizeof (char) + sizeof (int32_t);
521 * Format of argument64 token:
522 * argument token id adr_char
523 * argument number adr_char
524 * argument value adr_int64
525 * argument description adr_string
529 argument64_token(parse_context_t
*ctx
)
531 ctx
->adr
.adr_now
+= sizeof (char) + sizeof (int64_t);
538 * Format of acl token:
539 * acl token id adr_char
545 acl_token(parse_context_t
*ctx
)
547 ctx
->adr
.adr_now
+= 3 * sizeof (uint32_t);
553 * Format of ace token:
554 * ace token id adr_char
556 * access_mask adr_u_int32
561 ace_token(parse_context_t
*ctx
)
563 ctx
->adr
.adr_now
+= 2 * sizeof (uint32_t) + 2 * sizeof (ushort_t
);
569 * Format of attribute token: (old pre SunOS 5.7 format)
570 * attribute token id adr_char
571 * mode adr_int32 (printed in octal)
574 * file system id adr_int32
580 attribute_token(parse_context_t
*ctx
)
582 ctx
->adr
.adr_now
+= 6 * sizeof (int32_t);
588 * Format of attribute32 token:
589 * attribute token id adr_char
590 * mode adr_int32 (printed in octal)
593 * file system id adr_int32
599 attribute32_token(parse_context_t
*ctx
)
601 ctx
->adr
.adr_now
+= (5 * sizeof (int32_t)) + sizeof (int64_t);
607 * Format of attribute64 token:
608 * attribute token id adr_char
609 * mode adr_int32 (printed in octal)
612 * file system id adr_int32
618 attribute64_token(parse_context_t
*ctx
)
620 ctx
->adr
.adr_now
+= (4 * sizeof (int32_t)) + (2 * sizeof (int64_t));
627 * Format of command token:
628 * attribute token id adr_char
630 * argv len adr_short variable amount of argv len
631 * argv text argv len and text
635 * envp count adr_short variable amount of envp len
636 * envp len adr_short and text
644 cmd_token(parse_context_t
*ctx
)
649 adrm_short(&(ctx
->adr
), &cnt
, 1);
651 for (i
= 0; i
< cnt
; i
++)
654 adrm_short(&(ctx
->adr
), &cnt
, 1);
656 for (i
= 0; i
< cnt
; i
++)
664 * Format of exit token:
665 * attribute token id adr_char
666 * return value adr_int32
671 exit_token(parse_context_t
*ctx
)
675 adrm_int32(&(ctx
->adr
), &retval
, 1);
676 ctx
->adr
.adr_now
+= sizeof (int32_t);
678 ctx
->out
.sf_pass
= (retval
== 0) ? 1 : -1;
683 * Format of exec_args token:
684 * attribute token id adr_char
685 * count value adr_int32
686 * strings null terminated strings
690 exec_args_token(parse_context_t
*ctx
)
694 adrm_int32(&(ctx
->adr
), (int32_t *)&count
, 1);
695 for (i
= 1; i
<= count
; i
++) {
703 * Format of exec_env token:
704 * attribute token id adr_char
705 * count value adr_int32
706 * strings null terminated strings
710 exec_env_token(parse_context_t
*ctx
)
714 adrm_int32(&(ctx
->adr
), (int32_t *)&count
, 1);
715 for (i
= 1; i
<= count
; i
++)
722 * Format of liaison token:
725 liaison_token(parse_context_t
*ctx
)
727 ctx
->adr
.adr_now
+= sizeof (int32_t);
734 * Format of path token:
738 path_token(parse_context_t
*ctx
)
740 get_bytes_to_string(ctx
, &(ctx
->out
.sf_pathlen
), &(ctx
->out
.sf_path
),
742 if (ctx
->out
.sf_path
== NULL
)
745 * anchor the path because collapse_path needs it
747 if (*(ctx
->out
.sf_path
) != '/') {
748 anchor_path(ctx
->out
.sf_path
);
749 ctx
->out
.sf_pathlen
++;
751 ctx
->out
.sf_pathlen
= collapse_path(ctx
->out
.sf_path
,
752 ctx
->out
.sf_pathlen
);
758 * path attr token / AUT_XATPATH
760 * Format of path attr token:
762 * string count adr_int32
765 * the sequence of strings is converted to a single string with
766 * a blank separator replacing the EOS for all but the last
770 path_attr_token(parse_context_t
*ctx
)
777 adrm_int32(&(ctx
->adr
), &count
, 1);
779 offset
= ctx
->out
.sf_atpathlen
;
780 p
= ctx
->adr
.adr_now
;
781 for (i
= 0; i
<= count
; i
++) {
782 last_len
= strlen(p
);
783 ctx
->out
.sf_atpathlen
+= last_len
+ 1;
786 ctx
->out
.sf_atpath
= realloc(ctx
->out
.sf_atpath
, ctx
->out
.sf_atpathlen
);
787 ctx
->out
.sf_atpath
+= offset
;
788 p
= ctx
->out
.sf_atpath
; /* save for fix up, below */
789 (void) memcpy(ctx
->out
.sf_atpath
, ctx
->adr
.adr_now
,
790 ctx
->out
.sf_atpathlen
- offset
);
791 ctx
->out
.sf_atpathlen
--;
793 /* fix up: replace each eos except the last with ' ' */
795 for (i
= 0; i
< count
; i
++) {
805 * Format of System V IPC permission token:
806 * System V IPC permission token id adr_char
816 s5_IPC_perm_token(parse_context_t
*ctx
)
818 ctx
->adr
.adr_now
+= (7 * sizeof (int32_t));
823 common_process(parse_context_t
*ctx
)
825 int32_t ruid
, rgid
, egid
, pid
;
828 adrm_u_int32(&(ctx
->adr
), (uint32_t *)&(ctx
->out
.sf_pauid
), 1);
829 adrm_u_int32(&(ctx
->adr
), (uint32_t *)&(ctx
->out
.sf_peuid
), 1);
830 adrm_int32(&(ctx
->adr
), &egid
, 1);
831 adrm_int32(&(ctx
->adr
), &ruid
, 1);
832 adrm_int32(&(ctx
->adr
), &rgid
, 1);
833 adrm_int32(&(ctx
->adr
), &pid
, 1);
834 adrm_u_int32(&(ctx
->adr
), &asid
, 1);
838 * Format of process32 token:
839 * process token id adr_char
851 process32_token(parse_context_t
*ctx
)
853 int32_t port
, machine
;
857 adrm_int32(&(ctx
->adr
), &port
, 1);
858 adrm_int32(&(ctx
->adr
), &machine
, 1);
864 * Format of process32_ex token:
865 * process token id adr_char
876 * ip address adr_u_char*type
880 process32_ex_token(parse_context_t
*ctx
)
887 adrm_int32(&(ctx
->adr
), &port
, 1);
888 adrm_int32(&(ctx
->adr
), &type
, 1);
889 adrm_u_char(&(ctx
->adr
), addr
, type
);
895 * Format of process64 token:
896 * process token id adr_char
904 * termid adr_int64+adr_int32
908 process64_token(parse_context_t
*ctx
)
915 adrm_int64(&(ctx
->adr
), &port
, 1);
916 adrm_int32(&(ctx
->adr
), &machine
, 1);
922 * Format of process64_ex token:
923 * process token id adr_char
934 * ip address adr_u_char*type
938 process64_ex_token(parse_context_t
*ctx
)
946 adrm_int64(&(ctx
->adr
), &port
, 1);
947 adrm_int32(&(ctx
->adr
), &type
, 1);
948 adrm_u_char(&(ctx
->adr
), addr
, type
);
954 * Format of System V IPC token:
955 * System V IPC token id adr_char
956 * System V IPC type adr_char
957 * object id adr_int32
961 s5_IPC_token(parse_context_t
*ctx
)
963 ctx
->adr
.adr_now
+= sizeof (char);
964 ctx
->adr
.adr_now
+= sizeof (int32_t);
971 * Format of socket token:
972 * socket_type adrm_short
973 * remote_port adrm_short
974 * remote_inaddr adrm_int32
978 socket_token(parse_context_t
*ctx
)
980 ctx
->adr
.adr_now
+= (2 * sizeof (short)) + sizeof (int32_t);
987 * Format of socket_ex token:
988 * socket_domain adrm_short
989 * socket_type adrm_short
990 * address_type adrm_short
991 * local_port adrm_short
992 * local_inaddr adrm_u_char*address_type
993 * remote_port adrm_short
994 * remote_inaddr adrm_u_char*address_type
998 socket_ex_token(parse_context_t
*ctx
)
1002 ctx
->adr
.adr_now
+= (2 * sizeof (short));
1003 adrm_short(&(ctx
->adr
), &ip_size
, 1);
1005 ctx
->adr
.adr_now
+= sizeof (short) + (ip_size
* sizeof (char)) +
1006 sizeof (short) + (ip_size
* sizeof (char));
1012 common_subject(parse_context_t
*ctx
)
1014 int32_t ruid
, rgid
, pid
;
1016 adrm_u_int32(&(ctx
->adr
), (uint32_t *)&(ctx
->out
.sf_auid
), 1);
1017 adrm_u_int32(&(ctx
->adr
), (uint32_t *)&(ctx
->out
.sf_euid
), 1);
1018 adrm_u_int32(&(ctx
->adr
), (uint32_t *)&(ctx
->out
.sf_egid
), 1);
1019 adrm_int32(&(ctx
->adr
), &ruid
, 1);
1020 adrm_int32(&(ctx
->adr
), &rgid
, 1);
1021 adrm_int32(&(ctx
->adr
), &pid
, 1);
1022 adrm_u_int32(&(ctx
->adr
), (uint32_t *)&(ctx
->out
.sf_asid
), 1);
1026 * Format of subject32 token:
1027 * subject token id adr_char
1035 * termid adr_int32*2
1039 subject32_token(parse_context_t
*ctx
)
1041 int32_t port
; /* not used in output */
1043 common_subject(ctx
);
1045 adrm_int32(&(ctx
->adr
), &port
, 1);
1046 ctx
->out
.sf_tid
.at_type
= AU_IPv4
;
1047 adrm_u_char(&(ctx
->adr
), (uchar_t
*)&(ctx
->out
.sf_tid
.at_addr
[0]), 4);
1053 * Format of subject32_ex token:
1054 * subject token id adr_char
1065 * ip address adr_u_char*type
1069 subject32_ex_token(parse_context_t
*ctx
)
1071 int32_t port
; /* not used in output */
1073 common_subject(ctx
);
1075 adrm_int32(&(ctx
->adr
), &port
, 1);
1076 adrm_u_int32(&(ctx
->adr
), &(ctx
->out
.sf_tid
.at_type
), 1);
1077 adrm_u_char(&(ctx
->adr
), (uchar_t
*)&(ctx
->out
.sf_tid
.at_addr
[0]),
1078 ctx
->out
.sf_tid
.at_type
);
1084 * Format of subject64 token:
1085 * subject token id adr_char
1093 * termid adr_int64+adr_int32
1097 subject64_token(parse_context_t
*ctx
)
1101 common_subject(ctx
);
1103 adrm_int64(&(ctx
->adr
), &port
, 1);
1104 ctx
->out
.sf_tid
.at_type
= AU_IPv4
;
1105 adrm_u_char(&(ctx
->adr
), (uchar_t
*)&(ctx
->out
.sf_tid
.at_addr
[0]), 4);
1111 * Format of subject64_ex token:
1112 * subject token id adr_char
1123 * ip address adr_u_char*type
1127 subject64_ex_token(parse_context_t
*ctx
)
1131 common_subject(ctx
);
1133 adrm_int64(&(ctx
->adr
), &port
, 1);
1134 adrm_u_int32(&(ctx
->adr
), &(ctx
->out
.sf_tid
.at_type
), 1);
1135 adrm_u_char(&(ctx
->adr
), (uchar_t
*)&(ctx
->out
.sf_tid
.at_addr
[0]),
1136 ctx
->out
.sf_tid
.at_type
);
1143 xatom_token(parse_context_t
*ctx
)
1152 xselect_token(parse_context_t
*ctx
)
1162 * anchor a path name with a slash
1163 * assume we have enough space
1166 anchor_path(char *path
)
1169 (void) memmove((void *)(path
+ 1), (void *)path
, strlen(path
) + 1);
1175 * copy path to collapsed path.
1176 * collapsed path does not contain:
1177 * successive slashes
1178 * instances of dot-slash
1179 * instances of dot-dot-slash
1180 * passed path must be anchored with a '/'
1183 collapse_path(char *s
, size_t ls
)
1185 int id
; /* index of where we are in destination string */
1186 int is
; /* index of where we are in source string */
1187 int slashseen
; /* have we seen a slash */
1189 ls
++; /* source length including '\0' */
1192 for (is
= 0, id
= 0; is
< ls
; is
++) {
1193 if (s
[is
] == '\0') {
1194 if (id
> 1 && s
[id
-1] == '/') {
1200 /* previous character was a / */
1203 continue; /* another slash, ignore it */
1204 } else if (s
[is
] == '/') {
1205 /* we see a /, just copy it and try again */
1211 if (s
[is
] == '.' && s
[is
+1] == '/') {
1216 if (s
[is
] == '.' && s
[is
+1] == '\0') {
1222 if (s
[is
] == '.' && s
[is
+1] == '.' && s
[is
+2] == '\0') {
1226 while (id
> 0 && s
[--id
] != '/')
1232 if (s
[is
] == '.' && s
[is
+1] == '.' && s
[is
+2] == '/') {
1236 while (id
> 0 && s
[--id
] != '/')
1241 while (is
< ls
&& (s
[id
++] = s
[is
++]) != '/')
1245 return ((size_t)id
- 1);
1249 * for tokens with sub-fields that include a length, this
1250 * skips the sub-field.
1254 skip_bytes(parse_context_t
*ctx
)
1258 adrm_u_short(&(ctx
->adr
), &c
, 1);
1259 ctx
->adr
.adr_now
+= c
;
1263 skip_string(parse_context_t
*ctx
)
1268 adrm_char(&(ctx
->adr
), &c
, 1);
1269 } while (c
!= '\0');
1273 * add a byte to specified length so there can be a prefix of
1274 * '/' added (if needed for paths). Another is added for '\0'
1276 * if offset is zero, new data overwrites old, if any. Otherwise
1277 * new data is appended to the end.
1281 get_bytes_to_string(parse_context_t
*ctx
, size_t *l
, char **p
,
1287 adrm_u_short(&(ctx
->adr
), &len
, 1);
1289 len
++; /* in case need to add '/' prefix */
1290 *p
= realloc(*p
, 1 + (size_t)len
+ offset
);
1292 perror("audit_sysudp.so");
1296 offset
--; /* overwrite end of string */
1298 *l
= (size_t)len
- 2 + offset
;
1301 adrm_char(&(ctx
->adr
), bp
, len
- 1);
1302 *(bp
+ len
- 1) = '\0';
1307 * Format of host token:
1311 host_token(parse_context_t
*ctx
)
1313 ctx
->adr
.adr_now
+= sizeof (int32_t);
1319 * Format of useofauth token:
1320 * uauth token id adr_char
1325 useofauth_token(parse_context_t
*ctx
)
1327 get_bytes_to_string(ctx
, &(ctx
->out
.sf_uauthlen
),
1328 &(ctx
->out
.sf_uauth
), 0);
1334 * Format of user token:
1335 * user token id adr_char
1337 * username adr_string
1341 user_token(parse_context_t
*ctx
)
1343 ctx
->adr
.adr_now
+= sizeof (uid_t
);
1350 * Format of zonename token:
1351 * zonename token id adr_char
1352 * zonename adr_string
1356 zonename_token(parse_context_t
*ctx
)
1358 get_bytes_to_string(ctx
,
1359 &(ctx
->out
.sf_zonelen
),
1360 &(ctx
->out
.sf_zonename
),
1367 * Format of fmri token:
1368 * fmri token id adr_char
1372 fmri_token(parse_context_t
*ctx
)
1380 xcolormap_token(parse_context_t
*ctx
)
1382 return (xgeneric(ctx
));
1386 xcursor_token(parse_context_t
*ctx
)
1388 return (xgeneric(ctx
));
1392 xfont_token(parse_context_t
*ctx
)
1394 return (xgeneric(ctx
));
1398 xgc_token(parse_context_t
*ctx
)
1400 return (xgeneric(ctx
));
1404 xpixmap_token(parse_context_t
*ctx
)
1406 return (xgeneric(ctx
));
1410 xwindow_token(parse_context_t
*ctx
)
1412 return (xgeneric(ctx
));
1415 * Format of xgeneric token:
1417 * creator UID adr_int32
1419 * Includes: xcolormap, xcursor, xfont, xgc, xpixmap, and xwindow
1422 xgeneric(parse_context_t
*ctx
)
1424 ctx
->adr
.adr_now
+= 2 * sizeof (int32_t);
1429 * Format of xproperty token:
1431 * creator UID adr_int32
1432 * atom string adr_string
1435 xproperty_token(parse_context_t
*ctx
)
1437 ctx
->adr
.adr_now
+= 2 * sizeof (int32_t);
1442 * Format of xclient token:
1443 * xclient id adr_int32
1446 xclient_token(parse_context_t
*ctx
)
1448 ctx
->adr
.adr_now
+= sizeof (int32_t);
1454 * -----------------------------------------------------------------------
1455 * privilege_token() : Process privilege token and display contents
1457 * Format of privilege token:
1458 * privilege token id adr_char
1459 * privilege type adr_string
1460 * privilege adr_string
1461 * -----------------------------------------------------------------------
1465 privilege_token(parse_context_t
*ctx
)
1474 * -----------------------------------------------------------------------
1475 * secflags_token() : Process secflags token and display contents
1477 * Format of privilege token:
1478 * secflags token id adr_char
1479 * secflag set name adr_string
1480 * secflags adr_string
1481 * -----------------------------------------------------------------------
1484 secflags_token(parse_context_t
*ctx
)
1493 * Format of label token:
1495 * compartment length 1 byte
1496 * classification 2 bytes
1497 * compartment words <compartment length> * 4 bytes
1500 label_token(parse_context_t
*ctx
)
1504 ctx
->adr
.adr_now
+= sizeof (char); /* label ID */
1505 adrm_char(&(ctx
->adr
), &c
, 1);
1507 ctx
->adr
.adr_now
+= sizeof (ushort_t
); /* classification */
1508 ctx
->adr
.adr_now
+= 4 * c
; /* compartments */
1514 * Format of useofpriv token:
1515 * priv_type adr_char
1516 * priv_set_t adr_short
1517 * priv_set adr_char*(sizeof (priv_set_t))
1520 useofpriv_token(parse_context_t
*ctx
)
1522 ctx
->adr
.adr_now
+= sizeof (char); /* success / fail */