/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <dirent.h>
#include <locale.h>
#include <libintl.h>
#include <stdlib.h>
#include <strings.h>
#include <stdio.h>
#include <unistd.h>
#include <bsm/audit_record.h>
#include "praudit.h"
#include "toktable.h"
extern void init_tokens(void); /* shared with auditreduce */
const char *separator);
static int initdone = 0;
/*
* This source is shared outside of praudit; the following lint directive
* is needed to suppress praudit lint warnings about unused functions, for
* functions which are only invoked outside praudit.
*/
/*LINTLIBRARY*/
/*
* ----------------------------------------------------------------------
* check_inputs() - check input flags and delimiter.
* Returns:
* 0 - successful
* -1 - invalid inputs. errno is set to EINVAL
* ----------------------------------------------------------------------
*/
static int
{
return (-1);
}
/* Ignore the delimiter when XML is specified */
return (-1);
}
return (0);
}
/*
* ----------------------------------------------------------------------
* print_audit_xml_prolog_buf() - print the XML prolog.
* 0 - successful
* -1 - output buffer too small. errno is set to ENOSPC
* ----------------------------------------------------------------------
*/
int
{
if (xml_prolog_len > out_buf_len) {
return (-1);
}
return (0);
}
/*
* ----------------------------------------------------------------------
* print_audit_xml_ending_buf() - print the XML ending.
* 0 - successful
* -1 - output buffer too small. errno is set to ENOSPC
* ----------------------------------------------------------------------
*/
int
{
if (xml_end_len > out_buf_len) {
return (-1);
}
return (0);
}
/*
* ----------------------------------------------------------------------
* print_prolog() - print the XML prolog.
* ----------------------------------------------------------------------
*/
void
print_audit_xml_prolog(void)
{
}
/*
* ----------------------------------------------------------------------
* print_ending() - print the XML ending.
* ----------------------------------------------------------------------
*/
void
print_audit_xml_ending(void)
{
}
/*
* ----------------------------------------------------------------------
* checkpoint_progress() - If starting a new file or header token,
* checkpoint as needed to mark progress.
* ----------------------------------------------------------------------
*/
static void
{
}
if (is_file_token(tokenid)) {
}
}
}
/*
* ----------------------------------------------------------------------
* print_audit_buf() - display contents of audit trail file
*
* Parses the binary audit data from the specified input
* buffer, and formats as requested to the specified output
* buffer.
*
* inputs:
* in_buf, - address and length of binary audit input.
* in_buf_len
* out_buf, - address and length of output buffer to
* out_buf_len copy formatted audit data to.
* flags - formatting flags as defined in praudit.h
* separator - field delimiter (or NULL if the default
* delimiter of comma is to be used).
*
* return codes: 0 - success
* ENOSPC...
* ----------------------------------------------------------------------
*/
int
{
int retstat = 0;
return (retstat);
return (-1);
}
/* Init internal pointers and lengths... */
context->pending_flag = 0;
context->current_rec = 0;
/*
* get an adr pointer to the audit input buf
*/
context->audit_rec_len = 0;
/* Check for and handle partial results as needed */
if (retstat != 0) {
/* Return size of output */
if (*out_buf_len > 0) {
/* null-terminate the output */
}
} else {
/* Return size of output */
}
return (retstat);
}
/*
* ----------------------------------------------------------------------
* print_audit() - display contents of audit trail file
*
* Parses the binary audit data from the file mapped as stdin,
* and formats as requested to file mapped as stdout.
* inputs:
* flags - formatting flags as defined in praudit.h
* separator - field delimiter (or NULL if the default
* delimiter of comma is to be used).
*
* return codes: -1 - error
* 0 - successful
* ----------------------------------------------------------------------
*/
int
{
int retstat = 0;
return (retstat);
return (-1);
}
/*
* get an adr pointer to the current audit file (stdin)
*/
context->audit_rec_len = 0;
context->pending_flag = 0;
context->current_rec = 0;
return (retstat);
}
/*
* ----------------------------------------------------------------------
* print_audit_common() - common routine for print_audit* functions.
*
* Parses the binary audit data, and formats as requested.
* The context parameter defines whether the source of the
* audit data is a buffer, or a file mapped to stdin, and
* whether the output is to a buffer or a file mapped to
* stdout.
*
* inputs:
* context - defines the context of the request, including
* info about the source and output.
* flags - formatting flags as defined in praudit.h
* separator - field delimiter (or NULL if the default
* delimiter of comma is to be used).
*
* return codes: -1 - error
* 0 - successful
* ----------------------------------------------------------------------
*/
static int
const char *separator)
{
int retstat = 0;
if (!initdone) {
init_tokens();
initdone++;
}
/* start with default delimiter of comma */
}
}
} else
break;
}
/*
* For buffer processing, if the entire input buffer was processed
* successfully, but the last record in the buffer was incomplete
* (according to the length from its header), then reflect an
* "incomplete input" error (which will cause partial results to be
* returned).
*/
context->audit_rec_len))) {
retstat = -1;
}
/*
* If there was a last record that didn't get officially closed
* off, do it now.
*/
(context->current_rec)) {
if (retstat == 0)
}
return (retstat);
}
/*
* -----------------------------------------------------------------------
* token_processing:
* Calls the routine corresponding to the token id
* passed in the parameter from the token table, tokentable
* return codes : -1 - error
* : 0 - successful
* -----------------------------------------------------------------------
*/
static int
{
int retstat;
/*
* First check if there's a previous record that needs to be
* closed off now; then checkpoint our progress as needed.
*/
return (retstat);
/* print token name */
} else {
} else {
}
}
if (retstat == 0)
/*
* For XML, close the token tag. Header tokens wrap the
* entire record, so they only get closed later implicitly;
* here, just make sure the header open tag gets finished.
*/
if (!is_header_token(tokenid))
else
}
return (retstat);
}
/* here if token id is not in table */
"token id %d\n"), tokenid);
return (0);
}