xref: /freebsd/contrib/openbsm/test/bsm/generate.c (revision d056fa046c6a91b90cd98165face0e42a33a5173)
1 /*-
2  * Copyright (c) 2006 Robert N. M. Watson
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $P4: //depot/projects/trustedbsd/openbsm/test/bsm/generate.c#4 $
27  */
28 
29 /*
30  * Generate a series of BSM token samples in the requested directory.
31  */
32 
33 #include <sys/types.h>
34 #include <sys/socket.h>
35 #include <sys/stat.h>
36 
37 #include <netinet/in.h>
38 #include <netinet/in_systm.h>
39 #include <netinet/ip.h>
40 
41 #include <arpa/inet.h>
42 
43 #include <bsm/audit_kevents.h>
44 #include <bsm/libbsm.h>
45 
46 #include <err.h>
47 #include <errno.h>
48 #include <fcntl.h>
49 #include <limits.h>
50 #include <stdio.h>
51 #include <stdlib.h>
52 #include <string.h>
53 #include <sysexits.h>
54 #include <unistd.h>
55 
56 static int	do_records, do_tokens;
57 
58 static void
59 usage(void)
60 {
61 
62 	fprintf(stderr, "generate [-rt] path\n");
63 	exit(EX_USAGE);
64 }
65 
66 static int
67 open_file(const char *directory, const char *name)
68 {
69 	char pathname[PATH_MAX];
70 	int fd;
71 
72 	snprintf(pathname, PATH_MAX, "%s/%s", directory, name);
73 	(void)unlink(pathname);
74 	fd = open(pathname, O_WRONLY | O_CREAT | O_EXCL, 0600);
75 	if (fd < 0)
76 		err(EX_CANTCREAT, "open: %s", name);
77 	return (fd);
78 }
79 
80 static void
81 write_file(int fd, void *buffer, size_t buflen, const char *filename)
82 {
83 	ssize_t len;
84 
85 	len = write(fd, buffer, buflen);
86 	if (len < 0)
87 		err(EX_OSERR, "write_file: %s", filename);
88 	if (len < buflen)
89 		err(EX_OSERR, "write_file: short write: %s", filename);
90 }
91 
92 /*
93  * Write a single token to a file.
94  */
95 static void
96 write_token(const char *directory, const char *filename, token_t *tok)
97 {
98 	u_char buffer[MAX_AUDIT_RECORD_SIZE];
99 	size_t buflen;
100 	int fd;
101 
102 	buflen = MAX_AUDIT_RECORD_SIZE;
103 	if (au_close_token(tok, buffer, &buflen) < 0)
104 		err(EX_UNAVAILABLE, "au_close_token");
105 	fd = open_file(directory, filename);
106 	write_file(fd, buffer, buflen, filename);
107 	close(fd);
108 }
109 
110 /*
111  * Write a token to a file, wrapped in audit record header and trailer.
112  */
113 static void
114 write_record(const char *directory, const char *filename, token_t *tok,
115     short event)
116 {
117 	u_char buffer[MAX_AUDIT_RECORD_SIZE];
118 	size_t buflen;
119 	int au, fd;
120 
121 	au = au_open();
122 	if (au < 0)
123 		err(EX_UNAVAILABLE, "au_open");
124 	if (au_write(au, tok) < 0)
125 		err(EX_UNAVAILABLE, "au_write");
126 	buflen = MAX_AUDIT_RECORD_SIZE;
127 	if (au_close_buffer(au, event, buffer, &buflen) < 0)
128 		err(EX_UNAVAILABLE, "au_close_buffer");
129 	fd = open_file(directory, filename);
130 	write_file(fd, buffer, buflen, filename);
131 	close(fd);
132 }
133 
134 static struct timeval	 file_token_timeval = { 0x12345, 0x67890} ;
135 
136 static void
137 generate_file_token(const char *directory, const char *token_filename)
138 {
139 	token_t *file_token;
140 
141 	file_token = au_to_file("test", file_token_timeval);
142 	if (file_token == NULL)
143 		err(EX_UNAVAILABLE, "au_to_file");
144 	write_token(directory, token_filename, file_token);
145 }
146 
147 /*
148  * AUT_OHEADER
149  */
150 
151 static int		 trailer_token_len = 0x12345678;
152 
153 static void
154 generate_trailer_token(const char *directory, const char *token_filename)
155 {
156 	token_t *trailer_token;
157 
158 	trailer_token = au_to_trailer(trailer_token_len);
159 	if (trailer_token == NULL)
160 		err(EX_UNAVAILABLE, "au_to_trailer");
161 	write_token(directory, token_filename, trailer_token);
162 }
163 
164 static int		 header32_token_len = 0x12345678;
165 static au_event_t	 header32_e_type = AUE_OPEN;
166 static au_emod_t	 header32_e_mod = 0x4567;
167 static struct timeval	 header32_tm = { 0x12345, 0x67890 };
168 
169 static void
170 generate_header32_token(const char *directory, const char *token_filename)
171 {
172 	token_t *header32_token;
173 
174 	header32_token = au_to_header32_tm(header32_token_len,
175 	    header32_e_type, header32_e_mod, header32_tm);
176 	if (header32_token == NULL)
177 		err(EX_UNAVAILABLE, "au_to_header32");
178 	write_token(directory, token_filename, header32_token);
179 }
180 
181 /*
182  * AUT_HEADER32_EX
183  */
184 
185 static char		 data_token_unit_print = AUP_STRING;
186 static char		 data_token_unit_type = AUR_CHAR;
187 static char		*data_token_data = "SomeData";
188 static char		 data_token_unit_count = sizeof("SomeData") + 1;
189 
190 static void
191 generate_data_token(const char *directory, const char *token_filename)
192 {
193 	token_t *data_token;
194 
195 	data_token = au_to_data(data_token_unit_print, data_token_unit_type,
196 	    data_token_unit_count, data_token_data);
197 	if (data_token == NULL)
198 		err(EX_UNAVAILABLE, "au_to_data");
199 	write_token(directory, token_filename, data_token);
200 }
201 
202 static void
203 generate_data_record(const char *directory, const char *record_filename)
204 {
205 	token_t *data_token;
206 
207 	data_token = au_to_data(data_token_unit_print, data_token_unit_type,
208 	    data_token_unit_count, data_token_data);
209 	if (data_token == NULL)
210 		err(EX_UNAVAILABLE, "au_to_data");
211 	write_record(directory, record_filename, data_token, AUE_NULL);
212 }
213 
214 static char		 ipc_type = AT_IPC_MSG;
215 static int		 ipc_id = 0x12345678;
216 
217 static void
218 generate_ipc_token(const char *directory, const char *token_filename)
219 {
220 	token_t *ipc_token;
221 
222 	ipc_token = au_to_ipc(ipc_type, ipc_id);
223 	if (ipc_token == NULL)
224 		err(EX_UNAVAILABLE, "au_to_ipc");
225 	write_token(directory, token_filename, ipc_token);
226 }
227 
228 static void
229 generate_ipc_record(const char *directory, const char *record_filename)
230 {
231 	token_t *ipc_token;
232 
233 	ipc_token = au_to_ipc(ipc_type, ipc_id);
234 	if (ipc_token == NULL)
235 		err(EX_UNAVAILABLE, "au_to_ipc");
236 	write_record(directory, record_filename, ipc_token, AUE_NULL);
237 }
238 
239 static char		*path_token_path = "/test/this/is/a/test";
240 
241 static void
242 generate_path_token(const char *directory, const char *token_filename)
243 {
244 	token_t *path_token;
245 
246 	path_token = au_to_path(path_token_path);
247 	if (path_token == NULL)
248 		err(EX_UNAVAILABLE, "au_to_path");
249 	write_token(directory, token_filename, path_token);
250 }
251 
252 static void
253 generate_path_record(const char *directory, const char *record_filename)
254 {
255 	token_t *path_token;
256 
257 	path_token = au_to_path(path_token_path);
258 	if (path_token == NULL)
259 		err(EX_UNAVAILABLE, "au_to_path");
260 	write_record(directory, record_filename, path_token, AUE_NULL);
261 }
262 
263 static au_id_t		 subject32_auid = 0x12345678;
264 static uid_t		 subject32_euid = 0x01234567;
265 static gid_t		 subject32_egid = 0x23456789;
266 static uid_t		 subject32_ruid = 0x98765432;
267 static gid_t		 subject32_rgid = 0x09876543;
268 static pid_t		 subject32_pid = 0x13243546;
269 static au_asid_t	 subject32_sid = 0x97867564;
270 static au_tid_t		 subject32_tid = { 0x16593746 };
271 static au_tid_addr_t	 subject32_tid_addr = { 0x16593746 };
272 
273 static void
274 generate_subject32_token(const char *directory, const char *token_filename)
275 {
276 	token_t *subject32_token;
277 
278 	subject32_tid.machine = inet_addr("127.0.0.1");
279 
280 	subject32_token = au_to_subject32(subject32_auid, subject32_euid,
281 	    subject32_egid, subject32_ruid, subject32_rgid, subject32_pid,
282 	    subject32_sid, &subject32_tid);
283 	if (subject32_token == NULL)
284 		err(EX_UNAVAILABLE, "au_to_subject32");
285 	write_token(directory, token_filename, subject32_token);
286 }
287 
288 static void
289 generate_subject32_record(const char *directory, const char *record_filename)
290 {
291 	token_t *subject32_token;
292 
293 	subject32_tid.machine = inet_addr("127.0.0.1");
294 
295 	subject32_token = au_to_subject32(subject32_auid, subject32_euid,
296 	    subject32_egid, subject32_ruid, subject32_rgid, subject32_pid,
297 	    subject32_sid, &subject32_tid);
298 	if (subject32_token == NULL)
299 		err(EX_UNAVAILABLE, "au_to_subject32");
300 	write_record(directory, record_filename, subject32_token, AUE_NULL);
301 }
302 
303 static void
304 generate_subject32ex_token(const char *directory, const char *token_filename,
305     u_int32_t type)
306 {
307 	token_t *subject32ex_token;
308 	char *buf;
309 
310 	buf = (char *)malloc(strlen(token_filename) + 6);
311 	if (type == AU_IPv6) {
312 		inet_pton(AF_INET6, "fe80::1", subject32_tid_addr.at_addr);
313 		subject32_tid_addr.at_type = AU_IPv6;
314 		sprintf(buf, "%s%s", token_filename, "-IPv6");
315 	} else {
316 		subject32_tid_addr.at_addr[0] = inet_addr("127.0.0.1");
317 		subject32_tid_addr.at_type = AU_IPv4;
318 		sprintf(buf, "%s%s", token_filename, "-IPv4");
319 	}
320 
321 	subject32ex_token = au_to_subject32_ex(subject32_auid, subject32_euid,
322 	    subject32_egid, subject32_ruid, subject32_rgid, subject32_pid,
323 	    subject32_sid, &subject32_tid_addr);
324 	if (subject32ex_token == NULL)
325 		err(EX_UNAVAILABLE, "au_to_subject32_ex");
326 	write_token(directory, buf, subject32ex_token);
327 }
328 
329 static au_id_t		 process32_auid = 0x12345678;
330 static uid_t		 process32_euid = 0x01234567;
331 static gid_t		 process32_egid = 0x23456789;
332 static uid_t		 process32_ruid = 0x98765432;
333 static gid_t		 process32_rgid = 0x09876543;
334 static pid_t		 process32_pid = 0x13243546;
335 static au_asid_t	 process32_sid = 0x97867564;
336 static au_tid_t		 process32_tid = { 0x16593746 };
337 static au_tid_addr_t	 process32_tid_addr = { 0x16593746 };
338 
339 static void
340 generate_process32_token(const char *directory, const char *token_filename)
341 {
342 	token_t *process32_token;
343 
344 	process32_tid.machine = inet_addr("127.0.0.1");
345 
346 	process32_token = au_to_process32(process32_auid, process32_euid,
347 	    process32_egid, process32_ruid, process32_rgid, process32_pid,
348 	    process32_sid, &process32_tid);
349 	if (process32_token == NULL)
350 		err(EX_UNAVAILABLE, "au_to_process32");
351 	write_token(directory, token_filename, process32_token);
352 }
353 
354 static void
355 generate_process32_record(const char *directory, const char *record_filename)
356 {
357 	token_t *process32_token;
358 
359 	process32_tid.machine = inet_addr("127.0.0.1");
360 
361 	process32_token = au_to_process32(process32_auid, process32_euid,
362 	    process32_egid, process32_ruid, process32_rgid, process32_pid,
363 	    process32_sid, &process32_tid);
364 	if (process32_token == NULL)
365 		err(EX_UNAVAILABLE, "au_ti_process32");
366 	write_record(directory, record_filename, process32_token, AUE_NULL);
367 }
368 
369 static void
370 generate_process32ex_token(const char *directory, const char *token_filename)
371 {
372 	token_t *process32ex_token;
373 
374 	process32_tid_addr.at_addr[0] = inet_addr("127.0.0.1");
375 	process32_tid_addr.at_type = AU_IPv4;
376 
377 	process32ex_token = au_to_process32_ex(process32_auid, process32_euid,
378 	    process32_egid, process32_ruid, process32_rgid, process32_pid,
379 	    process32_sid, &process32_tid_addr);
380 	if (process32ex_token == NULL)
381 		err(EX_UNAVAILABLE, "au_to_process32_ex");
382 	write_token(directory, token_filename, process32ex_token);
383 }
384 
385 static char		 return32_status = 0xd7;
386 static uint32_t		 return32_ret = 0x12345678;
387 
388 static void
389 generate_return32_token(const char *directory, const char *token_filename)
390 {
391 	token_t *return32_token;
392 
393 	return32_token = au_to_return32(return32_status, return32_ret);
394 	if (return32_token == NULL)
395 		err(EX_UNAVAILABLE, "au_to_return32");
396 	write_token(directory, token_filename, return32_token);
397 }
398 
399 static void
400 generate_return32_record(const char *directory, const char *record_filename)
401 {
402 	token_t *return32_token;
403 
404 	return32_token = au_to_return32(return32_status, return32_ret);
405 	if (return32_token == NULL)
406 		err(EX_UNAVAILABLE, "au_to_return32");
407 	write_record(directory, record_filename, return32_token, AUE_NULL);
408 }
409 
410 static char		*text_token_text = "This is a test.";
411 
412 static void
413 generate_text_token(const char *directory, const char *token_filename)
414 {
415 	token_t *text_token;
416 
417 	text_token = au_to_text(text_token_text);
418 	if (text_token == NULL)
419 		err(EX_UNAVAILABLE, "au_to_text");
420 	write_token(directory, token_filename, text_token);
421 }
422 
423 static void
424 generate_text_record(const char *directory, const char *record_filename)
425 {
426 	token_t *text_token;
427 
428 	text_token = au_to_text(text_token_text);
429 	if (text_token == NULL)
430 		err(EX_UNAVAILABLE, "au_to_text");
431 	write_record(directory, record_filename, text_token, AUE_NULL);
432 }
433 
434 static char		 opaque_token_data[] = {0xaa, 0xbb, 0xcc, 0xdd};
435 static int		 opaque_token_bytes = sizeof(opaque_token_data);
436 
437 static void
438 generate_opaque_token(const char *directory, const char *token_filename)
439 {
440 	token_t *opaque_token;
441 
442 	opaque_token = au_to_opaque(opaque_token_data, opaque_token_bytes);
443 	if (opaque_token == NULL)
444 		err(EX_UNAVAILABLE, "au_to_opaque");
445 	write_token(directory, token_filename, opaque_token);
446 }
447 
448 static void
449 generate_opaque_record(const char *directory, const char *record_filename)
450 {
451 	token_t *opaque_token;
452 
453 	opaque_token = au_to_opaque(opaque_token_data, opaque_token_bytes);
454 	if (opaque_token == NULL)
455 		err(EX_UNAVAILABLE, "au_to_opaque");
456 	write_record(directory, record_filename, opaque_token, AUE_NULL);
457 }
458 
459 static struct in_addr	 in_addr_token_addr;
460 
461 static void
462 generate_in_addr_token(const char *directory, const char *token_filename)
463 {
464 	token_t *in_addr_token;
465 
466 	in_addr_token_addr.s_addr = inet_addr("192.168.100.15");
467 
468 	in_addr_token = au_to_in_addr(&in_addr_token_addr);
469 	if (in_addr_token == NULL)
470 		err(EX_UNAVAILABLE, "au_to_in_addr");
471 	write_token(directory, token_filename, in_addr_token);
472 }
473 
474 static void
475 generate_in_addr_record(const char *directory, const char *record_filename)
476 {
477 	token_t *in_addr_token;
478 
479 	in_addr_token_addr.s_addr = inet_addr("192.168.100.15");
480 
481 	in_addr_token = au_to_in_addr(&in_addr_token_addr);
482 	if (in_addr_token == NULL)
483 		err(EX_UNAVAILABLE, "au_to_in_addr");
484 	write_record(directory, record_filename, in_addr_token, AUE_NULL);
485 }
486 
487 static struct ip	 ip_token_ip;
488 static u_char		 ip_token_ip_v = 4;
489 static uint16_t		 ip_token_ip_id = 0x5478;
490 static u_char		 ip_token_ip_ttl = 64;
491 static u_char		 ip_token_ip_p = IPPROTO_ICMP;
492 static struct in_addr	 ip_token_ip_src;
493 static struct in_addr	 ip_token_ip_dst;
494 
495 static void
496 generate_ip_token(const char *directory, const char *token_filename)
497 {
498 	token_t *ip_token;
499 
500 	ip_token_ip_src.s_addr = inet_addr("192.168.100.155");
501 	ip_token_ip_dst.s_addr = inet_addr("192.168.110.48");
502 
503 	memset(&ip_token_ip, 0, sizeof(ip_token_ip));
504 	ip_token_ip.ip_v = ip_token_ip_v;
505 	ip_token_ip.ip_len = htons(sizeof(ip_token_ip));
506 	ip_token_ip.ip_id = htons(ip_token_ip_id);
507 	ip_token_ip.ip_ttl = ip_token_ip_ttl;
508 	ip_token_ip.ip_p = ip_token_ip_p;
509 	ip_token_ip.ip_src = ip_token_ip_src;
510 	ip_token_ip.ip_dst = ip_token_ip_dst;
511 
512 	ip_token = au_to_ip(&ip_token_ip);
513 	if (ip_token == NULL)
514 		err(EX_UNAVAILABLE, "au_to_ip");
515 	write_token(directory, token_filename, ip_token);
516 }
517 
518 static void
519 generate_ip_record(const char *directory, const char *record_filename)
520 {
521 	token_t *ip_token;
522 
523 	ip_token_ip_src.s_addr = inet_addr("192.168.100.155");
524 	ip_token_ip_dst.s_addr = inet_addr("192.168.110.48");
525 
526 	memset(&ip_token_ip, 0, sizeof(ip_token_ip));
527 	ip_token_ip.ip_v = ip_token_ip_v;
528 	ip_token_ip.ip_len = htons(sizeof(ip_token_ip));
529 	ip_token_ip.ip_id = htons(ip_token_ip_id);
530 	ip_token_ip.ip_ttl = ip_token_ip_ttl;
531 	ip_token_ip.ip_p = ip_token_ip_p;
532 	ip_token_ip.ip_src = ip_token_ip_src;
533 	ip_token_ip.ip_dst = ip_token_ip_dst;
534 
535 	ip_token = au_to_ip(&ip_token_ip);
536 	if (ip_token == NULL)
537 		err(EX_UNAVAILABLE, "au_to_ip");
538 	write_record(directory, record_filename, ip_token, AUE_NULL);
539 }
540 
541 static u_int16_t		 iport_token_iport;
542 
543 static void
544 generate_iport_token(const char *directory, const char *token_filename)
545 {
546 	token_t *iport_token;
547 
548 	iport_token_iport = htons(80);
549 
550 	iport_token = au_to_iport(iport_token_iport);
551 	if (iport_token == NULL)
552 		err(EX_UNAVAILABLE, "au_to_iport");
553 	write_token(directory, token_filename, iport_token);
554 }
555 
556 static void
557 generate_iport_record(const char *directory, const char *record_filename)
558 {
559 	token_t *iport_token;
560 
561 	iport_token_iport = htons(80);
562 
563 	iport_token = au_to_iport(iport_token_iport);
564 	if (iport_token == NULL)
565 		err(EX_UNAVAILABLE, "au_to_iport");
566 	write_record(directory, record_filename, iport_token, AUE_NULL);
567 }
568 
569 static char	 arg32_token_n = 3;
570 static char	*arg32_token_text = "test_arg32_token";
571 static uint32_t	 arg32_token_v = 0xabcdef00;
572 
573 static void
574 generate_arg32_token(const char *directory, const char *token_filename)
575 {
576 	token_t *arg32_token;
577 
578 	arg32_token = au_to_arg32(arg32_token_n, arg32_token_text,
579 	    arg32_token_v);
580 	if (arg32_token == NULL)
581 		err(EX_UNAVAILABLE, "au_to_arg32");
582 	write_token(directory, token_filename, arg32_token);
583 }
584 
585 static void
586 generate_arg32_record(const char *directory, const char *record_filename)
587 {
588 	token_t *arg32_token;
589 
590 	arg32_token = au_to_arg32(arg32_token_n, arg32_token_text,
591 	    arg32_token_v);
592 	if (arg32_token == NULL)
593 		err(EX_UNAVAILABLE, "au_to_arg32");
594 	write_record(directory, record_filename, arg32_token, AUE_NULL);
595 }
596 
597 static long	 seq_audit_count = 0x12345678;
598 
599 static void
600 generate_seq_token(const char *directory, const char *token_filename)
601 {
602 	token_t *seq_token;
603 
604 	seq_token = au_to_seq(seq_audit_count);
605 	if (seq_token == NULL)
606 		err(EX_UNAVAILABLE, "au_to_seq");
607 	write_token(directory, token_filename, seq_token);
608 }
609 
610 static void
611 generate_seq_record(const char *directory, const char *record_filename)
612 {
613 	token_t *seq_token;
614 
615 	seq_token = au_to_seq(seq_audit_count);
616 	if (seq_token == NULL)
617 		err(EX_UNAVAILABLE, "au_to_seq");
618 	write_record(directory, record_filename, seq_token, AUE_NULL);
619 }
620 
621 /*
622  * AUT_ACL
623  */
624 
625 static void
626 generate_attr_token(const char *directory, const char *token_filename)
627 {
628 	token_t *attr_token;
629 
630 }
631 
632 static void
633 generate_attr_record(const char *directory, const char *record_filename)
634 {
635 	token_t *attr_token;
636 
637 }
638 
639 static void
640 generate_ipc_perm_token(const char *directory, const char *token_filename)
641 {
642 	token_t *ipc_perm_token;
643 
644 }
645 
646 static void
647 generate_ipc_perm_record(const char *directory, const char *record_filename)
648 {
649 	token_t *ipc_perm_token;
650 
651 }
652 
653 /*
654  * AUT_LABEL
655  */
656 
657 static void
658 generate_groups_token(const char *directory, const char *token_filename)
659 {
660 	token_t *groups_token;
661 
662 }
663 
664 static void
665 generate_groups_record(const char *directory, const char *record_filename)
666 {
667 	token_t *groups_token;
668 
669 }
670 
671 /*
672  * AUT_ILABEL
673  */
674 
675 /*
676  * AUT_SLABEL
677  */
678 
679 /*
680  * AUT_CLEAR
681  */
682 
683 /*
684  * AUT_PRIV
685  */
686 
687 /*
688  * AUT_UPRIV
689  */
690 
691 /*
692  * AUT_LIAISON
693  */
694 
695 /*
696  * AUT_NEWGROUPS
697  */
698 
699 /*
700  * AUT_EXEC_ARGS
701  */
702 
703 /*
704  * AUT_EXEC_ENV
705  */
706 
707 static void
708 generate_attr32_token(const char *directory, const char *token_filename)
709 {
710 	token_t *attr32_token;
711 
712 }
713 
714 static void
715 generate_attr32_record(const char *directory, const char *record_filename)
716 {
717 	token_t *attr32_token;
718 
719 }
720 
721 int
722 main(int argc, char *argv[])
723 {
724 	const char *directory;
725 	int ch;
726 
727 	while ((ch = getopt(argc, argv, "rt")) != -1) {
728 		switch (ch) {
729 		case 'r':
730 			do_records++;
731 			break;
732 
733 		case 't':
734 			do_tokens++;
735 			break;
736 
737 		default:
738 			usage();
739 		}
740 	}
741 
742 	argc -= optind;
743 	argv += optind;
744 
745 	if (argc != 1)
746 		usage();
747 
748 	directory = argv[0];
749 
750 	if (mkdir(directory, 0755) < 0 && errno != EEXIST)
751 		err(EX_OSERR, "mkdir: %s", directory);
752 
753 	if (do_tokens) {
754 		generate_file_token(directory, "file_token");
755 		generate_trailer_token(directory, "trailer_token");
756 		generate_header32_token(directory, "header32_token");
757 		generate_data_token(directory, "data_token");
758 		generate_ipc_token(directory, "ipc_token");
759 		generate_path_token(directory, "path_token");
760 		generate_subject32_token(directory, "subject32_token");
761 		generate_subject32ex_token(directory, "subject32ex_token", AU_IPv4);
762 		generate_subject32ex_token(directory, "subject32ex_token", AU_IPv6);
763 		generate_process32_token(directory, "process32_token");
764 		generate_process32ex_token(directory, "process32ex_token");
765 		generate_return32_token(directory, "return32_token");
766 		generate_text_token(directory, "text_token");
767 		generate_opaque_token(directory, "opaque_token");
768 		generate_in_addr_token(directory, "in_addr_token");
769 		generate_ip_token(directory, "ip_token");
770 		generate_iport_token(directory, "iport_token");
771 		generate_arg32_token(directory, "arg32_token");
772 		generate_seq_token(directory, "seq_token");
773 		generate_attr_token(directory,  "attr_token");
774 		generate_ipc_perm_token(directory, "ipc_perm_token");
775 		generate_groups_token(directory, "groups_token");
776 		generate_attr32_token(directory, "attr32_token");
777 	}
778 
779 	if (do_records) {
780 		generate_file_token(directory, "file_token");
781 		generate_trailer_token(directory, "trailer_token");
782 		generate_header32_token(directory, "header32_token");
783 		generate_data_token(directory, "data_record");
784 		generate_ipc_token(directory, "ipc_record");
785 		generate_path_token(directory, "path_record");
786 		generate_subject32_token(directory, "subject32_record");
787 		generate_subject32ex_token(directory, "subject32ex_record", AU_IPv4);
788 		generate_subject32ex_token(directory, "subject32ex_record", AU_IPv6);
789 		generate_process32_token(directory, "process32_record");
790 		generate_process32ex_token(directory, "process32ex_token");
791 		generate_return32_token(directory, "return32_record");
792 		generate_text_token(directory, "text_record");
793 		generate_opaque_token(directory, "opaque_record");
794 		generate_in_addr_token(directory, "in_addr_record");
795 		generate_ip_token(directory, "ip_record");
796 		generate_iport_token(directory, "iport_record");
797 		generate_arg32_token(directory, "arg32_record");
798 		generate_seq_token(directory, "seq_record");
799 		generate_attr_token(directory,  "attr_record");
800 		generate_ipc_perm_token(directory, "ipc_perm_record");
801 		generate_groups_token(directory, "groups_record");
802 		generate_attr32_token(directory, "attr32_record");
803 	}
804 
805 	return (0);
806 }
807