/*
* 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_class(5) (/etc/security/audit_class)
*/
#include <stdlib.h>
#include <stdio.h>
#include <limits.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
#ifdef DEBUG2
void
{
}
#endif
void
{
(void) mutex_lock(&mutex_classfile);
if (au_class_file != NULL) {
(void) fseek(au_class_file, 0L, 0);
}
(void) mutex_unlock(&mutex_classfile);
}
void
{
(void) mutex_lock(&mutex_classfile);
if (au_class_file != NULL) {
(void) fclose(au_class_file);
}
(void) mutex_unlock(&mutex_classfile);
}
/*
* getauclassent():
* This is not MT-safe because of the static variables.
*/
{
static au_class_ent_t e;
return (getauclassent_r(&e));
}
/*
* getauclassent_r
* This is MT-safe if each thread passes in its own pointer
* to the space where the class entry is returned. Be careful
* to also allocate space from the cname and cdesc pointers
* in the au_class_ent structure.
*/
{
int i;
int c_int;
au_class_t v;
/* open audit class file if it isn't already */
(void) mutex_lock(&mutex_classfile);
if (au_class_file == NULL) {
(void) mutex_unlock(&mutex_classfile);
return (NULL);
}
}
for (;;) {
i = 0;
if (i < AU_CLASS_LINE_MAX) {
}
}
input[i] = '\0';
if ((*s != '\0') && (*s != '#')) {
s = input;
/* parse bitfield */
i = strcspn(s, ":");
s[i] = '\0';
} else {
}
au_class_entry->ac_class = v;
s = &s[i+1];
/* parse class name */
i = strcspn(s, ":");
s[i] = '\0';
trim_buf);
s = &s[i+1];
/* parse class description */
i = strcspn(s, "\n\0");
s[i] = '\0';
break;
}
break;
}
}
(void) mutex_unlock(&mutex_classfile);
}
{
static au_class_ent_t e;
return (getauclassnam_r(&e, name));
}
{
while (getauclassent_r(e) != NULL) {
return (e);
}
}
return (NULL);
}
/*
* xcacheauclass:
* Read the entire audit_class file into memory.
* Return a pointer to the requested entry in the cache
* or a pointer to an invalid entry if the the class
* requested is not known.
*
* Return < 0, do not set result pointer, if error.
* Return 0, set result pointer to invalid entry, if class not in cache.
* Return 1, set result pointer to a valid entry, if class is in cache.
*/
static int
int flags)
{
static int invalid;
static int called_once;
static int lines = 0;
int i;
int c_int;
int hit = 0;
char *s;
(void) mutex_lock(&mutex_classcache);
if (called_once == 0) {
/* Count number of lines in the class file */
(void) mutex_unlock(&mutex_classcache);
return (-1);
}
for (;;) {
i = 0;
if (i < AU_CLASS_LINE_MAX) {
}
}
line[i] = '\0';
if ((*s != '\0') && (*s != '#')) {
lines++;
}
break;
}
}
sizeof (class_tbl));
(void) mutex_unlock(&mutex_classcache);
return (-2);
}
lines = 0;
setauclass();
/*
* This call to getauclassent is protected by
* mutex_classcache, so we don't need to use the thread-
* safe version (getauclassent_r).
*/
malloc(sizeof (au_class_ent_t));
(void) mutex_unlock(&mutex_classcache);
return (-3);
}
#ifdef DEBUG2
#endif
lines++;
}
endauclass();
malloc(sizeof (au_class_ent_t));
(void) mutex_unlock(&mutex_classcache);
return (-4);
}
called_once = 1;
#ifdef DEBUG2
for (i = 0; i <= lines; i++) {
printclass(class_tbl[i]);
}
#endif
} /* END if called_once */
if (flags & AU_CACHE_NAME) {
for (i = 0; i < lines; i++) {
AU_CLASS_NAME_MAX) == 0) {
hit = 1;
break;
}
}
} else if (flags & AU_CACHE_NUMBER) {
for (i = 0; i < lines; i++) {
hit = 1;
break;
}
}
}
(void) mutex_unlock(&mutex_classcache);
return (hit);
}
int
{
}
int
{
}