xref: /titanic_51/usr/src/cmd/praudit/print_audit.txt (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate/*
2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate *
4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate * with the License.
8*7c478bd9Sstevel@tonic-gate *
9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate *
14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate *
20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate */
22*7c478bd9Sstevel@tonic-gate/*
23*7c478bd9Sstevel@tonic-gate * Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate */
26*7c478bd9Sstevel@tonic-gate
27*7c478bd9Sstevel@tonic-gate#pragma ident	"%Z%%M%	%I%	%E% SMI"
28*7c478bd9Sstevel@tonic-gate
29*7c478bd9Sstevel@tonic-gateThis describes some private interfaces currently provided by praudit.
30*7c478bd9Sstevel@tonic-gateIn the future these may be provided by libbsm instead.  Note that
31*7c478bd9Sstevel@tonic-gatethese interfaces are MT-Safe.
32*7c478bd9Sstevel@tonic-gate
33*7c478bd9Sstevel@tonic-gate
34*7c478bd9Sstevel@tonic-gateNAME
35*7c478bd9Sstevel@tonic-gate     print_audit, print_audit_buf  -  format and print audit trail data
36*7c478bd9Sstevel@tonic-gate     print_audit_xml_prolog,
37*7c478bd9Sstevel@tonic-gate     print_audit_xml_ending,
38*7c478bd9Sstevel@tonic-gate     print_audit_xml_prolog_buf,
39*7c478bd9Sstevel@tonic-gate     print_audit_xml_ending_buf    - print audit XML prolog and ending
40*7c478bd9Sstevel@tonic-gate
41*7c478bd9Sstevel@tonic-gateSYNOPSIS
42*7c478bd9Sstevel@tonic-gate     int print_audit(const int flags, const char *separator);
43*7c478bd9Sstevel@tonic-gate
44*7c478bd9Sstevel@tonic-gate     int print_audit_buf(char **in_buf, int *in_buf_len, char **out_buf,
45*7c478bd9Sstevel@tonic-gate	int *out_buf_len, const int flags, const char *separator);
46*7c478bd9Sstevel@tonic-gate
47*7c478bd9Sstevel@tonic-gate     void print_audit_xml_prolog(void);
48*7c478bd9Sstevel@tonic-gate     void print_audit_xml_ending(void);
49*7c478bd9Sstevel@tonic-gate     int print_audit_xml_prolog_buf(char *out_buf, const int out_buf_len);
50*7c478bd9Sstevel@tonic-gate     int print_audit_xml_ending_buf(char *out_buf, const int out_buf_len);
51*7c478bd9Sstevel@tonic-gate
52*7c478bd9Sstevel@tonic-gateDESCRIPTION
53*7c478bd9Sstevel@tonic-gate     print_audit() formats binary audit data from stdin and prints in
54*7c478bd9Sstevel@tonic-gate     ASCII on stdout. print_audit_buf() formats binary audit data from
55*7c478bd9Sstevel@tonic-gate     in_buf and copies in ASCII to out_buf, terminating with a null
56*7c478bd9Sstevel@tonic-gate     byte.
57*7c478bd9Sstevel@tonic-gate
58*7c478bd9Sstevel@tonic-gate     print_audit_xml_prolog and print_audit_xml_prolog_buf will print
59*7c478bd9Sstevel@tonic-gate     only the audit XML prolog. The XML, prolog includes identification
60*7c478bd9Sstevel@tonic-gate     of the DTD which is used to parse the XML, and also identifies the
61*7c478bd9Sstevel@tonic-gate     stylesheet which is used to view the XML conveniently (for example
62*7c478bd9Sstevel@tonic-gate     in a browser which supports these features).
63*7c478bd9Sstevel@tonic-gate
64*7c478bd9Sstevel@tonic-gate     print_audit_xml_ending and print_audit_xml_ending_buf print only
65*7c478bd9Sstevel@tonic-gate     the XML ending which completes the audit XML.
66*7c478bd9Sstevel@tonic-gate
67*7c478bd9Sstevel@tonic-gatePARAMETERS
68*7c478bd9Sstevel@tonic-gate     flags - specifies the types of formatting to be done:
69*7c478bd9Sstevel@tonic-gate
70*7c478bd9Sstevel@tonic-gate     PRF_DEFAULTM
71*7c478bd9Sstevel@tonic-gate	   Default formatting.  By default, times, user  and  group  IDs
72*7c478bd9Sstevel@tonic-gate	   (UIDs and GIDs, respectively) are converted to their ASCII
73*7c478bd9Sstevel@tonic-gate	   representation. Record type and  event fields  are converted
74*7c478bd9Sstevel@tonic-gate	   to their  ASCII representation. If any other flags are
75*7c478bd9Sstevel@tonic-gate	   specified they will override this flag.
76*7c478bd9Sstevel@tonic-gate
77*7c478bd9Sstevel@tonic-gate     PRF_RAWM
78*7c478bd9Sstevel@tonic-gate           Print records in their raw form. Times,   UIDs,  GIDs,
79*7c478bd9Sstevel@tonic-gate           record  types,  and  events are displayed as integers.
80*7c478bd9Sstevel@tonic-gate           This value and PRF_SHORTM are exclusive. If  both
81*7c478bd9Sstevel@tonic-gate           are used, no processing is done and EINVAL is returned.
82*7c478bd9Sstevel@tonic-gate
83*7c478bd9Sstevel@tonic-gate     PRF_SHORTM
84*7c478bd9Sstevel@tonic-gate           Print records in their short form. All numeric  fields
85*7c478bd9Sstevel@tonic-gate           are  converted to ASCII and displayed. The short ASCII
86*7c478bd9Sstevel@tonic-gate           representations for the record type and  event  fields
87*7c478bd9Sstevel@tonic-gate           are   used.   This  value an PRF_RAWM are exclusive. If
88*7c478bd9Sstevel@tonic-gate	   both are used, no processing is done and EINVAL is returned.
89*7c478bd9Sstevel@tonic-gate
90*7c478bd9Sstevel@tonic-gate     PRF_XMLM
91*7c478bd9Sstevel@tonic-gate           Print records in XML format. "tags" are included in the
92*7c478bd9Sstevel@tonic-gate           output to identify tokens and fields within tokens.
93*7c478bd9Sstevel@tonic-gate	   Output will not include an XML prolog or ending which
94*7c478bd9Sstevel@tonic-gate           are required to from complete, valid XML. The various
95*7c478bd9Sstevel@tonic-gate           print XML prolog and ending functions described here
96*7c478bd9Sstevel@tonic-gate           must be used separately from print_audit and print_audit_buf
97*7c478bd9Sstevel@tonic-gate           to accomplish that.
98*7c478bd9Sstevel@tonic-gate
99*7c478bd9Sstevel@tonic-gate     PRF_ONELINE
100*7c478bd9Sstevel@tonic-gate           Prints one line per record. The record type and  event
101*7c478bd9Sstevel@tonic-gate           fields  are  always  converted  to  their  short ASCII
102*7c478bd9Sstevel@tonic-gate           representation as is done for the -s option.
103*7c478bd9Sstevel@tonic-gate
104*7c478bd9Sstevel@tonic-gate
105*7c478bd9Sstevel@tonic-gate     separator -
106*7c478bd9Sstevel@tonic-gate	if non-NULL, this is used as the field delimiter instead of the
107*7c478bd9Sstevel@tonic-gate	default delimiter, which is the comma.  The maximum size of a
108*7c478bd9Sstevel@tonic-gate	delimiter is three characters (not counting the required
109*7c478bd9Sstevel@tonic-gate	null-terminator).  Note that the delimiter is not meaningful
110*7c478bd9Sstevel@tonic-gate	and this parameter is ignored when flags specifies XML format.
111*7c478bd9Sstevel@tonic-gate
112*7c478bd9Sstevel@tonic-gate     in_buf, in_buf_len,
113*7c478bd9Sstevel@tonic-gate     out_buf, out_buf_len  -
114*7c478bd9Sstevel@tonic-gate	pointers to the start of input and output buffers and their lengths.
115*7c478bd9Sstevel@tonic-gate	See Return Values for details about how these are used.
116*7c478bd9Sstevel@tonic-gate
117*7c478bd9Sstevel@tonic-gate
118*7c478bd9Sstevel@tonic-gateRETURN VALUES
119*7c478bd9Sstevel@tonic-gate     print_audit() and print_audit_buf() return:
120*7c478bd9Sstevel@tonic-gate     0     on success.
121*7c478bd9Sstevel@tonic-gate     -1    on failure and set errno to indicate the error:
122*7c478bd9Sstevel@tonic-gate
123*7c478bd9Sstevel@tonic-gate     EINVAL - invalid input flags, delimiter, or error parsing the
124*7c478bd9Sstevel@tonic-gate	      binary audit data.
125*7c478bd9Sstevel@tonic-gate
126*7c478bd9Sstevel@tonic-gate     ENOSPC - output buffer too small.
127*7c478bd9Sstevel@tonic-gate
128*7c478bd9Sstevel@tonic-gate     EIO    - input exhausted before end of an audit record.
129*7c478bd9Sstevel@tonic-gate
130*7c478bd9Sstevel@tonic-gate     EPERM  - internal or other unexpected error.
131*7c478bd9Sstevel@tonic-gate
132*7c478bd9Sstevel@tonic-gate     Partial results may also be returned for these errors.
133*7c478bd9Sstevel@tonic-gate
134*7c478bd9Sstevel@tonic-gate
135*7c478bd9Sstevel@tonic-gate     The following parameters are always returned:
136*7c478bd9Sstevel@tonic-gate
137*7c478bd9Sstevel@tonic-gate     out_buf_len -
138*7c478bd9Sstevel@tonic-gate
139*7c478bd9Sstevel@tonic-gate     updated to reflect size of output successfully produced. If
140*7c478bd9Sstevel@tonic-gate     non-zero, this will include the single terminating null byte.
141*7c478bd9Sstevel@tonic-gate
142*7c478bd9Sstevel@tonic-gate
143*7c478bd9Sstevel@tonic-gate     Upon return of partial results, these parameters will also be
144*7c478bd9Sstevel@tonic-gate     updated to reflect status (up to the end of the last completed
145*7c478bd9Sstevel@tonic-gate     audit record from the input):
146*7c478bd9Sstevel@tonic-gate
147*7c478bd9Sstevel@tonic-gate     in_buf, in_buf_len -
148*7c478bd9Sstevel@tonic-gate
149*7c478bd9Sstevel@tonic-gate     updated to reflect amount of input successfully consumed.  in_buf
150*7c478bd9Sstevel@tonic-gate     will point to the next byte which has not been processed.
151*7c478bd9Sstevel@tonic-gate     in_buf_len will be set to the remaining size from this address to
152*7c478bd9Sstevel@tonic-gate     the end of the original buffer.
153*7c478bd9Sstevel@tonic-gate
154*7c478bd9Sstevel@tonic-gate
155*7c478bd9Sstevel@tonic-gate     print_audit_xml_prolog_buf and print_audit_xml_ending_buf return:
156*7c478bd9Sstevel@tonic-gate     0     on success.
157*7c478bd9Sstevel@tonic-gate     -1    on failure and set errno to indicate the error:
158*7c478bd9Sstevel@tonic-gate
159*7c478bd9Sstevel@tonic-gate     ENOSPC - output buffer too small.
160*7c478bd9Sstevel@tonic-gate
161*7c478bd9Sstevel@tonic-gate
162*7c478bd9Sstevel@tonic-gateEXAMPLES
163*7c478bd9Sstevel@tonic-gate       The following code fragment takes audit input from stdin, and
164*7c478bd9Sstevel@tonic-gate       will print on stdout complete XML including a prolog:
165*7c478bd9Sstevel@tonic-gate
166*7c478bd9Sstevel@tonic-gate	print_audit_xml_prolog();
167*7c478bd9Sstevel@tonic-gate
168*7c478bd9Sstevel@tonic-gate	/*
169*7c478bd9Sstevel@tonic-gate	 * Format audit data from stdin and print to stdout.
170*7c478bd9Sstevel@tonic-gate	 */
171*7c478bd9Sstevel@tonic-gate	retstat = print_audit(PRF_XMLM | PRF_ONELINE, NULL);
172*7c478bd9Sstevel@tonic-gate
173*7c478bd9Sstevel@tonic-gate	if (retstat == 0)
174*7c478bd9Sstevel@tonic-gate		print_audit_xml_ending();
175*7c478bd9Sstevel@tonic-gate
176*7c478bd9Sstevel@tonic-gate
177