getacinfo.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#ifndef lint
static char sccsid[] = "%Z%%M% %I% %E% SMI";
#endif
/* getacinfo.c - get audit control info */
#include <stdio.h>
#include <string.h>
#include <synch.h>
#define DIROP 0
#define OTHEROP 1
#define SUCCESS 0
#define EOF_WARN 1
#define REW_WARN 2
#define EOF_ERR -1
#define ERROR -2
#define FORMAT_ERR -3
static char *AUDIT_CTRL = AUDITCONTROLFILE;
static char *MINLABEL = "minfree:";
static char *DIRLABEL = "dir:";
static char *DEFFLGLABEL = "flags:";
static char *NAFLGLABEL = "naflags:";
static int LASTOP;
static int DIRINIT;
extern int _mutex_lock(mutex_t *);
extern int _mutex_unlock(mutex_t *);
/*
* getacinfo.c - get audit control info
*
* getacdir() - get audit control directories, one at a time
* getacflg() - get audit control default audit flags
* getacmin() - get audit control directory min. fill value
* getacna() - get audit control non-attrib audit flags
* setac() - rewind the audit control file
* endac() - close the audit control file
* testac() - check if audit control file open
*/
/*
* getacdir() - get audit control directories, one at a time
*
* input: len - size of dir buffer
*
* output: dir - directory string
*
* returns: 0 - entry read ok
* -1 - end of file
* -2 - error - can't open audit control file for read
* -3 - error - directory entry format error
* 2 - directory search started from beginning again
*
* notes: It is the responsibility of the calling function to
* check the status of the directory entry.
*/
int
#ifdef __STDC__
#else
char *dir;
int len;
#endif
{
/* void setac(); */
/* open file if it is not already opened */
setac();
} else {
DIRINIT = 1;
}
switch (*entry) {
case '#':
break;
case 'd':
/* return directory entry */
} else {
/*
* allow zero or one blank
* between colon and directory
*/
} else {
}
gotone = 1;
}
} else
break;
case 'm':
break;
case 'f':
break;
default:
break;
} /* end of switch */
} else {
}
return (retstat);
}
/*
* getacmin() - get audit control directory min. fill value
*
* output: min_val - percentage of directory fill allowed
*
* returns: 0 - entry read ok
* 1 - end of file
* -2 - error; errno contains error number
* -3 - error - directory entry format error
*/
int
#ifdef __STDC__
#else
int *min_val;
#endif
{
/* open file if it is not already opened */
else
do {
switch (*entry) {
case '#':
break;
case 'd':
break;
case 'm':
(void)
"%d", min_val);
gotone = 1;
} else
break;
case 'f':
break;
default:
break;
}
else
}
else {
}
DIRINIT = 0;
}
return (retstat);
}
/*
* getacflg() - get audit control flags
*
* output: auditstring - character representation of system audit flags
*
* returns: 0 - entry read ok
* 1 - end of file
* -2 - error - errno contains error number
* -3 - error - directory entry format error
*/
#ifdef __STDC__
int
#else
int
char *auditstring;
int len;
#endif
{
/* open file if it is not already opened */
else
switch (*entry) {
case '#':
break;
case 'd':
break;
case 'm':
break;
case 'f':
strlen(DEFFLGLABEL))) == 0) {
} else {
}
else {
(void) strcpy(auditstring,
"\0");
gotone = 1;
}
} else
break; /* end of case f */
default:
break;
}
} else {
}
else {
}
DIRINIT = 0;
}
return (retstat);
}
/*
* getacna() - get audit flags for non-attributable (server) events
*
* output: auditstring - character representation of system audit flags
*
* returns: 0 - entry read ok
* 1 - end of file
* -2 - error - errno contains error number
* -3 - error - directory entry format error
*/
#ifdef __STDC__
int
#else
int
char *auditstring;
int len;
#endif
{
/* open file if it is not already opened */
} else {
}
switch (*entry) {
case '#':
break;
case 'd':
break;
case 'm':
break;
case 'f':
break;
case 'n':
0) {
} else {
}
else {
(void) strcpy(auditstring,
"\0");
gotone = 1;
}
} else
break; /* end of case n */
default:
break;
/* end of if-switch */
} else {
}
/* end of if-do */
else {
}
DIRINIT = 0;
}
return (retstat);
}
/* rewind the audit control file */
void
setac()
{
else
DIRINIT = 0;
}
/* close the audit control file */
void
endac()
{
}
DIRINIT = 0;
}
int
testac()
{
return (1);
return (0);
}