/*
* 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
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
*/
#include <stdio.h>
#include <stdlib.h>
#include <synch.h>
/* in ALLOC_INCR increments */
static int alloc_map();
static int load_map();
static int realloc_map();
typedef struct event_map {
} event_map_t;
/*
* au_preselect:
*
* Keep a dynamic array of event<-->class mappings.
* Refresh the map when the value of flag is AU_PRS_REREAD.
* Return:
* 1: The event is preselected.
* 0: The event is not preselected.
* -1: There was an error:
* Couldn't allocate memory.
* Couldn't find event.
*/
int
{
register int i;
(void) mutex_lock(&mutex_au_preselect);
if (!been_here_before) {
if (alloc_map() == -1) {
(void) mutex_unlock(&mutex_au_preselect);
return (-1);
}
if (load_map() == -1) {
(void) mutex_unlock(&mutex_au_preselect);
return (-1);
}
been_here_before = 1;
}
/*
* Don't use the cache. Re-read the audit_event(5) db every time
*/
if (flag == AU_PRS_REREAD) {
if (load_map() == -1) {
(void) mutex_unlock(&mutex_au_preselect);
return (-1);
}
}
/* Determine what portion of the preselection mask to check. */
if (sorf == AU_PRS_SUCCESS)
else if (sorf == AU_PRS_FAILURE)
else
for (i = 0; i < event_count; i++) {
(void) mutex_unlock(&mutex_au_preselect);
return (1);
} else {
(void) mutex_unlock(&mutex_au_preselect);
return (0);
}
}
}
(void) mutex_unlock(&mutex_au_preselect);
return (-1); /* could not find event in the table */
}
/*
* Initially allocate about as many map entries as are there
* are audit events shipped with the system. For sites
* that don't add audit events, this should be enough.
*/
static int
{
if ((event_map = (event_map_t *)
(event_map_t *)NULL)
return (-1);
else
return (0);
}
/*
* load the event<->class map into memory
*/
static int
load_map()
{
event_count = 0;
setauevent();
if (event_count > alloc_count)
if (realloc_map() == -1) {
endauevent();
return (-1);
}
++event_count;
}
endauevent();
return (0);
}
/*
* realloc the event map in ALLOC_INCR increments
*/
static int
{
if ((event_map = (event_map_t *)
return (-1);
return (0);
}