xref: /freebsd/contrib/openbsm/libbsm/audit_submit.3 (revision 506764c6f65f497f91be0d771f4ae9fb3b9131aa)
1.\"
2.\" Copyright (c) 2006 Christian S.J. Peron
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 Computer, 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
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR
22.\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE.
29.\"
30.\" $P4: //depot/projects/trustedbsd/openbsm/libbsm/audit_submit.3#8 $
31.\"
32.Dd May 29, 2006
33.Dt audit_submit 3
34.Os
35.Sh NAME
36.Nm audit_submit
37.Nd general purpose audit record submission
38.Sh LIBRARY
39.Lb libbsm
40.Sh SYNOPSIS
41.In stdio.h
42.Ft int
43.Fn audit_submit "short au_event" "au_id_t auid" "char status" "int reterr" "const char * restrict format" ...
44.Sh DESCRIPTION
45The
46.Nm
47function provides a generic programming interface for audit record submission.
48This audit record will contain a header, subject token, an optional text token,
49return token, and a trailer.
50The header will contain the event class specified by
51.Fa au_event .
52The subject token will be generated based on
53.Fa au_ctx .
54The return token is dependant on the
55.Fa status
56and
57.Fa reterr
58arguments.
59Optionally, a text token will be created as a part of this record.
60.Pp
61Text token output is under the control of a
62.Fa format
63string that specifies how subsequent arguments (or arguments accessed via the
64variable-length argument facilities of
65.Xr stdarg 3 )
66are converted for output.
67If
68.Fa format
69is NULL, then no text token is created in the audit record.
70.Pp
71It should be noted that
72.Nm
73assumes that
74.Xr setaudit 2 ,
75or
76.Xr setaudit_addr 2
77has already been called.
78As a direct result, the terminal ID for the
79subject will be retrieved from the kernel via
80.Xr getaudit 2 ,
81or
82.Xr getaudit_addr 2 .
83.Sh EXAMPLES
84.Bd -literal -offset indent
85#include <bsm/audit.h>
86#include <bsm/libbsm.h>
87#include <bsm/audit_uevents.h>
88
89#include <stdio.h>
90#include <stdarg.h>
91#include <errno.h>
92
93int
94audit_bad_su(char *from_login, char *to_login)
95{
96	int error;
97
98	error = audit_submit(AUE_su, getuid(), 1, EPERM,
99	    "bad su from %s to %s", from_login, to_login);
100	return (error);
101}
102.Ed
103.Pp
104Will generate the following audit record:
105.Bd -literal -offset indent
106header,94,1,su(1),0,Mon Apr 17 23:23:59 2006, + 271 msec
107subject,root,root,wheel,root,wheel,652,652,0,0.0.0.0
108text,bad su from from csjp to root
109return,failure : Operation not permitted,1
110trailer,94
111.Ed
112.Sh SEE ALSO
113.Xr auditon 2 ,
114.Xr getaudit 2 ,
115.Xr libbsm 3 ,
116.Xr stdarg 3
117.Sh HISTORY
118The
119.Nm
120function first appeared in OpenBSM version 1.0.
121OpenBSM 1.0 was introduced in FreeBSD 7.0.
122.Sh AUTHORS
123The
124.Nm
125function was written by
126.An Christian S.J. Peron Aq csjp@FreeBSD.org .
127