-
Notifications
You must be signed in to change notification settings - Fork 8
/
editUsersAcl
executable file
·96 lines (74 loc) · 1.96 KB
/
editUsersAcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/perl -w
# This code is a part of Slash, and is released under the GPL.
# Copyright 1997-2005 by Open Source Technology Group. See README
# and COPYING for more information, or see http://slashcode.com/.
# $Id$
use strict;
use File::Basename;
use Getopt::Std;
use Slash;
use Slash::Utility;
use Benchmark;
use vars qw( $slashdb $constants );
(my $VERSION) = ' $Revision$ ' =~ /\$Revision:\s+([^\s]+)/;
my $PROGNAME = basename($0);
my %opts;
# Remember to doublecheck these match usage()!
usage('Options used incorrectly') unless getopts('hu:vaU:dl', \%opts);
usage() if $opts{'h'};
version() if $opts{'v'};
usage("You must supply either -a, -d, or -l") unless $opts{'a'} || $opts{'d'} || $opts{'l'};
usage("You must supply a UID") unless $opts{'U'};
$opts{'u'} ||= 'slash';
createEnvironment($opts{u});
$slashdb = getCurrentDB();
$constants = getCurrentStatic();
main();
sub main {
my %hash;
if ($opts{'a'}) {
for(@ARGV) {
$hash{$_} = 1;
}
} elsif ($opts{'d'}) {
for(@ARGV) {
$hash{$_} = 0;
}
}
if (keys %hash) {
$slashdb->setUser($opts{'U'}, { acl => \%hash });
}
my $user = $slashdb->getUser($opts{'U'});
print "$user->{nickname} current ACL's\n";
for (keys (%{$user->{acl}})) {
print "\t$_\n";
}
}
sub usage {
print "*** $_[0]\n" if $_[0];
# Remember to doublecheck these match getopts()!
print <<EOT;
Usage: $PROGNAME [OPTIONS] [acls..]
This utility builds test Zoo users. It basically makes everyone related to everyone else.
You probably don't want to run this.
Main options:
-h Help (this message)
-v Version
-u Virtual user (default is "slash")
-U A uid to add or delete ACL from
-a Add the following ACL's
-l List the user's ACL
-d Delete the following ACL's
EOT
exit;
}
sub version {
print <<EOT;
$PROGNAME $VERSION
This code is a part of Slash, and is released under the GPL.
Copyright 1997-2005 by Open Source Technology Group. See README
and COPYING for more information, or see http://slashcode.com/.
EOT
exit;
}
__END__