1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _AUDITRT_H 28*7c478bd9Sstevel@tonic-gate #define _AUDITRT_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 33*7c478bd9Sstevel@tonic-gate extern "C" { 34*7c478bd9Sstevel@tonic-gate #endif 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate /* 37*7c478bd9Sstevel@tonic-gate * Auditreduce data structures. 38*7c478bd9Sstevel@tonic-gate */ 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate /* 41*7c478bd9Sstevel@tonic-gate * File Control Block 42*7c478bd9Sstevel@tonic-gate * Controls a single file. 43*7c478bd9Sstevel@tonic-gate * These are held by the pcb's in audit_pcbs[] in a linked list. 44*7c478bd9Sstevel@tonic-gate * There is one fcb for each file controlled by the pcb, 45*7c478bd9Sstevel@tonic-gate * and all of the files in a list have the same suffix in their names. 46*7c478bd9Sstevel@tonic-gate */ 47*7c478bd9Sstevel@tonic-gate struct audit_fcb { 48*7c478bd9Sstevel@tonic-gate struct audit_fcb *fcb_next; /* ptr to next fcb in list */ 49*7c478bd9Sstevel@tonic-gate int fcb_flags; /* flags - see below */ 50*7c478bd9Sstevel@tonic-gate time_t fcb_start; /* start time from filename */ 51*7c478bd9Sstevel@tonic-gate time_t fcb_end; /* end time from filename */ 52*7c478bd9Sstevel@tonic-gate char *fcb_suffix; /* ptr to suffix in fcb_file */ 53*7c478bd9Sstevel@tonic-gate char *fcb_name; /* ptr to name in fcb_file */ 54*7c478bd9Sstevel@tonic-gate char fcb_file[1]; /* full path and name string */ 55*7c478bd9Sstevel@tonic-gate }; 56*7c478bd9Sstevel@tonic-gate 57*7c478bd9Sstevel@tonic-gate typedef struct audit_fcb audit_fcb_t; 58*7c478bd9Sstevel@tonic-gate 59*7c478bd9Sstevel@tonic-gate /* 60*7c478bd9Sstevel@tonic-gate * Flags for fcb_flags. 61*7c478bd9Sstevel@tonic-gate */ 62*7c478bd9Sstevel@tonic-gate #define FF_NOTTERM 0x01 /* file is "not_terminated" */ 63*7c478bd9Sstevel@tonic-gate #define FF_DELETE 0x02 /* we may delete this file if requested */ 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate /* 66*7c478bd9Sstevel@tonic-gate * Process Control Block 67*7c478bd9Sstevel@tonic-gate * A pcb comes in two types: 68*7c478bd9Sstevel@tonic-gate * It controls either: 69*7c478bd9Sstevel@tonic-gate * 70*7c478bd9Sstevel@tonic-gate * 1. A single group of pcbs (processes that are lower on the process tree). 71*7c478bd9Sstevel@tonic-gate * These are the pcb's that the process tree is built from. 72*7c478bd9Sstevel@tonic-gate * These are allocated as needed while the process tree is being built. 73*7c478bd9Sstevel@tonic-gate * 74*7c478bd9Sstevel@tonic-gate * 2. A single group of files (fcbs). 75*7c478bd9Sstevel@tonic-gate * All of the files in one pcb have the same suffix in their filename. 76*7c478bd9Sstevel@tonic-gate * They are controlled by the leaf nodes of the process tree. 77*7c478bd9Sstevel@tonic-gate * They are found in audit_pcbs[]. 78*7c478bd9Sstevel@tonic-gate * They are initially setup by process_fileopt() when the files to be 79*7c478bd9Sstevel@tonic-gate * processes are gathered together. Then they are parsed out to 80*7c478bd9Sstevel@tonic-gate * the leaf nodes by mfork(). 81*7c478bd9Sstevel@tonic-gate * A particular leaf node's range of audit_pcbs[] is determined 82*7c478bd9Sstevel@tonic-gate * in the call to mfork() by the lo and hi paramters. 83*7c478bd9Sstevel@tonic-gate */ 84*7c478bd9Sstevel@tonic-gate struct audit_pcb { 85*7c478bd9Sstevel@tonic-gate struct audit_pcb *pcb_below; /* ptr to group of pcb's */ 86*7c478bd9Sstevel@tonic-gate struct audit_pcb *pcb_next; /* ptr to next - for list in mproc() */ 87*7c478bd9Sstevel@tonic-gate int pcb_procno; /* subprocess # */ 88*7c478bd9Sstevel@tonic-gate int pcb_nrecs; /* how many records read (current pcb/file) */ 89*7c478bd9Sstevel@tonic-gate int pcb_nprecs; /* how many records put (current pcb/file) */ 90*7c478bd9Sstevel@tonic-gate int pcb_flags; /* flags - see below */ 91*7c478bd9Sstevel@tonic-gate int pcb_count; /* count of active pcb's */ 92*7c478bd9Sstevel@tonic-gate int pcb_lo; /* low index for pcb's */ 93*7c478bd9Sstevel@tonic-gate int pcb_hi; /* hi index for pcb's */ 94*7c478bd9Sstevel@tonic-gate int pcb_size; /* size of current record buffer */ 95*7c478bd9Sstevel@tonic-gate time_t pcb_time; /* time of current record */ 96*7c478bd9Sstevel@tonic-gate time_t pcb_otime; /* time of previous record */ 97*7c478bd9Sstevel@tonic-gate char *pcb_rec; /* ptr to current record buffer */ 98*7c478bd9Sstevel@tonic-gate char *pcb_suffix; /* ptr to suffix name (string) */ 99*7c478bd9Sstevel@tonic-gate audit_fcb_t *pcb_first; /* ptr to first fcb_ */ 100*7c478bd9Sstevel@tonic-gate audit_fcb_t *pcb_last; /* ptr to last fcb_ */ 101*7c478bd9Sstevel@tonic-gate audit_fcb_t *pcb_cur; /* ptr to current fcb_ */ 102*7c478bd9Sstevel@tonic-gate audit_fcb_t *pcb_dfirst; /* ptr to first fcb_ for deleting */ 103*7c478bd9Sstevel@tonic-gate audit_fcb_t *pcb_dlast; /* ptr to last fcb_ for deleting */ 104*7c478bd9Sstevel@tonic-gate FILE *pcb_fpr; /* read stream */ 105*7c478bd9Sstevel@tonic-gate FILE *pcb_fpw; /* write stream */ 106*7c478bd9Sstevel@tonic-gate }; 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate typedef struct audit_pcb audit_pcb_t; 109*7c478bd9Sstevel@tonic-gate 110*7c478bd9Sstevel@tonic-gate /* 111*7c478bd9Sstevel@tonic-gate * Flags for pcb_flags 112*7c478bd9Sstevel@tonic-gate */ 113*7c478bd9Sstevel@tonic-gate #define PF_ROOT 0x01 /* current pcb is the root of process tree */ 114*7c478bd9Sstevel@tonic-gate #define PF_LEAF 0x02 /* current pcb is a leaf of process tree */ 115*7c478bd9Sstevel@tonic-gate #define PF_FILE 0x04 /* current pcb uses files as input, not pipes */ 116*7c478bd9Sstevel@tonic-gate 117*7c478bd9Sstevel@tonic-gate /* 118*7c478bd9Sstevel@tonic-gate * Message selection options 119*7c478bd9Sstevel@tonic-gate */ 120*7c478bd9Sstevel@tonic-gate #define M_AFTER 0x0001 /* 'a' after a time */ 121*7c478bd9Sstevel@tonic-gate #define M_BEFORE 0x0002 /* 'b' before a time */ 122*7c478bd9Sstevel@tonic-gate #define M_CLASS 0x0004 /* 'c' event class */ 123*7c478bd9Sstevel@tonic-gate #define M_GROUPE 0x0008 /* 'f' effective group-id */ 124*7c478bd9Sstevel@tonic-gate #define M_GROUPR 0x0010 /* 'g' real group-id */ 125*7c478bd9Sstevel@tonic-gate #define M_OBJECT 0x0020 /* 'o' object */ 126*7c478bd9Sstevel@tonic-gate #define M_SUBJECT 0x0040 /* 'j' subject */ 127*7c478bd9Sstevel@tonic-gate #define M_TYPE 0x0080 /* 'm' event type */ 128*7c478bd9Sstevel@tonic-gate #define M_USERA 0x0100 /* 'u' audit user */ 129*7c478bd9Sstevel@tonic-gate #define M_USERE 0x0200 /* 'e' effective user */ 130*7c478bd9Sstevel@tonic-gate #define M_USERR 0x0400 /* 'r' real user */ 131*7c478bd9Sstevel@tonic-gate #define M_SLABEL 0x0800 /* 's' sensitivity label range */ 132*7c478bd9Sstevel@tonic-gate #define M_ZONENAME 0x1000 /* 'z' zone name */ 133*7c478bd9Sstevel@tonic-gate #define M_SORF 0x4000 /* success or failure of event */ 134*7c478bd9Sstevel@tonic-gate /* 135*7c478bd9Sstevel@tonic-gate * object types 136*7c478bd9Sstevel@tonic-gate */ 137*7c478bd9Sstevel@tonic-gate 138*7c478bd9Sstevel@tonic-gate /* XXX Why is this a bit map? There can be only one M_OBJECT. */ 139*7c478bd9Sstevel@tonic-gate 140*7c478bd9Sstevel@tonic-gate #define OBJ_LP 0x00001 /* 'o' lp object */ 141*7c478bd9Sstevel@tonic-gate #define OBJ_MSG 0x00002 /* 'o' msgq object */ 142*7c478bd9Sstevel@tonic-gate #define OBJ_PATH 0x00004 /* 'o' file system object */ 143*7c478bd9Sstevel@tonic-gate #define OBJ_PROC 0x00008 /* 'o' process object */ 144*7c478bd9Sstevel@tonic-gate #define OBJ_SEM 0x00010 /* 'o' semaphore object */ 145*7c478bd9Sstevel@tonic-gate #define OBJ_SHM 0x00020 /* 'o' shared memory object */ 146*7c478bd9Sstevel@tonic-gate #define OBJ_SOCK 0x00040 /* 'o' socket object */ 147*7c478bd9Sstevel@tonic-gate #define OBJ_FGROUP 0x00080 /* 'o' file group */ 148*7c478bd9Sstevel@tonic-gate #define OBJ_FOWNER 0x00100 /* 'o' file owner */ 149*7c478bd9Sstevel@tonic-gate #define OBJ_MSGGROUP 0x00200 /* 'o' msgq [c]group */ 150*7c478bd9Sstevel@tonic-gate #define OBJ_MSGOWNER 0x00400 /* 'o' msgq [c]owner */ 151*7c478bd9Sstevel@tonic-gate #define OBJ_PGROUP 0x00800 /* 'o' process [e]group */ 152*7c478bd9Sstevel@tonic-gate #define OBJ_POWNER 0x01000 /* 'o' process [e]owner */ 153*7c478bd9Sstevel@tonic-gate #define OBJ_SEMGROUP 0x02000 /* 'o' semaphore [c]group */ 154*7c478bd9Sstevel@tonic-gate #define OBJ_SEMOWNER 0x04000 /* 'o' semaphore [c]owner */ 155*7c478bd9Sstevel@tonic-gate #define OBJ_SHMGROUP 0x08000 /* 'o' shared memory [c]group */ 156*7c478bd9Sstevel@tonic-gate #define OBJ_SHMOWNER 0x10000 /* 'o' shared memory [c]owner */ 157*7c478bd9Sstevel@tonic-gate 158*7c478bd9Sstevel@tonic-gate #define SOCKFLG_MACHINE 0 /* search socket token by machine name */ 159*7c478bd9Sstevel@tonic-gate #define SOCKFLG_PORT 1 /* search socket token by port number */ 160*7c478bd9Sstevel@tonic-gate 161*7c478bd9Sstevel@tonic-gate /* 162*7c478bd9Sstevel@tonic-gate * Global variables 163*7c478bd9Sstevel@tonic-gate */ 164*7c478bd9Sstevel@tonic-gate extern unsigned short m_type; /* 'm' message type */ 165*7c478bd9Sstevel@tonic-gate extern gid_t m_groupr; /* 'g' real group-id */ 166*7c478bd9Sstevel@tonic-gate extern gid_t m_groupe; /* 'f' effective group-id */ 167*7c478bd9Sstevel@tonic-gate extern uid_t m_usera; /* 'u' audit user */ 168*7c478bd9Sstevel@tonic-gate extern uid_t m_userr; /* 'r' real user */ 169*7c478bd9Sstevel@tonic-gate extern uid_t m_usere; /* 'f' effective user */ 170*7c478bd9Sstevel@tonic-gate extern time_t m_after; /* 'a' after a time */ 171*7c478bd9Sstevel@tonic-gate extern time_t m_before; /* 'b' before a time */ 172*7c478bd9Sstevel@tonic-gate extern audit_state_t mask; /* used with m_class */ 173*7c478bd9Sstevel@tonic-gate extern char *zonename; /* 'z' zonename */ 174*7c478bd9Sstevel@tonic-gate 175*7c478bd9Sstevel@tonic-gate #ifdef TSOL 176*7c478bd9Sstevel@tonic-gate extern brange_t m_slabel; /* 's' sensitivity label range */ 177*7c478bd9Sstevel@tonic-gate #endif /* TSOL */ 178*7c478bd9Sstevel@tonic-gate extern int flags; 179*7c478bd9Sstevel@tonic-gate extern int checkflags; 180*7c478bd9Sstevel@tonic-gate extern int socket_flag; 181*7c478bd9Sstevel@tonic-gate extern int ip_type; 182*7c478bd9Sstevel@tonic-gate extern int ip_ipv6[4]; /* ip ipv6 object identifier */ 183*7c478bd9Sstevel@tonic-gate extern int obj_flag; /* 'o' object type */ 184*7c478bd9Sstevel@tonic-gate extern int obj_id; /* object identifier */ 185*7c478bd9Sstevel@tonic-gate extern gid_t obj_group; /* object group */ 186*7c478bd9Sstevel@tonic-gate extern uid_t obj_owner; /* object owner */ 187*7c478bd9Sstevel@tonic-gate extern int subj_id; /* subject identifier */ 188*7c478bd9Sstevel@tonic-gate extern char ipc_type; /* 'o' object type - tell what type of IPC */ 189*7c478bd9Sstevel@tonic-gate 190*7c478bd9Sstevel@tonic-gate /* 191*7c478bd9Sstevel@tonic-gate * File selection options 192*7c478bd9Sstevel@tonic-gate */ 193*7c478bd9Sstevel@tonic-gate extern char *f_machine; /* 'M' machine (suffix) type */ 194*7c478bd9Sstevel@tonic-gate extern char *f_root; /* 'R' audit root */ 195*7c478bd9Sstevel@tonic-gate extern char *f_server; /* 'S' server */ 196*7c478bd9Sstevel@tonic-gate extern char *f_outfile; /* 'W' output file */ 197*7c478bd9Sstevel@tonic-gate extern int f_all; /* 'A' all records from a file */ 198*7c478bd9Sstevel@tonic-gate extern int f_complete; /* 'C' only completed files */ 199*7c478bd9Sstevel@tonic-gate extern int f_delete; /* 'D' delete when done */ 200*7c478bd9Sstevel@tonic-gate extern int f_quiet; /* 'Q' sshhhh! */ 201*7c478bd9Sstevel@tonic-gate extern int f_verbose; /* 'V' verbose */ 202*7c478bd9Sstevel@tonic-gate extern int f_stdin; /* '-' read from stdin */ 203*7c478bd9Sstevel@tonic-gate extern int f_cmdline; /* files specified on the command line */ 204*7c478bd9Sstevel@tonic-gate extern int new_mode; /* 'N' new object selection mode */ 205*7c478bd9Sstevel@tonic-gate 206*7c478bd9Sstevel@tonic-gate /* 207*7c478bd9Sstevel@tonic-gate * Error reporting 208*7c478bd9Sstevel@tonic-gate * Error_str is set whenever an error occurs to point to a string describing 209*7c478bd9Sstevel@tonic-gate * the error. When the error message is printed error_str is also 210*7c478bd9Sstevel@tonic-gate * printed to describe exactly what went wrong. 211*7c478bd9Sstevel@tonic-gate * Errbuf is used to build messages with variables in them. 212*7c478bd9Sstevel@tonic-gate */ 213*7c478bd9Sstevel@tonic-gate extern char *error_str; /* current error message */ 214*7c478bd9Sstevel@tonic-gate extern char errbuf[]; /* buffer for building error message */ 215*7c478bd9Sstevel@tonic-gate extern char *ar; /* => "auditreduce:" */ 216*7c478bd9Sstevel@tonic-gate 217*7c478bd9Sstevel@tonic-gate /* 218*7c478bd9Sstevel@tonic-gate * Control blocks 219*7c478bd9Sstevel@tonic-gate * Audit_pcbs[] is an array of pcbs that control files directly. 220*7c478bd9Sstevel@tonic-gate * In the program's initialization phase it will gather all of the input 221*7c478bd9Sstevel@tonic-gate * files it needs to process. Each file will have one fcb allocated for it, 222*7c478bd9Sstevel@tonic-gate * and each fcb will belong to one pcb from audit_pcbs[]. All of the files 223*7c478bd9Sstevel@tonic-gate * in a single pcb will have the same suffix in their filenames. If the 224*7c478bd9Sstevel@tonic-gate * number of active pcbs in audit_pcbs[] is greater that the number of open 225*7c478bd9Sstevel@tonic-gate * files a single process can have then the program will need to fork 226*7c478bd9Sstevel@tonic-gate * subprocesses to handle all of the files. 227*7c478bd9Sstevel@tonic-gate */ 228*7c478bd9Sstevel@tonic-gate extern audit_pcb_t *audit_pcbs; /* file-holding pcb's */ 229*7c478bd9Sstevel@tonic-gate extern int pcbsize; /* current size of audit_pcbs[] */ 230*7c478bd9Sstevel@tonic-gate extern int pcbnum; /* total # of active pcbs in audit_pcbs[] */ 231*7c478bd9Sstevel@tonic-gate 232*7c478bd9Sstevel@tonic-gate /* 233*7c478bd9Sstevel@tonic-gate * Time values 234*7c478bd9Sstevel@tonic-gate */ 235*7c478bd9Sstevel@tonic-gate extern time_t f_start; /* time of start rec for outfile */ 236*7c478bd9Sstevel@tonic-gate extern time_t f_end; /* time of end rec for outfile */ 237*7c478bd9Sstevel@tonic-gate extern time_t time_now; /* time program began */ 238*7c478bd9Sstevel@tonic-gate 239*7c478bd9Sstevel@tonic-gate /* 240*7c478bd9Sstevel@tonic-gate * Counting vars 241*7c478bd9Sstevel@tonic-gate */ 242*7c478bd9Sstevel@tonic-gate extern int filenum; /* number of files total */ 243*7c478bd9Sstevel@tonic-gate 244*7c478bd9Sstevel@tonic-gate /* 245*7c478bd9Sstevel@tonic-gate * Global variable, class of current record being processed. 246*7c478bd9Sstevel@tonic-gate */ 247*7c478bd9Sstevel@tonic-gate extern int global_class; 248*7c478bd9Sstevel@tonic-gate 249*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 250*7c478bd9Sstevel@tonic-gate } 251*7c478bd9Sstevel@tonic-gate #endif 252*7c478bd9Sstevel@tonic-gate 253*7c478bd9Sstevel@tonic-gate #endif /* _AUDITRT_H */ 254