xref: /freebsd/contrib/openbsm/libbsm/au_open.3 (revision b626f5a73a48f44a31a200291b141e1da408a2ff)
1506764c6SRobert Watson.\"-
2506764c6SRobert Watson.\" Copyright (c) 2006 Robert N. M. Watson
3506764c6SRobert Watson.\" All rights reserved.
4506764c6SRobert Watson.\"
5506764c6SRobert Watson.\" Redistribution and use in source and binary forms, with or without
6506764c6SRobert Watson.\" modification, are permitted provided that the following conditions
7506764c6SRobert Watson.\" are met:
8506764c6SRobert Watson.\" 1. Redistributions of source code must retain the above copyright
9506764c6SRobert Watson.\"    notice, this list of conditions and the following disclaimer.
10506764c6SRobert Watson.\" 2. Redistributions in binary form must reproduce the above copyright
11506764c6SRobert Watson.\"    notice, this list of conditions and the following disclaimer in the
12506764c6SRobert Watson.\"    documentation and/or other materials provided with the distribution.
13506764c6SRobert Watson.\"
14506764c6SRobert Watson.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15506764c6SRobert Watson.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16506764c6SRobert Watson.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17506764c6SRobert Watson.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18506764c6SRobert Watson.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19506764c6SRobert Watson.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20506764c6SRobert Watson.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21506764c6SRobert Watson.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22506764c6SRobert Watson.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23506764c6SRobert Watson.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24506764c6SRobert Watson.\" SUCH DAMAGE.
25506764c6SRobert Watson.\"
26506764c6SRobert Watson.Dd March 4, 2006
27506764c6SRobert Watson.Dt AU_OPEN 3
28506764c6SRobert Watson.Os
29506764c6SRobert Watson.Sh NAME
30506764c6SRobert Watson.Nm au_close ,
31bb97b418SRobert Watson.Nm au_close_buffer ,
32bb97b418SRobert Watson.Nm au_close_token ,
33bb97b418SRobert Watson.Nm au_open ,
34bb97b418SRobert Watson.Nm au_write
35bc168a6cSRobert Watson.Nd "create and commit audit records"
36506764c6SRobert Watson.Sh LIBRARY
37506764c6SRobert Watson.Lb libbsm
38506764c6SRobert Watson.Sh SYNOPSIS
39bc168a6cSRobert Watson.In bsm/libbsm.h
40506764c6SRobert Watson.Ft int
41bc168a6cSRobert Watson.Fn au_open void
42506764c6SRobert Watson.Ft int
43506764c6SRobert Watson.Fn au_write "int d" "token_t *tok"
44506764c6SRobert Watson.Ft int
45506764c6SRobert Watson.Fn au_close "int d" "int keep" "short event"
46506764c6SRobert Watson.Ft int
47506764c6SRobert Watson.Fn au_close_buffer "int d" "short event" "u_char *buffer" "size_t *buflen"
48506764c6SRobert Watson.Ft int
49506764c6SRobert Watson.Fn au_close_token "token_t *tok" "u_char *buffer" "size_t *buflen"
50506764c6SRobert Watson.Sh DESCRIPTION
51506764c6SRobert WatsonThese interfaces allow applications to allocate audit records, construct a
52506764c6SRobert Watsonrecord using a series of tokens, and commit the audit record to the system
53506764c6SRobert Watsonevent log.
54506764c6SRobert WatsonAn extension API is also provided to commit the record to an in-memory
55506764c6SRobert Watsonbuffer rather than the system audit log.
56506764c6SRobert Watson.Pp
57506764c6SRobert WatsonThe
58506764c6SRobert Watson.Fn au_open
59506764c6SRobert Watsoninterface allocates a new audit record descriptor.
60506764c6SRobert Watson.Pp
61506764c6SRobert WatsonThe
62506764c6SRobert Watson.Fn au_write
63506764c6SRobert Watsoninterface adds a token to an allocated audit descriptor.
64506764c6SRobert WatsonWhen a token has been successfully added to a record, the caller no longer
65506764c6SRobert Watsonowns the token memory, and does not need to free it directly via a call to
66506764c6SRobert Watson.Xr au_free_token 3 .
67506764c6SRobert Watson.Pp
68506764c6SRobert WatsonThe
69506764c6SRobert Watson.Fn au_close
70506764c6SRobert Watsonfunction is used to commit an audit record to the system audit log, or
71506764c6SRobert Watsonabandon the record.
72506764c6SRobert WatsonIn either cases, all resources associated with the record will be released.
73506764c6SRobert WatsonThe
74bc168a6cSRobert Watson.Fa keep
75506764c6SRobert Watsonargument determines the behavior: a value of
76506764c6SRobert Watson.Dv AU_TO_WRITE
77506764c6SRobert Watsoncauses the record to be committed; a value of
78506764c6SRobert Watson.Dv AU_TO_NO_WRITE
79506764c6SRobert Watsoncauses it to be abandoned.
80506764c6SRobert WatsonWhen the audit record is committed, a BSM header will be inserted before
81506764c6SRobert Watsontokens added to the record, using the event identifier passed via
82bc168a6cSRobert Watson.Fa event ,
83506764c6SRobert Watsonand a trailer added to the end.
84506764c6SRobert WatsonCommitting a record to the system audit log requires privilege.
85506764c6SRobert Watson.Pp
86506764c6SRobert WatsonThe
87506764c6SRobert Watson.Fn au_close_buffer
88506764c6SRobert Watsonfunction writes the resulting record to an in-memory buffer of size
89bc168a6cSRobert Watson.Fa *buflen ;
90506764c6SRobert Watsonit will write back the filled buffer length into the same variable.
91506764c6SRobert WatsonThe argument
92bc168a6cSRobert Watson.Fa event
93506764c6SRobert Watsonis the event identifier to use in the record header.
94506764c6SRobert Watson.Pp
95506764c6SRobert WatsonThe
96506764c6SRobert Watson.Fn au_close_token
97506764c6SRobert Watsonfunction generates the BSM stream output for a single token,
98bc168a6cSRobert Watson.Fa tok ,
99506764c6SRobert Watsonin the passed buffer
100bc168a6cSRobert Watson.Fa buffer .
101506764c6SRobert WatsonThe initial buffer size and resulting data size are passed via
102bc168a6cSRobert Watson.Fa *buflen .
103bc168a6cSRobert WatsonThe
104506764c6SRobert Watson.Fn au_close_token
105bc168a6cSRobert Watsonfunction
106506764c6SRobert Watsonwill free the token before returning.
107506764c6SRobert Watson.Sh RETURN VALUES
108506764c6SRobert WatsonThe function
109506764c6SRobert Watson.Fn au_open
110506764c6SRobert Watsonreturns a non-negative audit record descriptor number on success, or a
111506764c6SRobert Watsonnegative value on failure, along with error information in
112506764c6SRobert Watson.Va errno .
113506764c6SRobert Watson.Pp
114506764c6SRobert WatsonThe functions
115506764c6SRobert Watson.Fn au_write ,
116506764c6SRobert Watson.Fn au_close ,
117506764c6SRobert Watson.Fn au_close_buffer ,
118506764c6SRobert Watsonand
119506764c6SRobert Watson.Fn au_close_token
120506764c6SRobert Watsonreturn 0 on success, or a negative value on failure, along with error
121506764c6SRobert Watsoninformation in
122506764c6SRobert Watson.Va errno .
123506764c6SRobert Watson.Sh SEE ALSO
124bb97b418SRobert Watson.Xr audit_submit 3 ,
125506764c6SRobert Watson.Xr libbsm 3
126506764c6SRobert Watson.Sh HISTORY
127506764c6SRobert WatsonThe OpenBSM implementation was created by McAfee Research, the security
128506764c6SRobert Watsondivision of McAfee Inc., under contract to Apple Computer, Inc., in 2004.
129506764c6SRobert WatsonIt was subsequently adopted by the TrustedBSD Project as the foundation for
130506764c6SRobert Watsonthe OpenBSM distribution.
131bc168a6cSRobert Watson.Sh AUTHORS
132bc168a6cSRobert Watson.An -nosplit
133bc168a6cSRobert WatsonThis software was created by
134bc168a6cSRobert Watson.An Robert Watson ,
135bc168a6cSRobert Watson.An Wayne Salamon ,
136bc168a6cSRobert Watsonand
137bc168a6cSRobert Watson.An Suresh Krishnaswamy
138bc168a6cSRobert Watsonfor McAfee Research, the security research division of McAfee,
139bc168a6cSRobert WatsonInc., under contract to Apple Computer, Inc.
140bc168a6cSRobert Watson.Pp
141bc168a6cSRobert WatsonThe Basic Security Module (BSM) interface to audit records and audit event
142bc168a6cSRobert Watsonstream format were defined by Sun Microsystems.
143506764c6SRobert Watson.Sh BUGS
144506764c6SRobert WatsonCurrently,
145506764c6SRobert Watson.Fn au_open
146506764c6SRobert Watsondoes not reserve kernel resources necessary to commit the record to the
147506764c6SRobert Watsontrail; on systems supporting
148506764c6SRobert Watson.Fn au_close ,
149506764c6SRobert Watsonthe call will block until resources are available to commit the record.
150506764c6SRobert WatsonHowever, this leads to the possibility of an action being permitted without
151506764c6SRobert Watsonthe record being guaranteed to go to disk.
152506764c6SRobert WatsonIdeally,
153506764c6SRobert Watson.Fn au_open
154506764c6SRobert Watsonwould reserve resources necessary to commit any submitted record, releasing
155506764c6SRobert Watsonthem on
156506764c6SRobert Watson.Fn au_close .
157