/*
* 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
*/
/*
*/
/*
* 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.
*/
#ifdef DEBUG2
void
{
}
#endif
void
{
(void) mutex_lock(&mutex_eventfile);
if (au_event_file != NULL) {
(void) fseek(au_event_file, 0L, 0);
}
(void) mutex_unlock(&mutex_eventfile);
}
void
{
(void) mutex_lock(&mutex_eventfile);
if (au_event_file != NULL) {
(void) fclose(au_event_file);
}
(void) mutex_unlock(&mutex_eventfile);
}
{
/* initialize au_event_entry structure */
return (getauevent_r(&au_event_entry));
}
{
int i;
int c_int;
/* open audit event file if it isn't already */
(void) mutex_lock(&mutex_eventfile);
if (au_event_file == NULL) {
(void) mutex_unlock(&mutex_eventfile);
return (NULL);
}
}
for (;;) {
i = 0;
if (i < AU_EVENT_LINE_MAX) {
}
}
input[i] = '\0';
if ((*s != '\0') && (*s != '#')) {
s = input;
/* parse event 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 - the remainder of the line */
i = strcspn(s, "\n\0");
s[i] = '\0';
trim_buf);
if (cacheauclass_failure) {
}
break;
}
break;
}
}
(void) mutex_unlock(&mutex_eventfile);
}
{
/* initialize au_event_entry structure */
}
{
setauevent();
while (getauevent_r(e) != NULL) {
endauevent();
return (e);
}
}
endauevent();
return (NULL);
}
{
setauevent();
while (getauevent_r(e) != NULL) {
if (e->ae_number == event_number) {
endauevent();
return (e);
}
}
endauevent();
return (NULL);
}
{
static au_event_ent_t e;
/* initialize au_event_entry structure */
return (getauevnum_r(&e, event_number));
}
{
/* initialize au_event_entry structure */
return (0);
}
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
{
static int called_once = 0;
int lines = 0;
int i, size;
int c_int;
int hit = 0;
char *s;
(void) mutex_lock(&mutex_eventcache);
if (called_once == 0) {
/* Count number of lines in the events file */
(void) mutex_unlock(&mutex_eventcache);
return (-1);
}
for (;;) {
i = 0;
if (i < AU_EVENT_LINE_MAX) {
}
}
line[i] = '\0';
if ((*s != '\0') && (*s != '#')) {
lines++;
}
break;
}
}
/*
* 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.
*/
(void) mutex_unlock(&mutex_eventcache);
return (-2);
}
lines = 0;
max = 0;
min = 65535;
setauevent();
malloc(sizeof (au_event_ent_t));
(void) mutex_unlock(&mutex_eventcache);
return (-3);
}
#ifdef DEBUG2
#endif
}
}
lines++;
}
endauevent();
malloc(sizeof (au_event_ent_t));
(void) mutex_unlock(&mutex_eventcache);
return (-4);
}
#ifdef DEBUG2
for (i = 0; i <= lines; i++) {
printevent(p_tbl[i]);
}
#endif
/* get space for the index_tbl */
(void) mutex_unlock(&mutex_eventcache);
return (-5);
}
/* intialize the index_tbl to the invalid event number */
for (i = 0; (au_event_t)i < max; i++) {
}
/* point each index_tbl element at the corresponding event */
for (i = 0; i < size; i++) {
}
called_once = 1;
}
} else {
hit = 1;
}
(void) mutex_unlock(&mutex_eventcache);
return (hit);
}
static au_class_t
{
char *s;
char *last;
while (s != NULL) {
if ((cacheauclassnam(&p_class, s)) < 0) {
return ((au_class_t)-1);
}
}
return (hex);
}