2 # Updates an acl file to include new modules. Called with the parameters
3 # <config directory> <module>+
5 for($i=1; $i<@ARGV; $i++) {
6 if (!(-d "$ARGV[0]/$ARGV[$i]")) {
12 # Read in the existing file
13 open(ACL, "$ARGV[0]/webmin.acl");
17 # Get the list of users to grant new modules to
18 if (open(NEWMODS, "$ARGV[0]/newmodules")) {
21 $users{$_}++ if (/\S/);
28 # Find the users to add to
29 for($i=0; $i<@acl; $i++) {
30 if ($acl[$i] =~ /^(\S+):/ && $users{$1}) {
36 # Just use 'root' or 'admin' or the first user in the file
38 for($i=0; $i<@acl; $i++) {
39 if ($acl[$i] =~ /^(\S+):/ &&
40 ($1 eq 'root' || $1 eq 'admin')) {
47 # Update it with new modules
49 $acl[$pos] =~ /^(\S+):\s*(.*)$/ || next;
50 $name = $1; @list = split(/\s+/, $2);
51 foreach $o (@list) { $old{$o}++; }
53 push(@list, $n) if (!$old{$n});
55 $acl[$pos] = "$name: ".join(" ",@list)."\n";
59 open(ACL, ">$ARGV[0]/webmin.acl");