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.\" 26bb97b418SRobert Watson.\" $P4: //depot/projects/trustedbsd/openbsm/libbsm/au_open.3#5 $ 27506764c6SRobert Watson.\" 28506764c6SRobert Watson.Dd March 4, 2006 29506764c6SRobert Watson.Dt AU_OPEN 3 30506764c6SRobert Watson.Os 31506764c6SRobert Watson.Sh NAME 32506764c6SRobert Watson.Nm au_close , 33bb97b418SRobert Watson.Nm au_close_buffer , 34bb97b418SRobert Watson.Nm au_close_token , 35bb97b418SRobert Watson.Nm au_open , 36bb97b418SRobert Watson.Nm au_write 37506764c6SRobert Watson.Nd "Create and commit audit records" 38506764c6SRobert Watson.Sh LIBRARY 39506764c6SRobert Watson.Lb libbsm 40506764c6SRobert Watson.Sh SYNOPSIS 41506764c6SRobert Watson.In libbsm.h 42506764c6SRobert Watson.Ft int 43506764c6SRobert Watson.Fn au_open "void" 44506764c6SRobert Watson.Ft int 45506764c6SRobert Watson.Fn au_write "int d" "token_t *tok" 46506764c6SRobert Watson.Ft int 47506764c6SRobert Watson.Fn au_close "int d" "int keep" "short event" 48506764c6SRobert Watson.Ft int 49506764c6SRobert Watson.Fn au_close_buffer "int d" "short event" "u_char *buffer" "size_t *buflen" 50506764c6SRobert Watson.Ft int 51506764c6SRobert Watson.Fn au_close_token "token_t *tok" "u_char *buffer" "size_t *buflen" 52506764c6SRobert Watson.Sh DESCRIPTION 53506764c6SRobert WatsonThese interfaces allow applications to allocate audit records, construct a 54506764c6SRobert Watsonrecord using a series of tokens, and commit the audit record to the system 55506764c6SRobert Watsonevent log. 56506764c6SRobert WatsonAn extension API is also provided to commit the record to an in-memory 57506764c6SRobert Watsonbuffer rather than the system audit log. 58506764c6SRobert Watson.Pp 59506764c6SRobert WatsonThe 60506764c6SRobert Watson.Fn au_open 61506764c6SRobert Watsoninterface allocates a new audit record descriptor. 62506764c6SRobert Watson.Pp 63506764c6SRobert WatsonThe 64506764c6SRobert Watson.Fn au_write 65506764c6SRobert Watsoninterface adds a token to an allocated audit descriptor. 66506764c6SRobert WatsonWhen a token has been successfully added to a record, the caller no longer 67506764c6SRobert Watsonowns the token memory, and does not need to free it directly via a call to 68506764c6SRobert Watson.Xr au_free_token 3 . 69506764c6SRobert Watson.Pp 70506764c6SRobert WatsonThe 71506764c6SRobert Watson.Fn au_close 72506764c6SRobert Watsonfunction is used to commit an audit record to the system audit log, or 73506764c6SRobert Watsonabandon the record. 74506764c6SRobert WatsonIn either cases, all resources associated with the record will be released. 75506764c6SRobert WatsonThe 76506764c6SRobert Watson.Va keep 77506764c6SRobert Watsonargument determines the behavior: a value of 78506764c6SRobert Watson.Dv AU_TO_WRITE 79506764c6SRobert Watsoncauses the record to be committed; a value of 80506764c6SRobert Watson.Dv AU_TO_NO_WRITE 81506764c6SRobert Watsoncauses it to be abandoned. 82506764c6SRobert WatsonWhen the audit record is committed, a BSM header will be inserted before 83506764c6SRobert Watsontokens added to the record, using the event identifier passed via 84506764c6SRobert Watson.Va event , 85506764c6SRobert Watsonand a trailer added to the end. 86506764c6SRobert WatsonCommitting a record to the system audit log requires privilege. 87506764c6SRobert Watson.Pp 88506764c6SRobert WatsonThe 89506764c6SRobert Watson.Fn au_close_buffer 90506764c6SRobert Watsonfunction writes the resulting record to an in-memory buffer of size 91506764c6SRobert Watson.Va *buflen ; 92506764c6SRobert Watsonit will write back the filled buffer length into the same variable. 93506764c6SRobert WatsonThe argument 94506764c6SRobert Watson.Va short 95506764c6SRobert Watsonis the event identifier to use in the record header. 96506764c6SRobert Watson.Pp 97506764c6SRobert WatsonThe 98506764c6SRobert Watson.Fn au_close_token 99506764c6SRobert Watsonfunction generates the BSM stream output for a single token, 100506764c6SRobert Watson.Va tok , 101506764c6SRobert Watsonin the passed buffer 102506764c6SRobert Watson.Va buffer . 103506764c6SRobert WatsonThe initial buffer size and resulting data size are passed via 104506764c6SRobert Watson.Va *buflen . 105506764c6SRobert Watson.Fn au_close_token 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 AUTHORS 127506764c6SRobert WatsonThis software was created by Robert Watson, Wayne Salamon, and Suresh 128506764c6SRobert WatsonKrishnaswamy for McAfee Research, the security research division of McAfee, 129506764c6SRobert WatsonInc., under contract to Apple Computer, Inc. 130506764c6SRobert Watson.Pp 131506764c6SRobert WatsonThe Basic Security Module (BSM) interface to audit records and audit event 132506764c6SRobert Watsonstream format were defined by Sun Microsystems. 133506764c6SRobert Watson.Sh HISTORY 134506764c6SRobert WatsonThe OpenBSM implementation was created by McAfee Research, the security 135506764c6SRobert Watsondivision of McAfee Inc., under contract to Apple Computer, Inc., in 2004. 136506764c6SRobert WatsonIt was subsequently adopted by the TrustedBSD Project as the foundation for 137506764c6SRobert Watsonthe OpenBSM distribution. 138506764c6SRobert Watson.Sh BUGS 139506764c6SRobert WatsonCurrently, 140506764c6SRobert Watson.Fn au_open 141506764c6SRobert Watsondoes not reserve kernel resources necessary to commit the record to the 142506764c6SRobert Watsontrail; on systems supporting 143506764c6SRobert Watson.Fn au_close , 144506764c6SRobert Watsonthe call will block until resources are available to commit the record. 145506764c6SRobert WatsonHowever, this leads to the possibility of an action being permitted without 146506764c6SRobert Watsonthe record being guaranteed to go to disk. 147506764c6SRobert WatsonIdeally, 148506764c6SRobert Watson.Fn au_open 149506764c6SRobert Watsonwould reserve resources necessary to commit any submitted record, releasing 150506764c6SRobert Watsonthem on 151506764c6SRobert Watson.Fn au_close . 152