]> git.saurik.com Git - apple/xnu.git/blame - bsd/bsm/audit.h
xnu-792.18.15.tar.gz
[apple/xnu.git] / bsd / bsm / audit.h
CommitLineData
e5568f75 1/*
89b3af67 2 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
e5568f75 3 *
89b3af67
A
4 * This file contains Original Code and/or Modifications of Original Code
5 * as defined in and that are subject to the Apple Public Source License
6 * Version 2.0 (the 'License'). You may not use this file except in
7 * compliance with the License. The rights granted to you under the License
8 * may not be used to create, or enable the creation or redistribution of,
9 * unlawful or unlicensed copies of an Apple operating system, or to
10 * circumvent, violate, or enable the circumvention or violation of, any
11 * terms of an Apple operating system software license agreement.
37839358 12 *
89b3af67
A
13 * Please obtain a copy of the License at
14 * http://www.opensource.apple.com/apsl/ and read it before using this file.
8f6c56a5 15 *
89b3af67
A
16 * The Original Code and all software distributed under the License are
17 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
18 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
19 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
21 * Please see the License for the specific language governing rights and
22 * limitations under the License.
8f6c56a5 23 *
89b3af67 24 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
e5568f75
A
25 */
26
27#ifndef _BSM_AUDIT_H
28#define _BSM_AUDIT_H
29
30#include <sys/queue.h>
91447636 31#include <sys/types.h>
e5568f75 32#include <sys/param.h>
e5568f75
A
33#include <sys/socket.h>
34#include <sys/cdefs.h>
35
36#define AUDIT_RECORD_MAGIC 0x828a0f1b
37#define MAX_AUDIT_RECORDS 20
38#define MAX_AUDIT_RECORD_SIZE 4096
39#define MIN_AUDIT_FILE_SIZE 512 * 1024
40
41/*
42 * Triggers for the audit daemon
43 */
44#define AUDIT_TRIGGER_LOW_SPACE 1
45#define AUDIT_TRIGGER_FILE_FULL 2
46
47/*
48 * Pre-defined audit IDs
49 */
91447636 50#define AU_DEFAUDITID ((uid_t)-1)
e5568f75
A
51
52/*
53 * Define the masks for the classes of audit events.
54 */
55#define AU_NULL 0x00000000
56#define AU_FREAD 0x00000001
57#define AU_FWRITE 0x00000002
58#define AU_FACCESS 0x00000004
59#define AU_FMODIFY 0x00000008
60#define AU_FCREATE 0x00000010
61#define AU_FDELETE 0x00000020
62#define AU_CLOSE 0x00000040
63#define AU_PROCESS 0x00000080
64#define AU_NET 0x00000100
65#define AU_IPC 0x00000200
66#define AU_NONAT 0x00000400
67#define AU_ADMIN 0x00000800
68#define AU_LOGIN 0x00001000
69#define AU_TFM 0x00002000
70#define AU_APPL 0x00004000
71#define AU_SETL 0x00008000
72#define AU_IFLOAT 0x00010000
73#define AU_PRIV 0x00020000
74#define AU_MAC_RW 0x00040000
75#define AU_XCONN 0x00080000
76#define AU_XCREATE 0x00100000
77#define AU_XDELETE 0x00200000
78#define AU_XIFLOAT 0x00400000
79#define AU_XPRIVS 0x00800000
80#define AU_XPRIVF 0x01000000
81#define AU_XMOVE 0x02000000
82#define AU_XDACF 0x04000000
83#define AU_XMACF 0x08000000
84#define AU_XSECATTR 0x10000000
85#define AU_IOCTL 0x20000000
86#define AU_EXEC 0x40000000
87#define AU_OTHER 0x80000000
88#define AU_ALL 0xffffffff
89
90/*
91 * IPC types
92 */
93#define AT_IPC_MSG ((u_char)1) /* message IPC id */
94#define AT_IPC_SEM ((u_char)2) /* semaphore IPC id */
95#define AT_IPC_SHM ((u_char)3) /* shared mem IPC id */
96
97/*
98 * Audit conditions.
99 */
100#define AUC_UNSET 0
101#define AUC_AUDITING 1
102#define AUC_NOAUDIT 2
103#define AUC_DISABLED -1
104
105/*
106 * auditon(2) commands.
107 */
108#define A_GETPOLICY 2
109#define A_SETPOLICY 3
110#define A_GETKMASK 4
111#define A_SETKMASK 5
112#define A_GETQCTRL 6
113#define A_SETQCTRL 7
114#define A_GETCWD 8
115#define A_GETCAR 9
116#define A_GETSTAT 12
117#define A_SETSTAT 13
118#define A_SETUMASK 14
119#define A_SETSMASK 15
120#define A_GETCOND 20
121#define A_SETCOND 21
122#define A_GETCLASS 22
123#define A_SETCLASS 23
124#define A_GETPINFO 24
125#define A_SETPMASK 25
126#define A_SETFSIZE 26
127#define A_GETFSIZE 27
128#define A_GETPINFO_ADDR 28
129#define A_GETKAUDIT 29
130#define A_SETKAUDIT 30
131
132/*
133 * Audit policy controls.
134 */
135#define AUDIT_CNT 0x0001
136#define AUDIT_AHLT 0x0002
137#define AUDIT_ARGV 0x0004
138#define AUDIT_ARGE 0x0008
139#define AUDIT_PASSWD 0x0010
140#define AUDIT_SEQ 0x0020
141#define AUDIT_WINDATA 0x0040
142#define AUDIT_USER 0x0080
143#define AUDIT_GROUP 0x0100
144#define AUDIT_TRAIL 0x0200
145#define AUDIT_PATH 0x0400
146
147/*
148 * Audit queue control parameters
149 */
150#define AQ_HIWATER 100
151#define AQ_MAXHIGH 10000
152#define AQ_LOWATER 10
153#define AQ_BUFSZ 1024
154#define AQ_MAXBUFSZ 1048576
155
156#define AU_FS_MINFREE 20 /* default min filesystem freespace, in percent */
157
158__BEGIN_DECLS
159
160typedef uid_t au_id_t;
161typedef pid_t au_asid_t;
162typedef u_int16_t au_event_t;
163typedef u_int16_t au_emod_t;
164typedef u_int32_t au_class_t;
165
166struct au_tid {
167 dev_t port;
168 u_int32_t machine;
169};
170typedef struct au_tid au_tid_t;
171
172struct au_tid_addr {
173 dev_t at_port;
174 u_int32_t at_type;
175 u_int32_t at_addr[4];
176};
177typedef struct au_tid_addr au_tid_addr_t;
178
179struct au_mask {
180 unsigned int am_success; /* success bits */
181 unsigned int am_failure; /* failure bits */
182};
183typedef struct au_mask au_mask_t;
184
185struct auditinfo {
186 au_id_t ai_auid; /* Audit user ID */
187 au_mask_t ai_mask; /* Audit masks */
188 au_tid_t ai_termid; /* Terminal ID */
189 au_asid_t ai_asid; /* Audit session ID */
190};
191typedef struct auditinfo auditinfo_t;
192
193struct auditinfo_addr {
194 au_id_t ai_auid; /* Audit user ID */
195 au_mask_t ai_mask; /* Audit masks */
196 au_tid_addr_t ai_termid; /* Terminal ID */
197 au_asid_t ai_asid; /* Audit session ID */
198};
199typedef struct auditinfo_addr auditinfo_addr_t;
200
201struct auditpinfo {
202 pid_t ap_pid; /* ID of target process */
203 au_id_t ap_auid; /* Audit user ID */
204 au_mask_t ap_mask; /* Audit masks */
205 au_tid_t ap_termid; /* Terminal ID */
206 au_asid_t ap_asid; /* Audit session ID */
207};
208typedef struct auditpinfo auditpinfo_t;
209
210struct auditpinfo_addr {
211 pid_t ap_pid; /* ID of target process */
212 au_id_t ap_auid; /* Audit user ID */
213 au_mask_t ap_mask; /* Audit masks */
214 au_tid_addr_t ap_termid; /* Terminal ID */
215 au_asid_t ap_asid; /* Audit session ID */
216};
217typedef struct auditpinfo_addr auditpinfo_addr_t;
218
219/* Token and record structures */
220
221struct au_token {
222 u_char *t_data;
223 size_t len;
224 TAILQ_ENTRY(au_token) tokens;
225};
226typedef struct au_token token_t;
227
228struct au_record {
229 char used; /* Is this record currently being used */
230 int desc; /* The descriptor associated with this record */
231 TAILQ_HEAD(, au_token) token_q; /* queue of BSM tokens */
232 u_char *data;
233 size_t len;
234 LIST_ENTRY(au_record) au_rec_q;
235};
236typedef struct au_record au_record_t;
237
238/*
239 * Kernel audit queue control parameters.
240 */
241struct au_qctrl {
242 size_t aq_hiwater;
243 size_t aq_lowater;
244 size_t aq_bufsz;
245 clock_t aq_delay;
246 int aq_minfree; /* minimum filesystem percent free space */
247};
248typedef struct au_qctrl au_qctrl_t;
249
250/*
251 * Structure for the audit statistics.
252 */
253struct audit_stat {
254 unsigned int as_version;
255 unsigned int as_numevent;
256 int as_generated;
257 int as_nonattring;
258 int as_kernel;
259 int as_audit;
260 int as_auditctl;
261 int as_enqueu;
262 int as_written;
263 int as_wblocked;
264 int as_rblocked;
265 int as_dropped;
266 int as_totalsize;
267 unsigned int as_memused;
268};
269typedef struct audit_stat au_stat_t;
270
271/*
272 * Structure for the audit file statistics.
273 */
274struct audit_fstat {
275 u_quad_t af_filesz;
276 u_quad_t af_currsz;
277};
278typedef struct audit_fstat au_fstat_t;
279
280/*
281 * Audit to event class mapping.
282 */
283struct au_evclass_map {
284 au_event_t ec_number;
285 au_class_t ec_class;
286};
287typedef struct au_evclass_map au_evclass_map_t;
288
289#ifndef KERNEL
290
291int audit (const void *, int);
292int auditon (int, void *, int);
293int auditctl (const char *);
294int getauid (au_id_t *);
295int setauid (const au_id_t *);
296int getaudit (struct auditinfo *);
297int setaudit (const struct auditinfo *);
298int getaudit_addr (struct auditinfo_addr *, int);
299int setaudit_addr (const struct auditinfo_addr *, int);
300#endif /* !KERNEL */
301
302__END_DECLS
303
304#endif /* !_BSM_AUDIT_H */