7a0a89d2cb
contrib/openbsm (svn merge) and src/sys/{bsm,security/audit} (manual merge). Add libauditd build parts and add to auditd's linkage; force libbsm to build before libauditd. OpenBSM history for imported revisions below for reference. MFC after: 1 month Sponsored by: Apple Inc. Obtained from: TrustedBSD Project OpenBSM 1.1 alpha 4 - With the addition of BSM error number mapping, we also need to map the local error number passed to audit_submit(3) to a BSM error number, rather than have the caller perform that conversion. - Reallocate user audit events to avoid collisions with Solaris; adopt a more formal allocation scheme, and add some events allocated in Solaris that will be of immediate use on other platforms. - Add an event for Calife. - Add au_strerror(3), which allows generating strings for BSM errors directly, rather than requiring applications to map to the local error space, which might not be able to entirely represent the BSM error number space. - Major auditd rewrite for launchd(8) support. Add libauditd library that is shared between launchd and auditd. - Add AUDIT_TRIGGER_INITIALIZE trigger (sent via 'audit -i') for (re)starting auditing under launchd(8) on Mac OS X. - Add 'current' symlink to active audit trail. - Add crash recovery of previous audit trail file when detected on audit startup that it has not been properly terminated. - Add the event AUE_audit_recovery to indicated when an audit trail file has been recovered from not being properly terminated. This event is stored in the new audit trail file and includes the path of recovered audit trail file. - Mac OS X and FreeBSD dependent code in auditd.c is separated into auditd_darwin.c and auditd_fbsd.c files. - Add an event for the posix_spawn(2) and fsgetpath(2) Mac OS X system calls. - For Mac OS X, we use ASL(3) instead of syslog(3) for logging. - Add support for NOTICE level logging. OpenBSM 1.1 alpha 3 - Add two new functions, au_bsm_to_errno() and au_errno_to_bsm(), to map between BSM error numbers (largely the Solaris definitions) and local errno(2) values for 32-bit and 64-bit return tokens. This is required as operating systems don't agree on some of the values of more recent error numbers. - Fix a bug how au_to_exec_args(3) and au_to_exec_env(3) calculates the total size for the token. This buge. - Deprecated Darwin constants, such as TRAILER_PAD_MAGIC, removed.
136 lines
4.0 KiB
Groff
136 lines
4.0 KiB
Groff
.\"
|
|
.\" Copyright (c) 2006 Christian S.J. Peron
|
|
.\" All rights reserved.
|
|
.\"
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
.\" modification, are permitted provided that the following conditions
|
|
.\" are met:
|
|
.\"
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
.\" 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
|
|
.\" its contributors may be used to endorse or promote products derived
|
|
.\" from this software without specific prior written permission.
|
|
.\"
|
|
.\" THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR
|
|
.\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
|
.\"
|
|
.\" $P4: //depot/projects/trustedbsd/openbsm/libbsm/audit_submit.3#15 $
|
|
.\"
|
|
.Dd January 18, 2008
|
|
.Dt audit_submit 3
|
|
.Os
|
|
.Sh NAME
|
|
.Nm audit_submit
|
|
.Nd "general purpose audit record submission"
|
|
.Sh LIBRARY
|
|
.Lb libbsm
|
|
.Sh SYNOPSIS
|
|
.In bsm/libbsm.h
|
|
.Ft int
|
|
.Fo audit_submit
|
|
.Fa "short au_event" "au_id_t auid" "char status"
|
|
.Fa "int reterr" "const char * restrict format" ...
|
|
.Fc
|
|
.Sh DESCRIPTION
|
|
The
|
|
.Fn audit_submit
|
|
function provides a generic programming interface for audit record submission.
|
|
This audit record will contain a header, subject token, an optional text token,
|
|
return token, and a trailer.
|
|
The header will contain the event class specified by
|
|
.Fa au_event .
|
|
The subject token will be generated based on
|
|
.Fa auid .
|
|
The return token is dependent on the
|
|
.Fa status
|
|
and
|
|
.Fa reterr
|
|
arguments; unlike the argument to
|
|
.Xr au_to_return ,
|
|
.Fa reterr
|
|
should be a local rather than BSM error number.
|
|
Optionally, a text token will be created as a part of this record.
|
|
.Pp
|
|
Text token output is under the control of a
|
|
.Fa format
|
|
string that specifies how subsequent arguments (or arguments accessed via the
|
|
variable-length argument facilities of
|
|
.Xr stdarg 3 )
|
|
are converted for output.
|
|
If
|
|
.Fa format
|
|
is
|
|
.Dv NULL ,
|
|
then no text token is created in the audit record.
|
|
.Pp
|
|
It should be noted that
|
|
.Fn audit_submit
|
|
assumes that
|
|
.Xr setaudit 2 ,
|
|
or
|
|
.Xr setaudit_addr 2
|
|
has already been called.
|
|
As a direct result, the terminal ID for the
|
|
subject will be retrieved from the kernel via
|
|
.Xr getaudit 2 ,
|
|
or
|
|
.Xr getaudit_addr 2 .
|
|
.Sh EXAMPLES
|
|
.Bd -literal -offset indent
|
|
#include <bsm/audit.h>
|
|
#include <bsm/libbsm.h>
|
|
#include <bsm/audit_uevents.h>
|
|
|
|
#include <stdio.h>
|
|
#include <stdarg.h>
|
|
#include <errno.h>
|
|
|
|
int
|
|
audit_bad_su(char *from_login, char *to_login)
|
|
{
|
|
int error;
|
|
|
|
error = audit_submit(AUE_su, getuid(), 1, EPERM,
|
|
"bad su from %s to %s", from_login, to_login);
|
|
return (error);
|
|
}
|
|
.Ed
|
|
.Pp
|
|
Will generate the following audit record:
|
|
.Bd -literal -offset indent
|
|
header,94,1,su(1),0,Mon Apr 17 23:23:59 2006, + 271 msec
|
|
subject,root,root,wheel,root,wheel,652,652,0,0.0.0.0
|
|
text,bad su from from csjp to root
|
|
return,failure : Operation not permitted,1
|
|
trailer,94
|
|
.Ed
|
|
.Sh SEE ALSO
|
|
.Xr auditon 2 ,
|
|
.Xr getaudit 2 ,
|
|
.Xr libbsm 3 ,
|
|
.Xr stdarg 3
|
|
.Sh HISTORY
|
|
The
|
|
.Fn audit_submit
|
|
function first appeared in OpenBSM version 1.0.
|
|
OpenBSM 1.0 was introduced in
|
|
.Fx 7.0 .
|
|
.Sh AUTHORS
|
|
The
|
|
.Fn audit_submit
|
|
function was written by
|
|
.An Christian S.J. Peron Aq csjp@FreeBSD.org .
|