Deleted Added
full compact
audit.h (187214) audit.h (189279)
1/*-
2 * Copyright (c) 2005 Apple Inc.
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 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of Apple Inc. ("Apple") nor the names of
15 * its contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
1/*-
2 * Copyright (c) 2005 Apple Inc.
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 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of Apple Inc. ("Apple") nor the names of
15 * its contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * P4: //depot/projects/trustedbsd/openbsm/sys/bsm/audit.h#4
30 * $FreeBSD: head/sys/bsm/audit.h 187214 2009-01-14 10:44:16Z rwatson $
29 * P4: //depot/projects/trustedbsd/openbsm/sys/bsm/audit.h#5
30 * $FreeBSD: head/sys/bsm/audit.h 189279 2009-03-02 13:29:18Z rwatson $
31 */
32
33#ifndef _BSM_AUDIT_H
34#define _BSM_AUDIT_H
35
36#ifdef __APPLE__
37/* Temporary until rdar://problem/6133383 is resolved. */
38#include <sys/types.h>
39#include <sys/param.h>
40#include <sys/socket.h>
41#include <sys/cdefs.h>
42#include <sys/queue.h>
43#endif /* __APPLE__ */
44
45#define AUDIT_RECORD_MAGIC 0x828a0f1b
46#define MAX_AUDIT_RECORDS 20
47#define MAXAUDITDATA (0x8000 - 1)
48#define MAX_AUDIT_RECORD_SIZE MAXAUDITDATA
49#define MIN_AUDIT_FILE_SIZE (512 * 1024)
50
51/*
52 * Minimum noumber of free blocks on the filesystem containing the audit
53 * log necessary to avoid a hard log rotation. DO NOT SET THIS VALUE TO 0
54 * as the kernel does an unsigned compare, plus we want to leave a few blocks
55 * free so userspace can terminate the log, etc.
56 */
57#define AUDIT_HARD_LIMIT_FREE_BLOCKS 4
58
59/*
60 * Triggers for the audit daemon.
61 */
62#define AUDIT_TRIGGER_MIN 1
63#define AUDIT_TRIGGER_LOW_SPACE 1 /* Below low watermark. */
64#define AUDIT_TRIGGER_ROTATE_KERNEL 2 /* Kernel requests rotate. */
65#define AUDIT_TRIGGER_READ_FILE 3 /* Re-read config file. */
66#define AUDIT_TRIGGER_CLOSE_AND_DIE 4 /* Terminate audit. */
67#define AUDIT_TRIGGER_NO_SPACE 5 /* Below min free space. */
68#define AUDIT_TRIGGER_ROTATE_USER 6 /* User requests rotate. */
31 */
32
33#ifndef _BSM_AUDIT_H
34#define _BSM_AUDIT_H
35
36#ifdef __APPLE__
37/* Temporary until rdar://problem/6133383 is resolved. */
38#include <sys/types.h>
39#include <sys/param.h>
40#include <sys/socket.h>
41#include <sys/cdefs.h>
42#include <sys/queue.h>
43#endif /* __APPLE__ */
44
45#define AUDIT_RECORD_MAGIC 0x828a0f1b
46#define MAX_AUDIT_RECORDS 20
47#define MAXAUDITDATA (0x8000 - 1)
48#define MAX_AUDIT_RECORD_SIZE MAXAUDITDATA
49#define MIN_AUDIT_FILE_SIZE (512 * 1024)
50
51/*
52 * Minimum noumber of free blocks on the filesystem containing the audit
53 * log necessary to avoid a hard log rotation. DO NOT SET THIS VALUE TO 0
54 * as the kernel does an unsigned compare, plus we want to leave a few blocks
55 * free so userspace can terminate the log, etc.
56 */
57#define AUDIT_HARD_LIMIT_FREE_BLOCKS 4
58
59/*
60 * Triggers for the audit daemon.
61 */
62#define AUDIT_TRIGGER_MIN 1
63#define AUDIT_TRIGGER_LOW_SPACE 1 /* Below low watermark. */
64#define AUDIT_TRIGGER_ROTATE_KERNEL 2 /* Kernel requests rotate. */
65#define AUDIT_TRIGGER_READ_FILE 3 /* Re-read config file. */
66#define AUDIT_TRIGGER_CLOSE_AND_DIE 4 /* Terminate audit. */
67#define AUDIT_TRIGGER_NO_SPACE 5 /* Below min free space. */
68#define AUDIT_TRIGGER_ROTATE_USER 6 /* User requests rotate. */
69#define AUDIT_TRIGGER_INITIALIZE 7 /* Initialize audit. */
70#define AUDIT_TRIGGER_MAX 7
69#define AUDIT_TRIGGER_INITIALIZE 7 /* User initialize of auditd. */
70#define AUDIT_TRIGGER_EXPIRE_TRAILS 8 /* User expiration of trails. */
71#define AUDIT_TRIGGER_MAX 8
71
72/*
73 * The special device filename (FreeBSD).
74 */
75#define AUDITDEV_FILENAME "audit"
76#define AUDIT_TRIGGER_FILE ("/dev/" AUDITDEV_FILENAME)
77
78/*
79 * Pre-defined audit IDs
80 */
81#define AU_DEFAUDITID (uid_t)(-1)
82#define AU_DEFAUDITSID 0
83#define AU_ASSIGN_ASID -1
84
85/*
86 * IPC types.
87 */
88#define AT_IPC_MSG ((u_char)1) /* Message IPC id. */
89#define AT_IPC_SEM ((u_char)2) /* Semaphore IPC id. */
90#define AT_IPC_SHM ((u_char)3) /* Shared mem IPC id. */
91
92/*
93 * Audit conditions.
94 */
95#define AUC_UNSET 0
96#define AUC_AUDITING 1
97#define AUC_NOAUDIT 2
98#define AUC_DISABLED -1
99
100/*
101 * auditon(2) commands.
102 */
103#define A_GETPOLICY 2
104#define A_SETPOLICY 3
105#define A_GETKMASK 4
106#define A_SETKMASK 5
107#define A_GETQCTRL 6
108#define A_SETQCTRL 7
109#define A_GETCWD 8
110#define A_GETCAR 9
111#define A_GETSTAT 12
112#define A_SETSTAT 13
113#define A_SETUMASK 14
114#define A_SETSMASK 15
115#define A_GETCOND 20
116#define A_SETCOND 21
117#define A_GETCLASS 22
118#define A_SETCLASS 23
119#define A_GETPINFO 24
120#define A_SETPMASK 25
121#define A_SETFSIZE 26
122#define A_GETFSIZE 27
123#define A_GETPINFO_ADDR 28
124#define A_GETKAUDIT 29
125#define A_SETKAUDIT 30
126#define A_SENDTRIGGER 31
127#define A_GETSINFO_ADDR 32
128
129/*
130 * Audit policy controls.
131 */
132#define AUDIT_CNT 0x0001
133#define AUDIT_AHLT 0x0002
134#define AUDIT_ARGV 0x0004
135#define AUDIT_ARGE 0x0008
136#define AUDIT_SEQ 0x0010
137#define AUDIT_WINDATA 0x0020
138#define AUDIT_USER 0x0040
139#define AUDIT_GROUP 0x0080
140#define AUDIT_TRAIL 0x0100
141#define AUDIT_PATH 0x0200
142#define AUDIT_SCNT 0x0400
143#define AUDIT_PUBLIC 0x0800
144#define AUDIT_ZONENAME 0x1000
145#define AUDIT_PERZONE 0x2000
146
147/*
148 * Default audit queue control parameters.
149 */
150#define AQ_HIWATER 100
151#define AQ_MAXHIGH 10000
152#define AQ_LOWATER 10
153#define AQ_BUFSZ MAXAUDITDATA
154#define AQ_MAXBUFSZ 1048576
155
156/*
157 * Default minimum percentage free space on file system.
158 */
159#define AU_FS_MINFREE 20
160
161/*
162 * Type definitions used indicating the length of variable length addresses
163 * in tokens containing addresses, such as header fields.
164 */
165#define AU_IPv4 4
166#define AU_IPv6 16
167
168__BEGIN_DECLS
169
170typedef uid_t au_id_t;
171typedef pid_t au_asid_t;
172typedef u_int16_t au_event_t;
173typedef u_int16_t au_emod_t;
174typedef u_int32_t au_class_t;
175
176struct au_tid {
177 dev_t port;
178 u_int32_t machine;
179};
180typedef struct au_tid au_tid_t;
181
182struct au_tid_addr {
183 dev_t at_port;
184 u_int32_t at_type;
185 u_int32_t at_addr[4];
186};
187typedef struct au_tid_addr au_tid_addr_t;
188
189struct au_mask {
190 unsigned int am_success; /* Success bits. */
191 unsigned int am_failure; /* Failure bits. */
192};
193typedef struct au_mask au_mask_t;
194
195struct auditinfo {
196 au_id_t ai_auid; /* Audit user ID. */
197 au_mask_t ai_mask; /* Audit masks. */
198 au_tid_t ai_termid; /* Terminal ID. */
199 au_asid_t ai_asid; /* Audit session ID. */
200};
201typedef struct auditinfo auditinfo_t;
202
203struct auditinfo_addr {
204 au_id_t ai_auid; /* Audit user ID. */
205 au_mask_t ai_mask; /* Audit masks. */
206 au_tid_addr_t ai_termid; /* Terminal ID. */
207 au_asid_t ai_asid; /* Audit session ID. */
208 u_int64_t ai_flags; /* Audit session flags. */
209};
210typedef struct auditinfo_addr auditinfo_addr_t;
211
212struct auditpinfo {
213 pid_t ap_pid; /* ID of target process. */
214 au_id_t ap_auid; /* Audit user ID. */
215 au_mask_t ap_mask; /* Audit masks. */
216 au_tid_t ap_termid; /* Terminal ID. */
217 au_asid_t ap_asid; /* Audit session ID. */
218 u_int64_t ap_flags; /* Audit session flags. */
219};
220typedef struct auditpinfo auditpinfo_t;
221
222struct auditpinfo_addr {
223 pid_t ap_pid; /* ID of target process. */
224 au_id_t ap_auid; /* Audit user ID. */
225 au_mask_t ap_mask; /* Audit masks. */
226 au_tid_addr_t ap_termid; /* Terminal ID. */
227 au_asid_t ap_asid; /* Audit session ID. */
228};
229typedef struct auditpinfo_addr auditpinfo_addr_t;
230
231struct au_session {
232 auditinfo_addr_t *as_aia_p; /* Ptr to full audit info. */
233#define as_asid as_aia_p->ai_asid
234#define as_auid as_aia_p->ai_auid
235#define as_termid as_aia_p->ai_termid
236
237 au_mask_t as_mask; /* Process Audit Masks. */
238};
239typedef struct au_session au_session_t;
240
241/*
242 * Contents of token_t are opaque outside of libbsm.
243 */
244typedef struct au_token token_t;
245
246/*
247 * Kernel audit queue control parameters.
248 */
249struct au_qctrl {
250 size_t aq_hiwater;
251 size_t aq_lowater;
252 size_t aq_bufsz;
253 clock_t aq_delay;
254 int aq_minfree; /* Minimum filesystem percent free space. */
255};
256typedef struct au_qctrl au_qctrl_t;
257
258/*
259 * Structure for the audit statistics.
260 */
261struct audit_stat {
262 unsigned int as_version;
263 unsigned int as_numevent;
264 int as_generated;
265 int as_nonattrib;
266 int as_kernel;
267 int as_audit;
268 int as_auditctl;
269 int as_enqueue;
270 int as_written;
271 int as_wblocked;
272 int as_rblocked;
273 int as_dropped;
274 int as_totalsize;
275 unsigned int as_memused;
276};
277typedef struct audit_stat au_stat_t;
278
279/*
280 * Structure for the audit file statistics.
281 */
282struct audit_fstat {
283 u_int64_t af_filesz;
284 u_int64_t af_currsz;
285};
286typedef struct audit_fstat au_fstat_t;
287
288/*
289 * Audit to event class mapping.
290 */
291struct au_evclass_map {
292 au_event_t ec_number;
293 au_class_t ec_class;
294};
295typedef struct au_evclass_map au_evclass_map_t;
296
297/*
298 * Audit system calls.
299 */
300#if !defined(_KERNEL) && !defined(KERNEL)
301int audit(const void *, int);
302int auditon(int, void *, int);
303int auditctl(const char *);
304int getauid(au_id_t *);
305int setauid(const au_id_t *);
306int getaudit(struct auditinfo *);
307int setaudit(const struct auditinfo *);
308int getaudit_addr(struct auditinfo_addr *, int);
309int setaudit_addr(const struct auditinfo_addr *, int);
310#endif /* defined(_KERNEL) || defined(KERNEL) */
311
312__END_DECLS
313
314#endif /* !_BSM_AUDIT_H */
72
73/*
74 * The special device filename (FreeBSD).
75 */
76#define AUDITDEV_FILENAME "audit"
77#define AUDIT_TRIGGER_FILE ("/dev/" AUDITDEV_FILENAME)
78
79/*
80 * Pre-defined audit IDs
81 */
82#define AU_DEFAUDITID (uid_t)(-1)
83#define AU_DEFAUDITSID 0
84#define AU_ASSIGN_ASID -1
85
86/*
87 * IPC types.
88 */
89#define AT_IPC_MSG ((u_char)1) /* Message IPC id. */
90#define AT_IPC_SEM ((u_char)2) /* Semaphore IPC id. */
91#define AT_IPC_SHM ((u_char)3) /* Shared mem IPC id. */
92
93/*
94 * Audit conditions.
95 */
96#define AUC_UNSET 0
97#define AUC_AUDITING 1
98#define AUC_NOAUDIT 2
99#define AUC_DISABLED -1
100
101/*
102 * auditon(2) commands.
103 */
104#define A_GETPOLICY 2
105#define A_SETPOLICY 3
106#define A_GETKMASK 4
107#define A_SETKMASK 5
108#define A_GETQCTRL 6
109#define A_SETQCTRL 7
110#define A_GETCWD 8
111#define A_GETCAR 9
112#define A_GETSTAT 12
113#define A_SETSTAT 13
114#define A_SETUMASK 14
115#define A_SETSMASK 15
116#define A_GETCOND 20
117#define A_SETCOND 21
118#define A_GETCLASS 22
119#define A_SETCLASS 23
120#define A_GETPINFO 24
121#define A_SETPMASK 25
122#define A_SETFSIZE 26
123#define A_GETFSIZE 27
124#define A_GETPINFO_ADDR 28
125#define A_GETKAUDIT 29
126#define A_SETKAUDIT 30
127#define A_SENDTRIGGER 31
128#define A_GETSINFO_ADDR 32
129
130/*
131 * Audit policy controls.
132 */
133#define AUDIT_CNT 0x0001
134#define AUDIT_AHLT 0x0002
135#define AUDIT_ARGV 0x0004
136#define AUDIT_ARGE 0x0008
137#define AUDIT_SEQ 0x0010
138#define AUDIT_WINDATA 0x0020
139#define AUDIT_USER 0x0040
140#define AUDIT_GROUP 0x0080
141#define AUDIT_TRAIL 0x0100
142#define AUDIT_PATH 0x0200
143#define AUDIT_SCNT 0x0400
144#define AUDIT_PUBLIC 0x0800
145#define AUDIT_ZONENAME 0x1000
146#define AUDIT_PERZONE 0x2000
147
148/*
149 * Default audit queue control parameters.
150 */
151#define AQ_HIWATER 100
152#define AQ_MAXHIGH 10000
153#define AQ_LOWATER 10
154#define AQ_BUFSZ MAXAUDITDATA
155#define AQ_MAXBUFSZ 1048576
156
157/*
158 * Default minimum percentage free space on file system.
159 */
160#define AU_FS_MINFREE 20
161
162/*
163 * Type definitions used indicating the length of variable length addresses
164 * in tokens containing addresses, such as header fields.
165 */
166#define AU_IPv4 4
167#define AU_IPv6 16
168
169__BEGIN_DECLS
170
171typedef uid_t au_id_t;
172typedef pid_t au_asid_t;
173typedef u_int16_t au_event_t;
174typedef u_int16_t au_emod_t;
175typedef u_int32_t au_class_t;
176
177struct au_tid {
178 dev_t port;
179 u_int32_t machine;
180};
181typedef struct au_tid au_tid_t;
182
183struct au_tid_addr {
184 dev_t at_port;
185 u_int32_t at_type;
186 u_int32_t at_addr[4];
187};
188typedef struct au_tid_addr au_tid_addr_t;
189
190struct au_mask {
191 unsigned int am_success; /* Success bits. */
192 unsigned int am_failure; /* Failure bits. */
193};
194typedef struct au_mask au_mask_t;
195
196struct auditinfo {
197 au_id_t ai_auid; /* Audit user ID. */
198 au_mask_t ai_mask; /* Audit masks. */
199 au_tid_t ai_termid; /* Terminal ID. */
200 au_asid_t ai_asid; /* Audit session ID. */
201};
202typedef struct auditinfo auditinfo_t;
203
204struct auditinfo_addr {
205 au_id_t ai_auid; /* Audit user ID. */
206 au_mask_t ai_mask; /* Audit masks. */
207 au_tid_addr_t ai_termid; /* Terminal ID. */
208 au_asid_t ai_asid; /* Audit session ID. */
209 u_int64_t ai_flags; /* Audit session flags. */
210};
211typedef struct auditinfo_addr auditinfo_addr_t;
212
213struct auditpinfo {
214 pid_t ap_pid; /* ID of target process. */
215 au_id_t ap_auid; /* Audit user ID. */
216 au_mask_t ap_mask; /* Audit masks. */
217 au_tid_t ap_termid; /* Terminal ID. */
218 au_asid_t ap_asid; /* Audit session ID. */
219 u_int64_t ap_flags; /* Audit session flags. */
220};
221typedef struct auditpinfo auditpinfo_t;
222
223struct auditpinfo_addr {
224 pid_t ap_pid; /* ID of target process. */
225 au_id_t ap_auid; /* Audit user ID. */
226 au_mask_t ap_mask; /* Audit masks. */
227 au_tid_addr_t ap_termid; /* Terminal ID. */
228 au_asid_t ap_asid; /* Audit session ID. */
229};
230typedef struct auditpinfo_addr auditpinfo_addr_t;
231
232struct au_session {
233 auditinfo_addr_t *as_aia_p; /* Ptr to full audit info. */
234#define as_asid as_aia_p->ai_asid
235#define as_auid as_aia_p->ai_auid
236#define as_termid as_aia_p->ai_termid
237
238 au_mask_t as_mask; /* Process Audit Masks. */
239};
240typedef struct au_session au_session_t;
241
242/*
243 * Contents of token_t are opaque outside of libbsm.
244 */
245typedef struct au_token token_t;
246
247/*
248 * Kernel audit queue control parameters.
249 */
250struct au_qctrl {
251 size_t aq_hiwater;
252 size_t aq_lowater;
253 size_t aq_bufsz;
254 clock_t aq_delay;
255 int aq_minfree; /* Minimum filesystem percent free space. */
256};
257typedef struct au_qctrl au_qctrl_t;
258
259/*
260 * Structure for the audit statistics.
261 */
262struct audit_stat {
263 unsigned int as_version;
264 unsigned int as_numevent;
265 int as_generated;
266 int as_nonattrib;
267 int as_kernel;
268 int as_audit;
269 int as_auditctl;
270 int as_enqueue;
271 int as_written;
272 int as_wblocked;
273 int as_rblocked;
274 int as_dropped;
275 int as_totalsize;
276 unsigned int as_memused;
277};
278typedef struct audit_stat au_stat_t;
279
280/*
281 * Structure for the audit file statistics.
282 */
283struct audit_fstat {
284 u_int64_t af_filesz;
285 u_int64_t af_currsz;
286};
287typedef struct audit_fstat au_fstat_t;
288
289/*
290 * Audit to event class mapping.
291 */
292struct au_evclass_map {
293 au_event_t ec_number;
294 au_class_t ec_class;
295};
296typedef struct au_evclass_map au_evclass_map_t;
297
298/*
299 * Audit system calls.
300 */
301#if !defined(_KERNEL) && !defined(KERNEL)
302int audit(const void *, int);
303int auditon(int, void *, int);
304int auditctl(const char *);
305int getauid(au_id_t *);
306int setauid(const au_id_t *);
307int getaudit(struct auditinfo *);
308int setaudit(const struct auditinfo *);
309int getaudit_addr(struct auditinfo_addr *, int);
310int setaudit_addr(const struct auditinfo_addr *, int);
311#endif /* defined(_KERNEL) || defined(KERNEL) */
312
313__END_DECLS
314
315#endif /* !_BSM_AUDIT_H */