5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 /*
28 * The Secure SunOS audit reduction tool - auditreduce.
29 * Document SM0071 is the primary source of information on auditreduce.
30 *
31 * Composed of 4 source modules:
32 * main.c - main driver.
33 * option.c - command line option processing.
34 * process.c - record/file/process functions.
35 * time.c - date/time handling.
36 *
37 * Main(), write_header(), audit_stats(), and a_calloc()
38 * are the only functions visible outside this module.
39 */
40
41 #include <siginfo.h>
42 #include <locale.h>
43 #include <libintl.h>
44 #include "auditr.h"
64 static int init_sig(void);
65 static void int_handler(int);
66 static int mfork(audit_pcb_t *, int, int, int);
67 static void mcount(int, int);
68 static int open_outfile(void);
69 static void p_close(audit_pcb_t *);
70 static int rename_outfile(void);
71 static void rm_mem(audit_pcb_t *);
72 static void rm_outfile(void);
73 static void trim_mem(audit_pcb_t *);
74 static int write_file_token(time_t);
75 static int write_trailer(void);
76
77 /*
78 * File globals.
79 */
80 static int max_sproc; /* maximum number of subprocesses per process */
81 static int total_procs; /* number of processes in the process tree */
82 static int total_layers; /* number of layers in the process tree */
83
84 /*
85 * .func main - main.
86 * .desc The beginning. Main() calls each of the initialization routines
87 * and then allocates the root pcb. Then it calls mfork() to get
88 * the work done.
89 * .call main(argc, argv).
90 * .arg argc - number of arguments.
91 * .arg argv - array of pointers to arguments.
92 * .ret 0 - via exit() - no errors detected.
93 * .ret 1 - via exit() - errors detected (messages printed).
94 */
95 int
96 main(int argc, char **argv)
97 {
98 int ret;
99 audit_pcb_t *pcb;
100
101 /* Internationalization */
102 (void) setlocale(LC_ALL, "");
103 (void) textdomain(TEXT_DOMAIN);
|
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 *
26 * Copyright 2018 Nexenta Systems, Inc. All rights reserved.
27 */
28
29 /*
30 * The Secure SunOS audit reduction tool - auditreduce.
31 * Document SM0071 is the primary source of information on auditreduce.
32 *
33 * Composed of 4 source modules:
34 * main.c - main driver.
35 * option.c - command line option processing.
36 * process.c - record/file/process functions.
37 * time.c - date/time handling.
38 *
39 * Main(), write_header(), audit_stats(), and a_calloc()
40 * are the only functions visible outside this module.
41 */
42
43 #include <siginfo.h>
44 #include <locale.h>
45 #include <libintl.h>
46 #include "auditr.h"
66 static int init_sig(void);
67 static void int_handler(int);
68 static int mfork(audit_pcb_t *, int, int, int);
69 static void mcount(int, int);
70 static int open_outfile(void);
71 static void p_close(audit_pcb_t *);
72 static int rename_outfile(void);
73 static void rm_mem(audit_pcb_t *);
74 static void rm_outfile(void);
75 static void trim_mem(audit_pcb_t *);
76 static int write_file_token(time_t);
77 static int write_trailer(void);
78
79 /*
80 * File globals.
81 */
82 static int max_sproc; /* maximum number of subprocesses per process */
83 static int total_procs; /* number of processes in the process tree */
84 static int total_layers; /* number of layers in the process tree */
85
86 char errbuf[ERRBUF_SZ]; /* for creating error messages with sprintf */
87
88 /*
89 * .func main - main.
90 * .desc The beginning. Main() calls each of the initialization routines
91 * and then allocates the root pcb. Then it calls mfork() to get
92 * the work done.
93 * .call main(argc, argv).
94 * .arg argc - number of arguments.
95 * .arg argv - array of pointers to arguments.
96 * .ret 0 - via exit() - no errors detected.
97 * .ret 1 - via exit() - errors detected (messages printed).
98 */
99 int
100 main(int argc, char **argv)
101 {
102 int ret;
103 audit_pcb_t *pcb;
104
105 /* Internationalization */
106 (void) setlocale(LC_ALL, "");
107 (void) textdomain(TEXT_DOMAIN);
|