3 # Copyright (c) 2002-2003
\r
4 # The President and Fellows of Harvard College.
\r
6 # Redistribution and use in source and binary forms, with or without
\r
7 # modification, are permitted provided that the following conditions
\r
9 # 1. Redistributions of source code must retain the above copyright
\r
10 # notice, this list of conditions and the following disclaimer.
\r
11 # 2. Redistributions in binary form must reproduce the above copyright
\r
12 # notice, this list of conditions and the following disclaimer in the
\r
13 # documentation and/or other materials provided with the distribution.
\r
14 # 3. Neither the name of the University nor the names of its contributors
\r
15 # may be used to endorse or promote products derived from this software
\r
16 # without specific prior written permission.
\r
18 # THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
\r
19 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
20 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
\r
21 # ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
\r
22 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
\r
23 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
\r
24 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
\r
25 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
\r
26 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
\r
27 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
\r
30 # $Id: ns_split,v 1.4 2003/07/28 14:27:17 ellard Exp $
\r
35 $ProgDir =~ /(^.*)\//;
\r
41 require "$ProgDir/userUtils.pl";
\r
52 Usage: $0 [options] [table1.ns [table2.ns ... ]]
\r
54 If no table files are specified, then the input is read from stdin.
\r
56 Command line options:
\r
58 -h Print usage message and exit.
\r
60 -c c1[,c2]* Include only activity performed by the specified clients.
\r
62 -C c1[,c2]* Exclude activity performed by the specified clients.
\r
64 -g g1[,g2]* Include only activity performed by the specified groups.
\r
66 -G g1[,g2]* Exclude activity performed by the specified groups.
\r
68 -u u1[,u2]* Include only activity performed by the specified users.
\r
70 -U u1[,u2]* Exclude activity performed by the specified users.
\r
74 $cmdline = "$0 " . join (' ', @ARGV);
\r
75 $Options = "c:C:g:G:u:U::";
\r
76 if (! getopts ($Options)) {
\r
77 print STDERR "$0: Incorrect usage.\n";
\r
78 print STDERR $Usage;
\r
81 if (defined $opt_h) {
\r
86 if (defined $opt_u) {
\r
87 @ADD_USERS = &logins2uids ($opt_u);
\r
89 if (defined $opt_U) {
\r
90 @DEL_USERS = &logins2uids ($opt_U);
\r
92 if (defined $opt_g) {
\r
93 @ADD_GROUPS = &groups2gids ($opt_g);
\r
95 if (defined $opt_G) {
\r
96 @DEL_GROUPS = &groups2gids ($opt_G);
\r
98 if (defined $opt_c) {
\r
99 @ADD_CLIENTS = split (/,/, $opt_c);
\r
101 if (defined $opt_C) {
\r
102 @DEL_CLIENTS = split (/,/, $opt_C);
\r
105 print "#cmdline $cmdline\n";
\r
113 my ($type, $time, $client, $fh, $euid, $egid, @vals) = split (' ', $l);
\r
115 next unless ($type eq 'C');
\r
117 # Something wrong with the input?
\r
119 next if (@vals == 0);
\r
121 if (saveRecord ($client, $fh, $euid, $egid)) {
\r
127 my ($client, $fh, $euid, $egid) = @_;
\r
129 if (@ADD_CLIENTS && !grep (/^$client$/, @ADD_CLIENTS)) {
\r
132 if (@DEL_CLIENTS && grep (/^$client$/, @DEL_CLIENTS)) {
\r
136 if (@ADD_USERS && !grep (/^$euid$/, @ADD_USERS)) {
\r
139 if (@DEL_USERS && grep (/^$euid$/, @DEL_USERS)) {
\r
143 if (@ADD_GROUPS && !grep (/^$egid$/, @ADD_GROUPS)) {
\r
146 if (@DEL_GROUPS && grep (/^$egid$/, @DEL_GROUPS)) {
\r