audit_event.c revision e4163c9bf1c1d30987c9216473236d730dc3c3a9
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#ifndef lint
static char sccsid[] = "%Z%%M% %I% %E% SMI";
#endif
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Interfaces to audit_event(5) (/etc/security/audit_event)
*/
/*
* This routine is obsolete. I have removed its inclusion by removing
* the .o from the makefile. Please use cacheauevent() or any of the
* getauev* routines.
*/
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <synch.h>
/*
* Macros to produce a quoted string containing the value of a
* preprocessor macro. For example, if SIZE is defined to be 256,
* VAL2STR(SIZE) is "256". This is used to construct format
* strings for scanf-family functions below.
*/
#define QUOTE(x) #x
static au_class_t flagstohex(char *);
/*
* If an error occurs during the call to cacheauclassnam() inside
* flagstohex() any return value could be seen as a valid class mask so
* the following global variable, cacheauclass_failure, is set to indicate
* that an error has occurred.
*/
static int cacheauclass_failure = 0;
extern int _mutex_lock(mutex_t *);
extern int _mutex_unlock(mutex_t *);
int
#ifdef __STDC__
setaueventfile(char *fname)
#else
char *fname;
#endif
{
if (fname) {
}
return (0);
}
void
{
if (au_event_file) {
(void) fseek(au_event_file, 0L, 0);
}
}
void
{
if (au_event_file) {
(void) fclose(au_event_file);
au_event_file = (FILE *)0;
}
}
{
static au_event_ent_t au_event_entry;
static char ename[AU_EVENT_NAME_MAX];
static char edesc[AU_EVENT_DESC_MAX];
/* initialize au_event_entry structure */
return (getauevent_r(&au_event_entry));
}
{
char *s, input[AU_EVENT_LINE_MAX];
/* open audit event file if it isn't already */
if (!au_event_file)
return ((au_event_ent_t *)0);
}
if (input[0] != '#') {
if ((*s == '\0') || (*s == '#')) {
continue;
}
found = 1;
s = input;
/* parse number */
i = strcspn(s, ":");
s[i] = '\0';
s = &s[i+1];
/* parse event name */
i = strcspn(s, ":");
s[i] = '\0';
trim_buf);
s = &s[i+1];
/* parse event description */
i = strcspn(s, ":");
s[i] = '\0';
s = &s[i+1];
/* parse class */
i = strcspn(s, "\n\0");
s[i] = '\0';
trim_buf);
if (cacheauclass_failure == 1) {
error = 1;
cacheauclass_failure = 0;
}
break;
}
}
return (au_event_entry);
} else {
return ((au_event_ent_t *)0);
}
}
#ifdef __STDC__
getauevnam(char *name)
#else
char *name;
#endif
{
static au_event_ent_t au_event_entry;
static char ename[AU_EVENT_NAME_MAX];
static char edesc[AU_EVENT_DESC_MAX];
/* initialize au_event_entry structure */
}
#ifdef __STDC__
#else
getauevnam_r(e, name)
au_event_ent_t &e;
char *name;
#endif
{
setauevent();
while (getauevent_r(e) != NULL) {
endauevent();
return (e);
}
}
endauevent();
return ((au_event_ent_t *)NULL);
}
#ifdef __STDC__
#else
au_event_ent_t *e;
#endif
{
setauevent();
while (getauevent_r(e) != NULL) {
if (e->ae_number == event_number) {
endauevent();
return (e);
}
}
endauevent();
return ((au_event_ent_t *)NULL);
}
#ifdef __STDC__
#else
#endif
{
static au_event_ent_t e;
static char ename[AU_EVENT_NAME_MAX];
static char edesc[AU_EVENT_DESC_MAX];
/* initialize au_event_entry structure */
return (getauevnum_r(&e, event_number));
}
#ifdef __STDC__
getauevnonam(char *event_name)
#else
char *event_name;
#endif
{
char ename[AU_EVENT_NAME_MAX];
char edesc[AU_EVENT_DESC_MAX];
/* initialize au_event_entry structure */
return (-1);
}
return (e.ae_number);
}
/*
* cacheauevent:
* Read the entire audit_event file into memory.
* Set a pointer to the requested entry in the cache
* or a pointer to an invalid entry if the event number
* is not known.
*
* Return < 0, if error.
* Return 0, if event number not in cache.
* Return 1, if event number is in cache.
*/
int
#ifdef __STDC__
#else
#endif
{
static int invalid; /* 1+index of the highest event number */
static au_event_ent_t **index_tbl;
static au_event_ent_t **p_tbl;
static int called_once = 0;
char line[AU_EVENT_LINE_MAX];
int lines = 0;
int i, size;
int hit = 0;
char *s;
if (called_once == 0) {
/* Count number of lines in the events file */
return (-1);
}
if ((*s == '\0') || (*s == '#')) {
continue;
}
lines++;
}
/*
* Make an array in which each element in an entry in the
* events file. Make the next to last element an invalid
* event. Make the last element a NULL pointer.
*/
return (-2);
}
lines = 0;
max = 0;
min = 65535;
setauevent();
malloc(sizeof (au_event_ent_t));
return (-3);
}
#ifdef DEBUG2
#endif
}
}
lines++;
}
endauevent();
malloc(sizeof (au_event_ent_t));
return (-4);
}
#ifdef DEBUG2
for (i = 0; i < size; i++) {
}
#endif
/* get space for the index_tbl */
return (-5);
}
/* intialize the index_tbl to the invalid event number */
}
/* point each index_tbl element at the corresponding event */
for (i = 0; i < size; i++) {
}
called_once = 1;
}
} else {
hit = 1;
}
return (hit);
}
static au_class_t
flagstohex(char *flags)
{
au_class_t hex = 0;
char *comma = ",";
char *s;
char *last;
while (s != NULL) {
if ((cacheauclassnam(&p_class, s)) < 0) {
cacheauclass_failure = 1;
return ((au_class_t)-1);
}
}
return (hex);
}
#ifdef DEBUG2
void
{
}
#endif