changeset 2967:79257f1a9a24

6475360 bsmrecord -c is counter intuitive and seems way broken.
author tz204579
date Mon, 23 Oct 2006 06:03:44 -0700
parents b5ead0c5a8bf
children 77abf329e9ed
files usr/src/cmd/bsmrecord/bsmrecord.pl usr/src/cmd/perl/contrib/Sun/Solaris/BSM/_BSMparse.pm
diffstat 2 files changed, 43 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/bsmrecord/bsmrecord.pl	Sun Oct 22 21:39:09 2006 -0700
+++ b/usr/src/cmd/bsmrecord/bsmrecord.pl	Mon Oct 23 06:03:44 2006 -0700
@@ -3,9 +3,8 @@
 # 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.
+# 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
 # or http://www.opensolaris.org/os/licensing.
@@ -21,7 +20,7 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # ident	"%Z%%M%	%I%	%E% SMI"
@@ -106,6 +105,19 @@
 	print STDERR $error if ($cnt);
 }
 
+# check for invalid class to -c option if supplied
+if (defined $options{'classFilter'}) {
+	my $invalidClass = gettext('Invalid class %s supplied.');
+	my $isInvalidClass = 0;
+	foreach (split(/\s*,\s*/, $options{'classFilter'})) {
+		unless (exists $class{$_}) {
+			printf STDERR "$invalidClass\n", $_;
+			$isInvalidClass = 1;
+		}
+	}
+	exit (1) if $isInvalidClass;
+}
+
 if ($html) {
 	writeHTML();
 } else {
@@ -436,7 +448,7 @@
 			next;
 		}
 		$skipThisClass = 1 if ($skipClass{$thisClass});
-		$mask +=  $class{$thisClass};
+		$mask |=  $class{$thisClass};
 	}
 	return ($skipThisClass, $mask);
 }
--- a/usr/src/cmd/perl/contrib/Sun/Solaris/BSM/_BSMparse.pm	Sun Oct 22 21:39:09 2006 -0700
+++ b/usr/src/cmd/perl/contrib/Sun/Solaris/BSM/_BSMparse.pm	Mon Oct 23 06:03:44 2006 -0700
@@ -1,13 +1,12 @@
 #
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # 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.
+# 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
 # or http://www.opensolaris.org/os/licensing.
@@ -127,7 +126,7 @@
 			if (/^\s*skipClass\s*=\s*(.*)/i) {
 				my $class = $1;
 				# don't skip what you're searching for
-				next if (lc ($classFilter) eq lc ($class));
+				next if (index(lc($classFilter),lc($class)) > -1);
 				$skipClass{$1} = 1;
 				next;
 			}
@@ -247,9 +246,16 @@
 
 	my $count = 0;
 
+	unless (defined $obj->{'class'} && (scalar keys %{$obj->{'class'}} > 1)) {
+		$obj->readClass();
+	}
+
+	my @classFilterMasks = ();
 	my $classFilter = $obj->{'classFilter'};
 	if ($classFilter) {
-		$classFilter = qr/^$classFilter$/i;
+		foreach (split(',', $classFilter)) {
+			push @classFilterMasks, $obj->{'class'}{$_};
+		}
 	}
 	# ignore customer-supplied audit events (id > 32767)
 
@@ -277,8 +283,19 @@
 				} if ($event{$label});
 			}
 			next unless ($obj->filterLabel($label));
+			my $mask = 0;
 			if ($classFilter) {
-				next unless ($class =~ $classFilter);
+				foreach (split(/\s*,\s*/, $class)) {
+					$mask |= $obj->{'class'}{$_};
+				}
+				my $skip = 0;
+				foreach my $filterMask (@classFilterMasks) {
+					unless ($mask & $filterMask) {
+						$skip = 1;
+						last;
+					}
+				}
+				next if $skip;
 			}
 			if ($obj->{'idFilter'}) {
 				next unless ($obj->{'idFilter'} == $id);
@@ -383,6 +400,7 @@
 			my @class = split(/\s*,\s*/, $class);
 
 			foreach $class (@class) {
+				$class =~ s/^[-+^]+//;
 				unless (defined ($class{$class})) {
 					$errors .=
 					    sprintf("$invalidClass\n",
@@ -462,13 +480,12 @@
 			$cError++;
 			next;
 		}
-		$never = '' unless defined $never;
 		my $verify = $always . ',' . $never;
-		$verify =~ s/[^+]//;
 		my @class = split(/\s*,\s*/, $verify);
 		my $thisClass;
 
 		foreach $thisClass (@class) {
+			$thisClass =~ s/^[-+^]+//;
 			unless (defined $class{$thisClass}) {
 				$error .= sprintf("$invalidErr\n", $thisClass,
 				    $_);