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 <sys/tsol/label.h>
49 #include "toktable.h" /* ../praudit */
50 #include "sysplugin.h"
52 #include <audit_plugin.h>
55 static FILE *dbfp
; /* debug file */
58 static void anchor_path(char *);
59 static size_t collapse_path(char *, size_t);
60 static void get_bytes_to_string(parse_context_t
*, size_t *, char **,
62 static void skip_bytes(parse_context_t
*);
63 static void skip_string(parse_context_t
*);
64 static int xgeneric(parse_context_t
*);
67 * Process a token in a record to (1) extract data of interest if any
68 * and (2) point to the next token.
70 * returns 0 if ok. + or - values are of debug value:
72 * returns -1 if the parsing of the token failed.
74 * returns +<previous id> if the token is not found. This value
75 * is used to help determine where in the record the problem
76 * occurred. The common failure case is that the parsing of
77 * token M is incorrect and the buffer pointer ends up pointing
78 * to garbage. The positive error value of M *may* be the id of
79 * the incorrectly parsed token.
83 parse_token(parse_context_t
*ctx
)
86 static char prev_tokenid
= -1;
90 static boolean_t first
= 1;
93 dbfp
= __auditd_debug_file_open();
98 adrm_char(&(ctx
->adr
), &tokenid
, 1);
100 if ((tokenid
> 0) && (tokentable
[tokenid
].func
!= NOFUNC
)) {
101 rc
= (*tokentable
[tokenid
].func
)(ctx
);
102 prev_tokenid
= tokenid
;
105 /* here if token id is not in table */
106 return (prev_tokenid
);
109 /* There should not be any file tokens in the middle of a record */
113 file_token(parse_context_t
*ctx
)
121 file64_token(parse_context_t
*ctx
)
127 common_header(parse_context_t
*ctx
)
129 adrm_u_int32(&(ctx
->adr
), &(ctx
->out
.sf_reclen
), 1);
130 ctx
->adr
.adr_now
+= sizeof (char); /* version number */
131 adrm_u_short(&(ctx
->adr
), &(ctx
->out
.sf_eventid
), 1);
132 ctx
->adr
.adr_now
+= sizeof (short); /* modifier */
139 header_token(parse_context_t
*ctx
)
142 ctx
->adr
.adr_now
+= 2 * sizeof (int32_t); /* time */
149 header32_ex_token(parse_context_t
*ctx
)
155 adrm_int32(&(ctx
->adr
), &type
, 1); /* tid type */
156 ctx
->adr
.adr_now
+= type
* sizeof (char); /* ip address */
158 ctx
->adr
.adr_now
+= 2 * sizeof (int32_t); /* time */
165 header64_ex_token(parse_context_t
*ctx
)
171 adrm_int32(&(ctx
->adr
), &type
, 1); /* tid type */
172 ctx
->adr
.adr_now
+= type
* sizeof (char); /* ip address */
174 ctx
->adr
.adr_now
+= 2 * sizeof (int64_t); /* time */
181 header64_token(parse_context_t
*ctx
)
185 ctx
->adr
.adr_now
+= 2 * sizeof (int64_t); /* time */
192 * ======================================================
193 * The following token processing routines return
195 * -1: can't parse and can't determine location of next token
196 * ======================================================
200 trailer_token(parse_context_t
*ctx
)
205 adrm_u_short(&(ctx
->adr
), (ushort_t
*)&magic_number
, 1);
206 if (magic_number
!= AUT_TRAILER_MAGIC
)
209 adrm_u_int32(&(ctx
->adr
), &bytes
, 1);
216 * Format of arbitrary data token:
217 * arbitrary data token id &(ctx->adr) char
218 * how to print adr_char
219 * basic unit adr_char
220 * unit count adr_char, specifying number of units of
221 * data items depends on basic unit
225 arbitrary_data_token(parse_context_t
*ctx
)
227 char basic_unit
, unit_count
;
229 ctx
->adr
.adr_now
+= sizeof (char); /* how to print */
231 adrm_char(&(ctx
->adr
), &basic_unit
, 1);
232 adrm_char(&(ctx
->adr
), &unit_count
, 1);
234 switch (basic_unit
) {
235 case AUR_CHAR
: /* same as AUR_BYTE */
236 ctx
->adr
.adr_now
+= unit_count
* sizeof (char);
239 ctx
->adr
.adr_now
+= unit_count
* sizeof (short);
241 case AUR_INT32
: /* same as AUR_INT */
242 ctx
->adr
.adr_now
+= unit_count
* sizeof (int32_t);
245 ctx
->adr
.adr_now
+= unit_count
* sizeof (int64_t);
255 * Format of opaque token:
256 * opaque token id adr_char
258 * data adr_char, size times
262 opaque_token(parse_context_t
*ctx
)
270 * Format of return32 value token:
271 * return value token id adr_char
272 * error number adr_char
273 * return value adr_u_int32
277 return_value32_token(parse_context_t
*ctx
)
281 adrm_char(&(ctx
->adr
), &errnum
, 1); /* pass / fail */
282 ctx
->adr
.adr_now
+= sizeof (int32_t); /* error code */
284 ctx
->out
.sf_pass
= (errnum
== 0) ? 1 : -1;
290 * Format of return64 value token:
291 * return value token id adr_char
292 * error number adr_char
293 * return value adr_u_int64
297 return_value64_token(parse_context_t
*ctx
)
301 adrm_char(&(ctx
->adr
), &errnum
, 1); /* pass / fail */
302 ctx
->adr
.adr_now
+= sizeof (int64_t); /* error code */
304 ctx
->out
.sf_pass
= (errnum
== 0) ? 1 : -1;
311 * Format of sequence token:
312 * sequence token id adr_char
313 * audit_count int32_t
317 sequence_token(parse_context_t
*ctx
)
319 adrm_int32(&(ctx
->adr
), &(ctx
->out
.sf_sequence
), 1);
325 * Format of text token:
326 * text token id adr_char
330 text_token(parse_context_t
*ctx
)
333 size_t separator_sz
= 0;
334 char *bp
; /* pointer to output string */
336 adrm_u_short(&(ctx
->adr
), &len
, 1);
338 if (ctx
->out
.sf_textlen
> 0)
339 separator_sz
= sizeof (AU_TEXT_NAME
) - 1;
341 DPRINT((dbfp
, "text_token: start length=%d, add length=%d+%d\n",
342 ctx
->out
.sf_textlen
, (size_t)len
, separator_sz
));
344 ctx
->out
.sf_text
= realloc(ctx
->out
.sf_text
,
345 ctx
->out
.sf_textlen
+ (size_t)len
+ separator_sz
);
347 if (ctx
->out
.sf_text
== NULL
)
350 bp
= ctx
->out
.sf_text
;
352 if (ctx
->out
.sf_textlen
!= 0) { /* concatenation? */
353 bp
+= ctx
->out
.sf_textlen
;
354 bp
+= strlcpy(bp
, AU_TEXT_NAME
, separator_sz
+ 1);
355 ctx
->out
.sf_textlen
+= separator_sz
;
356 DPRINT((dbfp
, "text_token: l is %d\n%s\n", ctx
->out
.sf_textlen
,
359 adrm_char(&(ctx
->adr
), bp
, len
);
360 len
--; /* includes EOS */
363 ctx
->out
.sf_textlen
+= len
;
364 DPRINT((dbfp
, "text_token: l=%d\n%s\n", ctx
->out
.sf_textlen
,
371 * Format of tid token:
372 * ip token id adr_char
373 * terminal type adr_char
374 * terminal type = AU_IPADR:
375 * remote port: ushort
377 * IP type: int32 -- AU_IPv4 or AU_IPv6
378 * address: int32 if IPv4, else 4 * int32
381 tid_token(parse_context_t
*ctx
)
386 adrm_char(&(ctx
->adr
), (char *)&type
, 1);
390 return (-1); /* other than IP type is not implemented */
392 ctx
->adr
.adr_now
+= 2 * sizeof (ushort_t
);
393 adrm_int32(&(ctx
->adr
), &ip_length
, 1);
394 ctx
->adr
.adr_now
+= ip_length
;
401 * Format of ip_addr token:
402 * ip token id adr_char
407 ip_addr_token(parse_context_t
*ctx
)
409 ctx
->adr
.adr_now
+= sizeof (int32_t);
415 * Format of ip_addr_ex token:
416 * ip token id adr_char
418 * ip address adr_u_char*type
422 ip_addr_ex_token(parse_context_t
*ctx
)
426 adrm_int32(&(ctx
->adr
), &type
, 1); /* ip type */
427 ctx
->adr
.adr_now
+= type
* sizeof (uchar_t
); /* ip address */
433 * Format of ip token:
434 * ip header token id adr_char
436 * type of service adr_char
442 * checksum adr_u_short
443 * source address adr_int32
444 * destination address adr_int32
448 ip_token(parse_context_t
*ctx
)
450 ctx
->adr
.adr_now
+= (2 * sizeof (char)) + (3 * sizeof (short)) +
451 (2 * sizeof (char)) + sizeof (short) + (2 * sizeof (int32_t));
457 * Format of iport token:
458 * ip port address token id adr_char
459 * port address adr_short
463 iport_token(parse_context_t
*ctx
)
465 ctx
->adr
.adr_now
+= sizeof (short);
472 * Format of groups token:
473 * group token id adr_char
474 * group list adr_int32, 16 times
478 group_token(parse_context_t
*ctx
)
480 ctx
->adr
.adr_now
+= 16 * sizeof (int32_t);
486 * Format of newgroups token:
487 * group token id adr_char
488 * number of groups adr_short
489 * group list adr_int32, "number" times
493 newgroup_token(parse_context_t
*ctx
)
497 adrm_short(&(ctx
->adr
), &number
, 1);
499 ctx
->adr
.adr_now
+= number
* sizeof (int32_t);
505 * Format of argument32 token:
506 * argument token id adr_char
507 * argument number adr_char
508 * argument value adr_int32
509 * argument description adr_string
513 argument32_token(parse_context_t
*ctx
)
515 ctx
->adr
.adr_now
+= sizeof (char) + sizeof (int32_t);
522 * Format of argument64 token:
523 * argument token id adr_char
524 * argument number adr_char
525 * argument value adr_int64
526 * argument description adr_string
530 argument64_token(parse_context_t
*ctx
)
532 ctx
->adr
.adr_now
+= sizeof (char) + sizeof (int64_t);
539 * Format of acl token:
540 * acl token id adr_char
546 acl_token(parse_context_t
*ctx
)
548 ctx
->adr
.adr_now
+= 3 * sizeof (uint32_t);
554 * Format of ace token:
555 * ace token id adr_char
557 * access_mask adr_u_int32
562 ace_token(parse_context_t
*ctx
)
564 ctx
->adr
.adr_now
+= 2 * sizeof (uint32_t) + 2 * sizeof (ushort_t
);
570 * Format of attribute token: (old pre SunOS 5.7 format)
571 * attribute token id adr_char
572 * mode adr_int32 (printed in octal)
575 * file system id adr_int32
581 attribute_token(parse_context_t
*ctx
)
583 ctx
->adr
.adr_now
+= 6 * sizeof (int32_t);
589 * Format of attribute32 token:
590 * attribute token id adr_char
591 * mode adr_int32 (printed in octal)
594 * file system id adr_int32
600 attribute32_token(parse_context_t
*ctx
)
602 ctx
->adr
.adr_now
+= (5 * sizeof (int32_t)) + sizeof (int64_t);
608 * Format of attribute64 token:
609 * attribute token id adr_char
610 * mode adr_int32 (printed in octal)
613 * file system id adr_int32
619 attribute64_token(parse_context_t
*ctx
)
621 ctx
->adr
.adr_now
+= (4 * sizeof (int32_t)) + (2 * sizeof (int64_t));
628 * Format of command token:
629 * attribute token id adr_char
631 * argv len adr_short variable amount of argv len
632 * argv text argv len and text
636 * envp count adr_short variable amount of envp len
637 * envp len adr_short and text
645 cmd_token(parse_context_t
*ctx
)
650 adrm_short(&(ctx
->adr
), &cnt
, 1);
652 for (i
= 0; i
< cnt
; i
++)
655 adrm_short(&(ctx
->adr
), &cnt
, 1);
657 for (i
= 0; i
< cnt
; i
++)
665 * Format of exit token:
666 * attribute token id adr_char
667 * return value adr_int32
672 exit_token(parse_context_t
*ctx
)
676 adrm_int32(&(ctx
->adr
), &retval
, 1);
677 ctx
->adr
.adr_now
+= sizeof (int32_t);
679 ctx
->out
.sf_pass
= (retval
== 0) ? 1 : -1;
684 * Format of exec_args token:
685 * attribute token id adr_char
686 * count value adr_int32
687 * strings null terminated strings
691 exec_args_token(parse_context_t
*ctx
)
695 adrm_int32(&(ctx
->adr
), (int32_t *)&count
, 1);
696 for (i
= 1; i
<= count
; i
++) {
704 * Format of exec_env token:
705 * attribute token id adr_char
706 * count value adr_int32
707 * strings null terminated strings
711 exec_env_token(parse_context_t
*ctx
)
715 adrm_int32(&(ctx
->adr
), (int32_t *)&count
, 1);
716 for (i
= 1; i
<= count
; i
++)
723 * Format of liaison token:
726 liaison_token(parse_context_t
*ctx
)
728 ctx
->adr
.adr_now
+= sizeof (int32_t);
735 * Format of path token:
739 path_token(parse_context_t
*ctx
)
741 get_bytes_to_string(ctx
, &(ctx
->out
.sf_pathlen
), &(ctx
->out
.sf_path
),
743 if (ctx
->out
.sf_path
== NULL
)
746 * anchor the path because collapse_path needs it
748 if (*(ctx
->out
.sf_path
) != '/') {
749 anchor_path(ctx
->out
.sf_path
);
750 ctx
->out
.sf_pathlen
++;
752 ctx
->out
.sf_pathlen
= collapse_path(ctx
->out
.sf_path
,
753 ctx
->out
.sf_pathlen
);
759 * path attr token / AUT_XATPATH
761 * Format of path attr token:
763 * string count adr_int32
766 * the sequence of strings is converted to a single string with
767 * a blank separator replacing the EOS for all but the last
771 path_attr_token(parse_context_t
*ctx
)
778 adrm_int32(&(ctx
->adr
), &count
, 1);
780 offset
= ctx
->out
.sf_atpathlen
;
781 p
= ctx
->adr
.adr_now
;
782 for (i
= 0; i
<= count
; i
++) {
783 last_len
= strlen(p
);
784 ctx
->out
.sf_atpathlen
+= last_len
+ 1;
787 ctx
->out
.sf_atpath
= realloc(ctx
->out
.sf_atpath
, ctx
->out
.sf_atpathlen
);
788 ctx
->out
.sf_atpath
+= offset
;
789 p
= ctx
->out
.sf_atpath
; /* save for fix up, below */
790 (void) memcpy(ctx
->out
.sf_atpath
, ctx
->adr
.adr_now
,
791 ctx
->out
.sf_atpathlen
- offset
);
792 ctx
->out
.sf_atpathlen
--;
794 /* fix up: replace each eos except the last with ' ' */
796 for (i
= 0; i
< count
; i
++) {
806 * Format of System V IPC permission token:
807 * System V IPC permission token id adr_char
817 s5_IPC_perm_token(parse_context_t
*ctx
)
819 ctx
->adr
.adr_now
+= (7 * sizeof (int32_t));
824 common_process(parse_context_t
*ctx
)
826 int32_t ruid
, rgid
, egid
, pid
;
829 adrm_u_int32(&(ctx
->adr
), (uint32_t *)&(ctx
->out
.sf_pauid
), 1);
830 adrm_u_int32(&(ctx
->adr
), (uint32_t *)&(ctx
->out
.sf_peuid
), 1);
831 adrm_int32(&(ctx
->adr
), &egid
, 1);
832 adrm_int32(&(ctx
->adr
), &ruid
, 1);
833 adrm_int32(&(ctx
->adr
), &rgid
, 1);
834 adrm_int32(&(ctx
->adr
), &pid
, 1);
835 adrm_u_int32(&(ctx
->adr
), &asid
, 1);
839 * Format of process32 token:
840 * process token id adr_char
852 process32_token(parse_context_t
*ctx
)
854 int32_t port
, machine
;
858 adrm_int32(&(ctx
->adr
), &port
, 1);
859 adrm_int32(&(ctx
->adr
), &machine
, 1);
865 * Format of process32_ex token:
866 * process token id adr_char
877 * ip address adr_u_char*type
881 process32_ex_token(parse_context_t
*ctx
)
888 adrm_int32(&(ctx
->adr
), &port
, 1);
889 adrm_int32(&(ctx
->adr
), &type
, 1);
890 adrm_u_char(&(ctx
->adr
), addr
, type
);
896 * Format of process64 token:
897 * process token id adr_char
905 * termid adr_int64+adr_int32
909 process64_token(parse_context_t
*ctx
)
916 adrm_int64(&(ctx
->adr
), &port
, 1);
917 adrm_int32(&(ctx
->adr
), &machine
, 1);
923 * Format of process64_ex token:
924 * process token id adr_char
935 * ip address adr_u_char*type
939 process64_ex_token(parse_context_t
*ctx
)
947 adrm_int64(&(ctx
->adr
), &port
, 1);
948 adrm_int32(&(ctx
->adr
), &type
, 1);
949 adrm_u_char(&(ctx
->adr
), addr
, type
);
955 * Format of System V IPC token:
956 * System V IPC token id adr_char
957 * System V IPC type adr_char
958 * object id adr_int32
962 s5_IPC_token(parse_context_t
*ctx
)
964 ctx
->adr
.adr_now
+= sizeof (char);
965 ctx
->adr
.adr_now
+= sizeof (int32_t);
972 * Format of socket token:
973 * socket_type adrm_short
974 * remote_port adrm_short
975 * remote_inaddr adrm_int32
979 socket_token(parse_context_t
*ctx
)
981 ctx
->adr
.adr_now
+= (2 * sizeof (short)) + sizeof (int32_t);
988 * Format of socket_ex token:
989 * socket_domain adrm_short
990 * socket_type adrm_short
991 * address_type adrm_short
992 * local_port adrm_short
993 * local_inaddr adrm_u_char*address_type
994 * remote_port adrm_short
995 * remote_inaddr adrm_u_char*address_type
999 socket_ex_token(parse_context_t
*ctx
)
1003 ctx
->adr
.adr_now
+= (2 * sizeof (short));
1004 adrm_short(&(ctx
->adr
), &ip_size
, 1);
1006 ctx
->adr
.adr_now
+= sizeof (short) + (ip_size
* sizeof (char)) +
1007 sizeof (short) + (ip_size
* sizeof (char));
1013 common_subject(parse_context_t
*ctx
)
1015 int32_t ruid
, rgid
, pid
;
1017 adrm_u_int32(&(ctx
->adr
), (uint32_t *)&(ctx
->out
.sf_auid
), 1);
1018 adrm_u_int32(&(ctx
->adr
), (uint32_t *)&(ctx
->out
.sf_euid
), 1);
1019 adrm_u_int32(&(ctx
->adr
), (uint32_t *)&(ctx
->out
.sf_egid
), 1);
1020 adrm_int32(&(ctx
->adr
), &ruid
, 1);
1021 adrm_int32(&(ctx
->adr
), &rgid
, 1);
1022 adrm_int32(&(ctx
->adr
), &pid
, 1);
1023 adrm_u_int32(&(ctx
->adr
), (uint32_t *)&(ctx
->out
.sf_asid
), 1);
1027 * Format of subject32 token:
1028 * subject token id adr_char
1036 * termid adr_int32*2
1040 subject32_token(parse_context_t
*ctx
)
1042 int32_t port
; /* not used in output */
1044 common_subject(ctx
);
1046 adrm_int32(&(ctx
->adr
), &port
, 1);
1047 ctx
->out
.sf_tid
.at_type
= AU_IPv4
;
1048 adrm_u_char(&(ctx
->adr
), (uchar_t
*)&(ctx
->out
.sf_tid
.at_addr
[0]), 4);
1054 * Format of subject32_ex token:
1055 * subject token id adr_char
1066 * ip address adr_u_char*type
1070 subject32_ex_token(parse_context_t
*ctx
)
1072 int32_t port
; /* not used in output */
1074 common_subject(ctx
);
1076 adrm_int32(&(ctx
->adr
), &port
, 1);
1077 adrm_u_int32(&(ctx
->adr
), &(ctx
->out
.sf_tid
.at_type
), 1);
1078 adrm_u_char(&(ctx
->adr
), (uchar_t
*)&(ctx
->out
.sf_tid
.at_addr
[0]),
1079 ctx
->out
.sf_tid
.at_type
);
1085 * Format of subject64 token:
1086 * subject token id adr_char
1094 * termid adr_int64+adr_int32
1098 subject64_token(parse_context_t
*ctx
)
1102 common_subject(ctx
);
1104 adrm_int64(&(ctx
->adr
), &port
, 1);
1105 ctx
->out
.sf_tid
.at_type
= AU_IPv4
;
1106 adrm_u_char(&(ctx
->adr
), (uchar_t
*)&(ctx
->out
.sf_tid
.at_addr
[0]), 4);
1112 * Format of subject64_ex token:
1113 * subject token id adr_char
1124 * ip address adr_u_char*type
1128 subject64_ex_token(parse_context_t
*ctx
)
1132 common_subject(ctx
);
1134 adrm_int64(&(ctx
->adr
), &port
, 1);
1135 adrm_u_int32(&(ctx
->adr
), &(ctx
->out
.sf_tid
.at_type
), 1);
1136 adrm_u_char(&(ctx
->adr
), (uchar_t
*)&(ctx
->out
.sf_tid
.at_addr
[0]),
1137 ctx
->out
.sf_tid
.at_type
);
1144 xatom_token(parse_context_t
*ctx
)
1153 xselect_token(parse_context_t
*ctx
)
1163 * anchor a path name with a slash
1164 * assume we have enough space
1167 anchor_path(char *path
)
1170 (void) memmove((void *)(path
+ 1), (void *)path
, strlen(path
) + 1);
1176 * copy path to collapsed path.
1177 * collapsed path does not contain:
1178 * successive slashes
1179 * instances of dot-slash
1180 * instances of dot-dot-slash
1181 * passed path must be anchored with a '/'
1184 collapse_path(char *s
, size_t ls
)
1186 int id
; /* index of where we are in destination string */
1187 int is
; /* index of where we are in source string */
1188 int slashseen
; /* have we seen a slash */
1190 ls
++; /* source length including '\0' */
1193 for (is
= 0, id
= 0; is
< ls
; is
++) {
1194 if (s
[is
] == '\0') {
1195 if (id
> 1 && s
[id
-1] == '/') {
1201 /* previous character was a / */
1204 continue; /* another slash, ignore it */
1205 } else if (s
[is
] == '/') {
1206 /* we see a /, just copy it and try again */
1212 if (s
[is
] == '.' && s
[is
+1] == '/') {
1217 if (s
[is
] == '.' && s
[is
+1] == '\0') {
1223 if (s
[is
] == '.' && s
[is
+1] == '.' && s
[is
+2] == '\0') {
1227 while (id
> 0 && s
[--id
] != '/')
1233 if (s
[is
] == '.' && s
[is
+1] == '.' && s
[is
+2] == '/') {
1237 while (id
> 0 && s
[--id
] != '/')
1242 while (is
< ls
&& (s
[id
++] = s
[is
++]) != '/')
1246 return ((size_t)id
- 1);
1250 * for tokens with sub-fields that include a length, this
1251 * skips the sub-field.
1255 skip_bytes(parse_context_t
*ctx
)
1259 adrm_u_short(&(ctx
->adr
), &c
, 1);
1260 ctx
->adr
.adr_now
+= c
;
1264 skip_string(parse_context_t
*ctx
)
1269 adrm_char(&(ctx
->adr
), &c
, 1);
1270 } while (c
!= (char)0);
1274 * add a byte to specified length so there can be a prefix of
1275 * '/' added (if needed for paths). Another is added for '\0'
1277 * if offset is zero, new data overwrites old, if any. Otherwise
1278 * new data is appended to the end.
1282 get_bytes_to_string(parse_context_t
*ctx
, size_t *l
, char **p
,
1288 adrm_u_short(&(ctx
->adr
), &len
, 1);
1290 len
++; /* in case need to add '/' prefix */
1291 *p
= realloc(*p
, 1 + (size_t)len
+ offset
);
1293 perror("audit_sysudp.so");
1297 offset
--; /* overwrite end of string */
1299 *l
= (size_t)len
- 2 + offset
;
1302 adrm_char(&(ctx
->adr
), bp
, len
- 1);
1303 *(bp
+ len
- 1) = '\0';
1308 * Format of host token:
1312 host_token(parse_context_t
*ctx
)
1314 ctx
->adr
.adr_now
+= sizeof (int32_t);
1320 * Format of useofauth token:
1321 * uauth token id adr_char
1326 useofauth_token(parse_context_t
*ctx
)
1328 get_bytes_to_string(ctx
, &(ctx
->out
.sf_uauthlen
),
1329 &(ctx
->out
.sf_uauth
), 0);
1335 * Format of user token:
1336 * user token id adr_char
1338 * username adr_string
1342 user_token(parse_context_t
*ctx
)
1344 ctx
->adr
.adr_now
+= sizeof (uid_t
);
1351 * Format of zonename token:
1352 * zonename token id adr_char
1353 * zonename adr_string
1357 zonename_token(parse_context_t
*ctx
)
1359 get_bytes_to_string(ctx
,
1360 &(ctx
->out
.sf_zonelen
),
1361 &(ctx
->out
.sf_zonename
),
1368 * Format of fmri token:
1369 * fmri token id adr_char
1373 fmri_token(parse_context_t
*ctx
)
1381 xcolormap_token(parse_context_t
*ctx
)
1383 return (xgeneric(ctx
));
1387 xcursor_token(parse_context_t
*ctx
)
1389 return (xgeneric(ctx
));
1393 xfont_token(parse_context_t
*ctx
)
1395 return (xgeneric(ctx
));
1399 xgc_token(parse_context_t
*ctx
)
1401 return (xgeneric(ctx
));
1405 xpixmap_token(parse_context_t
*ctx
)
1407 return (xgeneric(ctx
));
1411 xwindow_token(parse_context_t
*ctx
)
1413 return (xgeneric(ctx
));
1416 * Format of xgeneric token:
1418 * creator UID adr_int32
1420 * Includes: xcolormap, xcursor, xfont, xgc, xpixmap, and xwindow
1423 xgeneric(parse_context_t
*ctx
)
1425 ctx
->adr
.adr_now
+= 2 * sizeof (int32_t);
1430 * Format of xproperty token:
1432 * creator UID adr_int32
1433 * atom string adr_string
1436 xproperty_token(parse_context_t
*ctx
)
1438 ctx
->adr
.adr_now
+= 2 * sizeof (int32_t);
1443 * Format of xclient token:
1444 * xclient id adr_int32
1447 xclient_token(parse_context_t
*ctx
)
1449 ctx
->adr
.adr_now
+= sizeof (int32_t);
1455 * -----------------------------------------------------------------------
1456 * privilege_token() : Process privilege token and display contents
1458 * Format of privilege token:
1459 * privilege token id adr_char
1460 * privilege type adr_string
1461 * privilege adr_string
1462 * -----------------------------------------------------------------------
1466 privilege_token(parse_context_t
*ctx
)
1475 * -----------------------------------------------------------------------
1476 * secflags_token() : Process secflags token and display contents
1478 * Format of privilege token:
1479 * secflags token id adr_char
1480 * secflag set name adr_string
1481 * secflags adr_string
1482 * -----------------------------------------------------------------------
1485 secflags_token(parse_context_t
*ctx
)
1494 * Format of label token:
1496 * compartment length 1 byte
1497 * classification 2 bytes
1498 * compartment words <compartment length> * 4 bytes
1501 label_token(parse_context_t
*ctx
)
1505 ctx
->adr
.adr_now
+= sizeof (char); /* label ID */
1506 adrm_char(&(ctx
->adr
), &c
, 1);
1508 ctx
->adr
.adr_now
+= sizeof (ushort_t
); /* classification */
1509 ctx
->adr
.adr_now
+= 4 * c
; /* compartments */
1515 * Format of useofpriv token:
1516 * priv_type adr_char
1517 * priv_set_t adr_short
1518 * priv_set adr_char*(sizeof (priv_set_t))
1521 useofpriv_token(parse_context_t
*ctx
)
1523 ctx
->adr
.adr_now
+= sizeof (char); /* success / fail */