]> git.saurik.com Git - apple/xnu.git/blame - bsd/man/man4/auditpipe.4
xnu-3789.70.16.tar.gz
[apple/xnu.git] / bsd / man / man4 / auditpipe.4
CommitLineData
b0d623f7
A
1.\" Copyright (c) 2006 Robert N. M. Watson
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\" $FreeBSD: src/share/man/man4/auditpipe.4,v 1.6 2008/05/02 17:36:22 rwatson Exp $
26.\"
6d2010ae 27.Dd Oct 18, 2010
b0d623f7
A
28.Os
29.Dt AUDITPIPE 4
30.Sh NAME
31.Nm auditpipe
32.Nd "pseudo-device for live audit event tracking"
33.Sh SYNOPSIS
34.Cd "pseudo-device auditpipe"
35.Pp
36.Fd #include <security/audit/audit_ioctl.h>
37.Sh DESCRIPTION
38While audit trail files
39generated with
40.Xr audit 4
41and maintained by
42.Xr auditd 8
43provide a reliable long-term store for audit log information, current log
44files are owned by the audit daemon until terminated making them somewhat
45unwieldy for live monitoring applications such as host-based intrusion
46detection.
47For example, the log may be cycled and new records written to a new file
48without notice to applications that may be accessing the file.
49.Pp
50The audit facility provides an audit pipe facility for applications requiring
51direct access to live BSM audit data for the purposes of real-time
52monitoring.
53Audit pipes are available via a clonable special device,
54.Pa /dev/auditpipe ,
55subject to the permissions on the device node, and provide a
56.Qq tee
57of the audit event stream.
58As the device is clonable, more than one instance of the device may be opened
59at a time; each device instance will provide independent access to all
60records.
61.Pp
62The audit pipe device provides discrete BSM audit records; if the read buffer
63passed by the application is too small to hold the next record in the
64sequence, it will be dropped.
65Unlike audit data written to the audit trail, the reliability of record
66delivery is not guaranteed.
67In particular, when an audit pipe queue fills, records will be dropped.
68Audit pipe devices are blocking by default, but support non-blocking I/O,
69asynchronous I/O using
70.Dv SIGIO ,
71and polled operation via
72.Xr select 2
73and
74.Xr poll 2 .
75.Pp
76Applications may choose to track the global audit trail, or configure local
77preselection parameters independent of the global audit trail parameters.
78.Ss Audit Pipe Queue Ioctls
79The following ioctls retrieve and set various audit pipe record queue
80properties:
81.Bl -tag -width ".Dv AUDITPIPE_GET_MAXAUDITDATA"
82.It Dv AUDITPIPE_GET_QLEN
83Query the current number of records available for reading on the pipe.
84.It Dv AUDITPIPE_GET_QLIMIT
85Retrieve the current maximum number of records that may be queued for reading
86on the pipe.
87.It Dv AUDITPIPE_SET_QLIMIT
88Set the current maximum number of records that may be queued for reading on
89the pipe.
90The new limit must fall between the queue limit minimum and queue limit
91maximum queryable using the following two ioctls.
92.It Dv AUDITPIPE_GET_QLIMIT_MIN
93Query the lowest possible maximum number of records that may be queued for
94reading on the pipe.
95.It Dv AUDITPIPE_GET_QLIMIT_MAX
96Query the highest possible maximum number of records that may be queued for
97reading on the pipe.
98.It Dv AUDITPIPE_FLUSH
99Flush all outstanding records on the audit pipe; useful after setting initial
100preselection properties to delete records queued during the configuration
101process which may not match the interests of the user process.
102.It Dv AUDITPIPE_GET_MAXAUDITDATA
103Query the maximum size of an audit record, which is a useful minimum size for
104a user space buffer intended to hold audit records read from the audit pipe.
105.El
106.Ss Audit Pipe Preselection Mode Ioctls
107By default, the audit pipe facility configures pipes to present records
108matched by the system-wide audit trail, configured by
109.Xr auditd 8 .
110However, the preselection mechanism for audit pipes can be configured using
111alternative criteria, including pipe-local flags and naflags settings, as
112well as auid-specific selection masks.
113This allows applications to track events not captured in the global audit
114trail, as well as limit records presented to those of specific interest to
115the application.
116.Pp
117The following ioctls configure the preselection mode on an audit pipe:
118.Bl -tag -width ".Dv AUDITPIPE_GET_PRESELECT_MODE"
119.It Dv AUDITPIPE_GET_PRESELECT_MODE
120Return the current preselect mode on the audit pipe.
121The ioctl argument should be of type
122.Vt int .
123.It Dv AUDITPIPE_SET_PRESELECT_MODE
124Set the current preselection mode on the audit pipe.
125The ioctl argument should be of type
126.Vt int .
127.El
128.Pp
129Possible preselection mode values are:
130.Bl -tag -width ".Dv AUDITPIPE_PRESELECT_MODE_TRAIL"
131.It Dv AUDITPIPE_PRESELECT_MODE_TRAIL
132Use the global audit trail preselection parameters to select records for the
133audit pipe.
134.It Dv AUDITPIPE_PRESELECT_MODE_LOCAL
135Use local audit pipe preselection; this model is similar to the global audit
136trail configuration model, consisting of global flags and naflags parameters,
137as well as a set of per-auid masks.
138These parameters are configured using further ioctls.
139.El
140.Pp
141After changing the audit pipe preselection mode, records selected under
142earlier preselection configuration may still be in the audit pipe queue.
143The application may flush the current record queue after changing the
144configuration to remove possibly undesired records.
145.Ss Audit Pipe Local Preselection Mode Ioctls
146The following ioctls configure the preselection parameters used when an audit
147pipe is configured for the
148.Dv AUDITPIPE_PRESELECT_MODE_LOCAL
149preselection mode.
150.Bl -tag -width ".Dv AUDITPIPE_GET_PRESELECT_NAFLAGS"
151.It Dv AUDITPIPE_GET_PRESELECT_FLAGS
152Retrieve the current default preselection flags for attributable events on
153the pipe.
154These flags correspond to the
155.Va flags
156field in
157.Xr audit_control 5 .
158The ioctl argument should be of type
6d2010ae 159.Vt au_mask_t .
b0d623f7
A
160.It Dv AUDITPIPE_SET_PRESELECT_FLAGS
161Set the current default preselection flags for attributable events on the
162pipe.
163These flags correspond to the
164.Va flags
165field in
166.Xr audit_control 5 .
167The ioctl argument should be of type
6d2010ae 168.Vt au_mask_t .
b0d623f7
A
169.It Dv AUDITPIPE_GET_PRESELECT_NAFLAGS
170Retrieve the current default preselection flags for non-attributable events
171on the pipe.
172These flags correspond to the
173.Va naflags
174field in
175.Xr audit_control 5 .
176The ioctl argument should be of type
6d2010ae 177.Vt au_mask_t .
b0d623f7
A
178.It Dv AUDITPIPE_SET_PRESELECT_NAFLAGS
179Set the current default preselection flags for non-attributable events on the
180pipe.
181These flags correspond to the
182.Va naflags
183field in
184.Xr audit_control 5 .
185The ioctl argument should be of type
6d2010ae 186.Vt au_mask_t .
b0d623f7
A
187.It Dv AUDITPIPE_GET_PRESELECT_AUID
188Query the current preselection masks for a specific auid on the pipe.
189The ioctl argument should be of type
190.Vt "struct auditpipe_ioctl_preselect" .
191The auid to query is specified via the
192.Va ap_auid
193field of type
194.Vt au_id_t ;
195the mask will be returned via
196.Va ap_mask
197of type
198.Vt au_mask_t .
199.It Dv AUDITPIPE_SET_PRESELECT_AUID
200Set the current preselection masks for a specific auid on the pipe.
201Arguments are identical to
202.Dv AUDITPIPE_GET_PRESELECT_AUID ,
203except that the caller should properly initialize the
204.Va ap_mask
205field to hold the desired preselection mask.
206.It Dv AUDITPIPE_DELETE_PRESELECT_AUID
207Delete the current preselection mask for a specific auid on the pipe.
208Once called, events associated with the specified auid will use the default
209flags mask.
210The ioctl argument should be of type
211.Vt au_id_t .
212.It Dv AUDITPIPE_FLUSH_PRESELECT_AUID
213Delete all auid specific preselection specifications.
214.El
215.Sh EXAMPLES
216The
217.Xr praudit 1
218utility
219may be directly executed on
220.Pa /dev/auditpipe
221to review the default audit trail.
222.Sh SEE ALSO
223.Xr poll 2 ,
224.Xr select 2 ,
225.Xr audit 4 ,
226.Xr audit_control 5 ,
227.Xr audit 8 ,
228.Xr auditd 8
229.Sh HISTORY
230The OpenBSM implementation was created by McAfee Research, the security
231division of McAfee Inc., under contract to Apple Computer Inc.\& in 2004.
232It was subsequently adopted by the TrustedBSD Project as the foundation for
233the OpenBSM distribution.
234.Pp
235Support for kernel audit first appeared in Mac OS X 10.3 and
236.Fx 6.2 .
237.Sh AUTHORS
238The audit pipe facility was designed and implemented by
239.An Robert Watson Aq rwatson@FreeBSD.org .
240.Pp
241The Basic Security Module (BSM) interface to audit records and audit event
242stream format were defined by Sun Microsystems.
243.Sh BUGS
244See the
245.Xr audit 4
246manual page for information on audit-related bugs and limitations.
247.Pp
248The configurable preselection mechanism mirrors the selection model present
249for the global audit trail.
250It might be desirable to provided a more flexible selection model.
251.Pp
252The per-pipe audit event queue is fifo, with drops occurring if either the
253user thread provides in sufficient for the record on the queue head, or on
254enqueue if there is insufficient room.
6d2010ae
A
255It might be desirable to allow applications to select which records are
256dropped, possibly in the style of preselection.