4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
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.
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]
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
27 * Extend regular expression matching for the file objects to allow
28 * multiple regular expressions (instead of just 1), and to not select
29 * regular expressions starting with a "~". This will allow adminstrator
30 * to exclude uninteresting files from the audit trail.
38 char *s
; /* The regular is expression */
39 int not; /* Exclude if matched? */
40 char *comp
; /* The compiled regular expression */
43 static char SEP
= ','; /* separator used between reg exprs */
44 static char NOT
= '~'; /* Character used to exclude rex exprs */
45 static int compile
= 1; /* Must we compile the expressions */
47 static char *fexp
= NULL
; /* full list of regular expressions */
48 static int nexp
= 1; /* number of regular expressions in fexp */
49 static struct exp
*p_exp
= NULL
; /* list of individual expressions */
57 static char *er
= "regcmp: error";
61 for (i
= 0; i
< nexp
; i
++)
62 if (p_exp
[i
].comp
!= NULL
)
70 for (p
= fexp
, nexp
= 1; *p
!= '\0'; p
++) {
75 p_exp
= (struct exp
*)malloc(nexp
* sizeof (struct exp
));
76 for (i
= 0, p
= fexp
; *p
!= '\0'; i
++) {
85 while (*p
!= SEP
&& *p
!= '\0')
91 if (regcmp(p_exp
[i
].s
, NULL
) == NULL
)
105 for (i
= 0; i
< nexp
; i
++) {
106 if ((p_exp
[i
].comp
= regcmp(p_exp
[i
].s
, NULL
)) == NULL
)
111 for (i
= 0; i
< nexp
; i
++) {
112 ret
= regex(p_exp
[i
].comp
, s
);
114 return (!p_exp
[i
].not);
118 /* no match and no more to check */