]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - contrib/openbsm/libbsm/audit_submit.3
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / contrib / openbsm / libbsm / audit_submit.3
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#12 $
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 bsm/libbsm.h
42 .Ft int
43 .Fo audit_submit
44 .Fa "short au_event" "au_id_t auid" "char status"
45 .Fa "int reterr" "const char * restrict format" ...
46 .Fc
47 .Sh DESCRIPTION
48 The
49 .Fn audit_submit
50 function provides a generic programming interface for audit record submission.
51 This audit record will contain a header, subject token, an optional text token,
52 return token, and a trailer.
53 The header will contain the event class specified by
54 .Fa au_event .
55 The subject token will be generated based on
56 .Fa au_ctx .
57 The return token is dependent on the
58 .Fa status
59 and
60 .Fa reterr
61 arguments.
62 Optionally, a text token will be created as a part of this record.
63 .Pp
64 Text token output is under the control of a
65 .Fa format
66 string that specifies how subsequent arguments (or arguments accessed via the
67 variable-length argument facilities of
68 .Xr stdarg 3 )
69 are converted for output.
70 If
71 .Fa format
72 is
73 .Dv NULL ,
74 then no text token is created in the audit record.
75 .Pp
76 It should be noted that
77 .Fn audit_submit
78 assumes that
79 .Xr setaudit 2 ,
80 or
81 .Xr setaudit_addr 2
82 has already been called.
83 As a direct result, the terminal ID for the
84 subject will be retrieved from the kernel via
85 .Xr getaudit 2 ,
86 or
87 .Xr getaudit_addr 2 .
88 .Sh EXAMPLES
89 .Bd -literal -offset indent
90 #include <bsm/audit.h>
91 #include <bsm/libbsm.h>
92 #include <bsm/audit_uevents.h>
93
94 #include <stdio.h>
95 #include <stdarg.h>
96 #include <errno.h>
97
98 int
99 audit_bad_su(char *from_login, char *to_login)
100 {
101         int error;
102
103         error = audit_submit(AUE_su, getuid(), 1, EPERM,
104             "bad su from %s to %s", from_login, to_login);
105         return (error);
106 }
107 .Ed
108 .Pp
109 Will generate the following audit record:
110 .Bd -literal -offset indent
111 header,94,1,su(1),0,Mon Apr 17 23:23:59 2006, + 271 msec
112 subject,root,root,wheel,root,wheel,652,652,0,0.0.0.0
113 text,bad su from from csjp to root
114 return,failure : Operation not permitted,1
115 trailer,94
116 .Ed
117 .Sh SEE ALSO
118 .Xr auditon 2 ,
119 .Xr getaudit 2 ,
120 .Xr libbsm 3 ,
121 .Xr stdarg 3
122 .Sh HISTORY
123 The
124 .Fn audit_submit
125 function first appeared in OpenBSM version 1.0.
126 OpenBSM 1.0 was introduced in
127 .Fx 7.0 .
128 .Sh AUTHORS
129 The
130 .Fn audit_submit
131 function was written by
132 .An Christian S.J. Peron Aq csjp@FreeBSD.org .