-
Notifications
You must be signed in to change notification settings - Fork 651
/
Copy pathlibbsm.h
1475 lines (1360 loc) · 42.3 KB
/
libbsm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*-
* Copyright (c) 2004-2009 Apple Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $P4: //depot/projects/trustedbsd/openbsm/bsm/libbsm.h#48 $
*/
#ifndef _LIBBSM_H_
#define _LIBBSM_H_
/*
* NB: definitions, etc., marked with "OpenSSH compatibility" were introduced
* solely to allow OpenSSH to compile; Darwin/Apple code should not use them.
*/
#include <sys/types.h>
#include <sys/cdefs.h>
#include <inttypes.h> /* Required for audit.h. */
#include <time.h> /* Required for clock_t on Linux. */
#include <bsm/audit.h>
#include <bsm/audit_record.h>
#include <stdio.h>
#ifdef __APPLE__
#include <mach/mach.h> /* audit_token_t */
#include <Availability.h>
#endif
/*
* Size parsed token vectors for execve(2) arguments and environmental
* variables. Note: changing these sizes affects the ABI of the token
* structure, and as the token structure is often placed in the caller stack,
* this is undesirable.
*/
#define AUDIT_MAX_ARGS 128
#define AUDIT_MAX_ENV 128
/*
* Arguments to au_preselect(3).
*/
#define AU_PRS_USECACHE 0
#define AU_PRS_REREAD 1
#define AU_PRS_SUCCESS 1
#define AU_PRS_FAILURE 2
#define AU_PRS_BOTH (AU_PRS_SUCCESS|AU_PRS_FAILURE)
#define AUDIT_EVENT_FILE "/etc/security/audit_event"
#define AUDIT_CLASS_FILE "/etc/security/audit_class"
#define AUDIT_CONTROL_FILE "/etc/security/audit_control"
#define AUDIT_USER_FILE "/etc/security/audit_user"
#define DIR_CONTROL_ENTRY "dir"
#define MINFREE_CONTROL_ENTRY "minfree"
#define FILESZ_CONTROL_ENTRY "filesz"
#define FLAGS_CONTROL_ENTRY "flags"
#define NA_CONTROL_ENTRY "naflags"
#define POLICY_CONTROL_ENTRY "policy"
#define AUDIT_HOST_CONTROL_ENTRY "host"
#define EXPIRE_AFTER_CONTROL_ENTRY "expire-after"
#define MEMBER_SET_SFLAGS_MASK_CONTROL_ENTRY \
"member-set-sflags-mask"
#define MEMBER_CLEAR_SFLAGS_MASK_CONTROL_ENTRY \
"member-clear-sflags-mask"
#define SUPERUSER_SET_SFLAGS_MASK_CONTROL_ENTRY \
"superuser-set-sflags-mask"
#define SUPERUSER_CLEAR_SFLAGS_MASK_CONTROL_ENTRY \
"superuser-clear-sflags-mask"
#define AU_CLASS_NAME_MAX 8
#define AU_CLASS_DESC_MAX 72
#define AU_EVENT_NAME_MAX 30
#define AU_EVENT_DESC_MAX 50
#define AU_USER_NAME_MAX 50
#define AU_LINE_MAX 256
#define MAX_AUDITSTRING_LEN 256
#define BSM_TEXTBUFSZ MAX_AUDITSTRING_LEN /* OpenSSH compatibility */
/*
* Arguments to au_close(3).
*/
#define AU_TO_NO_WRITE 0 /* Abandon audit record. */
#define AU_TO_WRITE 1 /* Commit audit record. */
/*
* Output format flags for au_print_flags_tok().
*/
#define AU_OFLAG_NONE 0x0000 /* Default form. */
#define AU_OFLAG_RAW 0x0001 /* Raw, numeric form. */
#define AU_OFLAG_SHORT 0x0002 /* Short form. */
#define AU_OFLAG_XML 0x0004 /* XML form. */
#define AU_OFLAG_NORESOLVE 0x0008 /* No user/group name resolution. */
__BEGIN_DECLS
struct au_event_ent {
au_event_t ae_number;
char *ae_name;
char *ae_desc;
au_class_t ae_class;
};
typedef struct au_event_ent au_event_ent_t;
struct au_class_ent {
char *ac_name;
au_class_t ac_class;
char *ac_desc;
};
typedef struct au_class_ent au_class_ent_t;
struct au_user_ent {
char *au_name;
au_mask_t au_always;
au_mask_t au_never;
};
typedef struct au_user_ent au_user_ent_t;
__END_DECLS
#define ADD_TO_MASK(m, c, sel) do { \
if (sel & AU_PRS_SUCCESS) \
(m)->am_success |= c; \
if (sel & AU_PRS_FAILURE) \
(m)->am_failure |= c; \
} while (0)
#define SUB_FROM_MASK(m, c, sel) do { \
if (sel & AU_PRS_SUCCESS) \
(m)->am_success &= ((m)->am_success ^ c); \
if (sel & AU_PRS_FAILURE) \
(m)->am_failure &= ((m)->am_failure ^ c); \
} while (0)
#define ADDMASK(m, v) do { \
(m)->am_success |= (v)->am_success; \
(m)->am_failure |= (v)->am_failure; \
} while(0)
#define SUBMASK(m, v) do { \
(m)->am_success &= ((m)->am_success ^ (v)->am_success); \
(m)->am_failure &= ((m)->am_failure ^ (v)->am_failure); \
} while(0)
__BEGIN_DECLS
typedef struct au_tid32 {
u_int32_t port;
u_int32_t addr;
} au_tid32_t;
typedef struct au_tid64 {
u_int64_t port;
u_int32_t addr;
} au_tid64_t;
typedef struct au_tidaddr32 {
u_int32_t port;
u_int32_t type;
u_int32_t addr[4];
} au_tidaddr32_t;
typedef struct au_tidaddr64 {
u_int64_t port;
u_int32_t type;
u_int32_t addr[4];
} au_tidaddr64_t;
/*
* argument # 1 byte
* argument value 4 bytes/8 bytes (32-bit/64-bit value)
* text length 2 bytes
* text N bytes + 1 terminating NULL byte
*/
typedef struct {
u_char no;
u_int32_t val;
u_int16_t len;
char *text;
} au_arg32_t;
typedef struct {
u_char no;
u_int64_t val;
u_int16_t len;
char *text;
} au_arg64_t;
/*
* how to print 1 byte
* basic unit 1 byte
* unit count 1 byte
* data items (depends on basic unit)
*/
typedef struct {
u_char howtopr;
u_char bu;
u_char uc;
u_char *data;
} au_arb_t;
/*
* file access mode 4 bytes
* owner user ID 4 bytes
* owner group ID 4 bytes
* file system ID 4 bytes
* node ID 8 bytes
* device 4 bytes/8 bytes (32-bit/64-bit)
*/
typedef struct {
u_int32_t mode;
u_int32_t uid;
u_int32_t gid;
u_int32_t fsid;
u_int64_t nid;
u_int32_t dev;
} au_attr32_t;
typedef struct {
u_int32_t mode;
u_int32_t uid;
u_int32_t gid;
u_int32_t fsid;
u_int64_t nid;
u_int64_t dev;
} au_attr64_t;
/*
* count 4 bytes
* text count null-terminated string(s)
*/
typedef struct {
u_int32_t count;
char *text[AUDIT_MAX_ARGS];
} au_execarg_t;
/*
* count 4 bytes
* text count null-terminated string(s)
*/
typedef struct {
u_int32_t count;
char *text[AUDIT_MAX_ENV];
} au_execenv_t;
/*
* status 4 bytes
* return value 4 bytes
*/
typedef struct {
u_int32_t status;
u_int32_t ret;
} au_exit_t;
/*
* seconds of time 4 bytes
* milliseconds of time 4 bytes
* file name length 2 bytes
* file pathname N bytes + 1 terminating NULL byte
*/
typedef struct {
u_int32_t s;
u_int32_t ms;
u_int16_t len;
char *name;
} au_file_t;
/*
* number groups 2 bytes
* group list N * 4 bytes
*/
typedef struct {
u_int16_t no;
u_int32_t list[AUDIT_MAX_GROUPS];
} au_groups_t;
/*
* record byte count 4 bytes
* version # 1 byte [2]
* event type 2 bytes
* event modifier 2 bytes
* seconds of time 4 bytes/8 bytes (32-bit/64-bit value)
* milliseconds of time 4 bytes/8 bytes (32-bit/64-bit value)
*/
typedef struct {
u_int32_t size;
u_char version;
u_int16_t e_type;
u_int16_t e_mod;
u_int32_t s;
u_int32_t ms;
} au_header32_t;
/*
* record byte count 4 bytes
* version # 1 byte [2]
* event type 2 bytes
* event modifier 2 bytes
* address type/length 1 byte (XXX: actually, 4 bytes)
* machine address 4 bytes/16 bytes (IPv4/IPv6 address)
* seconds of time 4 bytes/8 bytes (32/64-bits)
* nanoseconds of time 4 bytes/8 bytes (32/64-bits)
*/
typedef struct {
u_int32_t size;
u_char version;
u_int16_t e_type;
u_int16_t e_mod;
u_int32_t ad_type;
u_int32_t addr[4];
u_int32_t s;
u_int32_t ms;
} au_header32_ex_t;
typedef struct {
u_int32_t size;
u_char version;
u_int16_t e_type;
u_int16_t e_mod;
u_int64_t s;
u_int64_t ms;
} au_header64_t;
typedef struct {
u_int32_t size;
u_char version;
u_int16_t e_type;
u_int16_t e_mod;
u_int32_t ad_type;
u_int32_t addr[4];
u_int64_t s;
u_int64_t ms;
} au_header64_ex_t;
/*
* internet address 4 bytes
*/
typedef struct {
u_int32_t addr;
} au_inaddr_t;
/*
* type 4 bytes
* internet address 16 bytes
*/
typedef struct {
u_int32_t type;
u_int32_t addr[4];
} au_inaddr_ex_t;
/*
* version and ihl 1 byte
* type of service 1 byte
* length 2 bytes
* id 2 bytes
* offset 2 bytes
* ttl 1 byte
* protocol 1 byte
* checksum 2 bytes
* source address 4 bytes
* destination address 4 bytes
*/
typedef struct {
u_char version;
u_char tos;
u_int16_t len;
u_int16_t id;
u_int16_t offset;
u_char ttl;
u_char prot;
u_int16_t chksm;
u_int32_t src;
u_int32_t dest;
} au_ip_t;
/*
* object ID type 1 byte
* object ID 4 bytes
*/
typedef struct {
u_char type;
u_int32_t id;
} au_ipc_t;
/*
* owner user ID 4 bytes
* owner group ID 4 bytes
* creator user ID 4 bytes
* creator group ID 4 bytes
* access mode 4 bytes
* slot sequence # 4 bytes
* key 4 bytes
*/
typedef struct {
u_int32_t uid;
u_int32_t gid;
u_int32_t puid;
u_int32_t pgid;
u_int32_t mode;
u_int32_t seq;
u_int32_t key;
} au_ipcperm_t;
/*
* port IP address 2 bytes
*/
typedef struct {
u_int16_t port;
} au_iport_t;
/*
* length 2 bytes
* data length bytes
*/
typedef struct {
u_int16_t size;
char *data;
} au_opaque_t;
/*
* path length 2 bytes
* path N bytes + 1 terminating NULL byte
*/
typedef struct {
u_int16_t len;
char *path;
} au_path_t;
/*
* audit ID 4 bytes
* effective user ID 4 bytes
* effective group ID 4 bytes
* real user ID 4 bytes
* real group ID 4 bytes
* process ID 4 bytes
* session ID 4 bytes
* terminal ID
* port ID 4 bytes/8 bytes (32-bit/64-bit value)
* machine address 4 bytes
*/
typedef struct {
u_int32_t auid;
u_int32_t euid;
u_int32_t egid;
u_int32_t ruid;
u_int32_t rgid;
u_int32_t pid;
u_int32_t sid;
au_tid32_t tid;
} au_proc32_t;
typedef struct {
u_int32_t auid;
u_int32_t euid;
u_int32_t egid;
u_int32_t ruid;
u_int32_t rgid;
u_int32_t pid;
u_int32_t sid;
au_tid64_t tid;
} au_proc64_t;
/*
* audit ID 4 bytes
* effective user ID 4 bytes
* effective group ID 4 bytes
* real user ID 4 bytes
* real group ID 4 bytes
* process ID 4 bytes
* session ID 4 bytes
* terminal ID
* port ID 4 bytes/8 bytes (32-bit/64-bit value)
* type 4 bytes
* machine address 16 bytes
*/
typedef struct {
u_int32_t auid;
u_int32_t euid;
u_int32_t egid;
u_int32_t ruid;
u_int32_t rgid;
u_int32_t pid;
u_int32_t sid;
au_tidaddr32_t tid;
} au_proc32ex_t;
typedef struct {
u_int32_t auid;
u_int32_t euid;
u_int32_t egid;
u_int32_t ruid;
u_int32_t rgid;
u_int32_t pid;
u_int32_t sid;
au_tidaddr64_t tid;
} au_proc64ex_t;
/*
* error status 1 byte
* return value 4 bytes/8 bytes (32-bit/64-bit value)
*/
typedef struct {
u_char status;
u_int32_t ret;
} au_ret32_t;
typedef struct {
u_char err;
u_int64_t val;
} au_ret64_t;
/*
* sequence number 4 bytes
*/
typedef struct {
u_int32_t seqno;
} au_seq_t;
/*
* socket type 2 bytes
* local port 2 bytes
* local Internet address 4 bytes
* remote port 2 bytes
* remote Internet address 4 bytes
*/
typedef struct {
u_int16_t type;
u_int16_t l_port;
u_int32_t l_addr;
u_int16_t r_port;
u_int32_t r_addr;
} au_socket_t;
/*
* socket type 2 bytes
* local port 2 bytes
* address type/length 4 bytes
* local Internet address 4 bytes/16 bytes (IPv4/IPv6 address)
* remote port 4 bytes
* address type/length 4 bytes
* remote Internet address 4 bytes/16 bytes (IPv4/IPv6 address)
*/
typedef struct {
u_int16_t domain;
u_int16_t type;
u_int16_t atype;
u_int16_t l_port;
u_int32_t l_addr[4];
u_int32_t r_port;
u_int32_t r_addr[4];
} au_socket_ex32_t;
/*
* socket family 2 bytes
* local port 2 bytes
* socket address 4 bytes/16 bytes (IPv4/IPv6 address)
*/
typedef struct {
u_int16_t family;
u_int16_t port;
u_int32_t addr[4];
} au_socketinet_ex32_t;
typedef struct {
u_int16_t family;
u_int16_t port;
u_int32_t addr;
} au_socketinet32_t;
/*
* socket family 2 bytes
* path 104 bytes
*/
typedef struct {
u_int16_t family;
char path[104];
} au_socketunix_t;
/*
* audit ID 4 bytes
* effective user ID 4 bytes
* effective group ID 4 bytes
* real user ID 4 bytes
* real group ID 4 bytes
* process ID 4 bytes
* session ID 4 bytes
* terminal ID
* port ID 4 bytes/8 bytes (32-bit/64-bit value)
* machine address 4 bytes
*/
typedef struct {
u_int32_t auid;
u_int32_t euid;
u_int32_t egid;
u_int32_t ruid;
u_int32_t rgid;
u_int32_t pid;
u_int32_t sid;
au_tid32_t tid;
} au_subject32_t;
typedef struct {
u_int32_t auid;
u_int32_t euid;
u_int32_t egid;
u_int32_t ruid;
u_int32_t rgid;
u_int32_t pid;
u_int32_t sid;
au_tid64_t tid;
} au_subject64_t;
/*
* audit ID 4 bytes
* effective user ID 4 bytes
* effective group ID 4 bytes
* real user ID 4 bytes
* real group ID 4 bytes
* process ID 4 bytes
* session ID 4 bytes
* terminal ID
* port ID 4 bytes/8 bytes (32-bit/64-bit value)
* type 4 bytes
* machine address 16 bytes
*/
typedef struct {
u_int32_t auid;
u_int32_t euid;
u_int32_t egid;
u_int32_t ruid;
u_int32_t rgid;
u_int32_t pid;
u_int32_t sid;
au_tidaddr32_t tid;
} au_subject32ex_t;
typedef struct {
u_int32_t auid;
u_int32_t euid;
u_int32_t egid;
u_int32_t ruid;
u_int32_t rgid;
u_int32_t pid;
u_int32_t sid;
au_tidaddr64_t tid;
} au_subject64ex_t;
/*
* text length 2 bytes
* text N bytes + 1 terminating NULL byte
*/
typedef struct {
u_int16_t len;
char *text;
} au_text_t;
/*
* zonename length 2 bytes
* zonename text N bytes + 1 NULL terminator
*/
typedef struct {
u_int16_t len;
char *zonename;
} au_zonename_t;
typedef struct {
u_int32_t ident;
u_int16_t filter;
u_int16_t flags;
u_int32_t fflags;
u_int32_t data;
} au_kevent_t;
typedef struct {
u_int16_t length;
char *data;
} au_invalid_t;
/*
* trailer magic number 2 bytes
* record byte count 4 bytes
*/
typedef struct {
u_int16_t magic;
u_int32_t count;
} au_trailer_t;
struct tokenstr {
u_char id;
u_char *data;
size_t len;
union {
au_arg32_t arg32;
au_arg64_t arg64;
au_arb_t arb;
au_attr32_t attr32;
au_attr64_t attr64;
au_execarg_t execarg;
au_execenv_t execenv;
au_exit_t exit;
au_file_t file;
au_groups_t grps;
au_header32_t hdr32;
au_header32_ex_t hdr32_ex;
au_header64_t hdr64;
au_header64_ex_t hdr64_ex;
au_inaddr_t inaddr;
au_inaddr_ex_t inaddr_ex;
au_ip_t ip;
au_ipc_t ipc;
au_ipcperm_t ipcperm;
au_iport_t iport;
au_opaque_t opaque;
au_path_t path;
au_proc32_t proc32;
au_proc32ex_t proc32_ex;
au_proc64_t proc64;
au_proc64ex_t proc64_ex;
au_ret32_t ret32;
au_ret64_t ret64;
au_seq_t seq;
au_socket_t socket;
au_socket_ex32_t socket_ex32;
au_socketinet_ex32_t sockinet_ex32;
au_socketunix_t sockunix;
au_subject32_t subj32;
au_subject32ex_t subj32_ex;
au_subject64_t subj64;
au_subject64ex_t subj64_ex;
au_text_t text;
au_kevent_t kevent;
au_invalid_t invalid;
au_trailer_t trail;
au_zonename_t zonename;
} tt; /* The token is one of the above types */
};
typedef struct tokenstr tokenstr_t;
int audit_submit(short au_event, au_id_t auid,
char status, int reterr, const char *fmt, ...);
/*
* Functions relating to querying audit class information.
*/
void setauclass(void);
void endauclass(void);
struct au_class_ent *getauclassent(void);
struct au_class_ent *getauclassent_r(au_class_ent_t *class_int);
struct au_class_ent *getauclassnam(const char *name);
struct au_class_ent *getauclassnam_r(au_class_ent_t *class_int,
const char *name);
struct au_class_ent *getauclassnum(au_class_t class_number);
struct au_class_ent *getauclassnum_r(au_class_ent_t *class_int,
au_class_t class_number);
/*
* Functions relating to querying audit control information.
*/
void setac(void);
void endac(void);
int getacdir(char *name, int len);
int getacmin(int *min_val);
int getacfilesz(size_t *size_val);
int getacflg(char *auditstr, int len);
int getacna(char *auditstr, int len);
int getacpol(char *auditstr, size_t len);
int getacsflagsmask(const char *which, char *auditstr, size_t len);
int getachost(char *auditstr, size_t len);
int getacexpire(int *andflg, time_t *age, size_t *size);
int getauditflagsbin(char *auditstr, au_mask_t *masks);
int getauditflagschar(char *auditstr, au_mask_t *masks,
int verbose);
int au_preselect(au_event_t event, au_mask_t *mask_p,
int sorf, int flag);
ssize_t au_poltostr(int policy, size_t maxsize, char *buf);
int au_strtopol(const char *polstr, int *policy);
ssize_t au_sflagstostr(uint64_t flags, size_t maxsize, char *buf);
int au_strtosflags(const char *sflagsstr, uint64_t *flags);
/*
* Functions relating to querying audit event information.
*/
void setauevent(void);
void endauevent(void);
struct au_event_ent *getauevent(void);
struct au_event_ent *getauevent_r(struct au_event_ent *e);
struct au_event_ent *getauevnam(const char *name);
struct au_event_ent *getauevnam_r(struct au_event_ent *e,
const char *name);
struct au_event_ent *getauevnum(au_event_t event_number);
struct au_event_ent *getauevnum_r(struct au_event_ent *e,
au_event_t event_number);
au_event_t *getauevnonam(const char *event_name);
au_event_t *getauevnonam_r(au_event_t *ev,
const char *event_name);
/*
* Functions relating to querying audit user information.
*/
void setauuser(void);
void endauuser(void);
struct au_user_ent *getauuserent(void);
struct au_user_ent *getauuserent_r(struct au_user_ent *u);
struct au_user_ent *getauusernam(const char *name);
struct au_user_ent *getauusernam_r(struct au_user_ent *u,
const char *name);
int au_user_mask(char *username, au_mask_t *mask_p);
int getfauditflags(au_mask_t *usremask,
au_mask_t *usrdmask, au_mask_t *lastmask);
/*
* Functions for reading and printing records and tokens from audit trails.
*/
int au_read_rec(FILE *fp, u_char **buf);
int au_fetch_tok(tokenstr_t *tok, u_char *buf, int len);
//XXX The following interface has different prototype from BSM
void au_print_tok(FILE *outfp, tokenstr_t *tok,
char *del, char raw, char sfrm);
void au_print_flags_tok(FILE *outfp, tokenstr_t *tok,
char *del, int oflags);
void au_print_tok_xml(FILE *outfp, tokenstr_t *tok,
char *del, char raw, char sfrm);
/*
* Functions relating to XML output.
*/
void au_print_xml_header(FILE *outfp);
void au_print_xml_footer(FILE *outfp);
/*
* BSM library routines for converting between local and BSM constant spaces.
* (Note: some of these are replicated in audit_record.h for the benefit of
* the FreeBSD and Mac OS X kernels)
*/
int au_bsm_to_domain(u_short bsm_domain, int *local_domainp);
int au_bsm_to_errno(u_char bsm_error, int *errorp);
int au_bsm_to_fcntl_cmd(u_short bsm_fcntl_cmd, int *local_fcntl_cmdp);
int au_bsm_to_socket_type(u_short bsm_socket_type,
int *local_socket_typep);
u_short au_domain_to_bsm(int local_domain);
u_char au_errno_to_bsm(int local_errno);
u_short au_fcntl_cmd_to_bsm(int local_fcntl_command);
u_short au_socket_type_to_bsm(int local_socket_type);
const char *au_strerror(u_char bsm_error);
__END_DECLS
/*
* The remaining APIs are associated with Apple's BSM implementation, in
* particular as relates to Mach IPC auditing and triggers passed via Mach
* IPC.
*/
#ifdef __APPLE__
#include <sys/appleapiopts.h>
/**************************************************************************
**************************************************************************
** The following definitions, functions, etc., are NOT officially
** supported: they may be changed or removed in the future. Do not use
** them unless you are prepared to cope with that eventuality.
**************************************************************************
**************************************************************************/
#ifdef __APPLE_API_PRIVATE
#define __BSM_INTERNAL_NOTIFY_KEY "com.apple.audit.change"
#endif /* __APPLE_API_PRIVATE */
/*
* au_get_state() return values
* XXX use AUC_* values directly instead (<bsm/audit.h>); AUDIT_OFF and
* AUDIT_ON are deprecated and WILL be removed.
*/
#ifdef __APPLE_API_PRIVATE
#define AUDIT_OFF AUC_NOAUDIT
#define AUDIT_ON AUC_AUDITING
#endif /* __APPLE_API_PRIVATE */
#endif /* !__APPLE__ */
/*
* Error return codes for audit_set_terminal_id_ex(), audit_write() and its
* brethren. We have 255 (not including kAUNoErr) to play with.
*
* XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE.
*/
enum {
kAUNoErr = 0,
kAUBadParamErr = -66049,
kAUStatErr,
kAUSysctlErr,
kAUOpenErr,
kAUMakeSubjectTokErr,
kAUWriteSubjectTokErr,
kAUWriteCallerTokErr,
kAUMakeReturnTokErr,
kAUWriteReturnTokErr,
kAUCloseErr,
kAUMakeTextTokErr,
kAULastErr
};
#ifdef __APPLE__
/*
* Error return codes for au_get_state() and/or its private support
* functions. These codes are designed to be compatible with the
* NOTIFY_STATUS_* codes defined in <notify.h> but non-overlapping.
* Any changes to notify(3) may cause these values to change in future.
*
* AU_UNIMPL should never happen unless you've changed your system software
* without rebooting. Shame on you.
*/
#ifdef __APPLE_API_PRIVATE
#define AU_UNIMPL NOTIFY_STATUS_FAILED + 1 /* audit unimplemented */
#endif /* __APPLE_API_PRIVATE */
#endif /* !__APPLE__ */
__BEGIN_DECLS
/*
* XXX This prototype should be in audit_record.h
*
* au_free_token()
*
* @summary - au_free_token() deallocates a token_t created by any of
* the au_to_*() BSM API functions.
*
* The BSM API generally manages deallocation of token_t objects. However,
* if au_write() is passed a bad audit descriptor, the token_t * parameter
* will be left untouched. In that case, the caller can deallocate the
* token_t using au_free_token() if desired. This is, in fact, what
* audit_write() does, in keeping with the existing memory management model
* of the BSM API.
*
* @param tok - A token_t * generated by one of the au_to_*() BSM API
* calls. For convenience, tok may be NULL, in which case
* au_free_token() returns immediately.
*
* XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE.
*/
void au_free_token(token_t *tok);
/*
* Lightweight check to determine if auditing is enabled. If a client
* wants to use this to govern whether an entire series of audit calls
* should be made--as in the common case of a caller building a set of
* tokens, then writing them--it should cache the audit status in a local
* variable. This call always returns the current state of auditing.
*
* @return - AUC_AUDITING or AUC_NOAUDIT if no error occurred.
* Otherwise the function can return any of the errno values defined for
* setaudit(2), or AU_UNIMPL if audit does not appear to be supported by
* the system.
*
* XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE.
*/
int au_get_state(void);
/*
* Initialize the audit notification. If it has not already been initialized
* it will automatically on the first call of au_get_state().
*/
uint32_t au_notify_initialize(void);
/*
* Cancel audit notification and free the resources associated with it.
* Responsible code that no longer needs to use au_get_state() should call
* this.
*/
int au_notify_terminate(void);
__END_DECLS
/* OpenSSH compatibility */
int cannot_audit(int);
__BEGIN_DECLS
/*