3 # Display a form for editing the ACL for some module for some user or group
5 require './cluster-usermin-lib.pl';
8 # Get hosts and module details
9 @hosts = &list_webmin_hosts();
10 if ($in{'whohost'} =~ /^(\d+),(\S*)$/) {
11 # Coming from the module page, so know which host to look at
12 ($host) = grep { $_->{'id'} == $1 } @hosts;
13 local ($u) = grep { $_->{'name'} eq $2 } @{$host->{'users'}};
14 local ($g) = grep { $_->{'name'} eq $2 } @{$host->{'groups'}};
17 ($mod) = grep { $_->{'dir'} eq $in{'mod'} } @{$host->{'modules'}};
19 elsif ($in{'modhost'} =~ /^(\d+),(\S*)$/) {
20 # Coming from the user or group page, so know which host to look at
21 ($host) = grep { $_->{'id'} == $1 } @hosts;
22 ($mod) = grep { $_->{'dir'} eq $2 } @{$host->{'modules'}};
24 ($user) = grep { $_->{'name'} eq $in{'user'} } @{$host->{'users'}};
27 ($group) = grep { $_->{'name'} eq $in{'group'} } @{$host->{'groups'}};
31 # Find a host that has the user and module
32 foreach $h (sort { $a->{'id'} <=> $b->{'id'} } @hosts) {
33 local ($m) = grep { $_->{'dir'} eq $in{'mod'} } @{$h->{'modules'}};
35 local ($u) = grep { $_->{'name'} eq $in{'user'} }
37 if ($u && (&indexof($in{'mod'}, @{$u->{'modules'}}) >= 0 ||
46 local ($g) = grep { $_->{'name'} eq $in{'group'} }
48 if ($g && (&indexof($in{'mod'}, @{$g->{'modules'}}) >= 0 ||
57 $host || &error(&text('acl_efound',
58 $in{'user'} ? $in{'user'} : $in{'group'}, $in{'mod'}));
60 $who = $user ? $user->{'name'} : $group->{'name'};
61 @servers = &list_servers();
62 ($serv) = grep { $_->{'id'} == $host->{'id'} } @servers;
63 $d = &server_name($serv);
65 $ga = "_ga" if (!$mod->{'dir'});
66 $desc = &text($user ? 'acl_title2'.$ga : 'acl_title3'.$ga,
67 "<b>$who</b>", "<b>$mod->{'desc'}</b>", "<b>$d</b>");
68 &ui_print_header($desc, $text{'acl_title'}, "");
70 # Get the host's ACL options
71 &remote_foreign_require($serv->{'host'}, "acl", "acl-lib.pl");
72 $aref = &remote_eval($serv->{'host'}, "acl", "\%rv = &get_module_acl('$who', '$mod->{'dir'}'); \\%rv");
75 # Display the editor form from this host
76 print "<form method=post action=save_acl.cgi>\n";
77 print "<input type=hidden name=_acl_mod value='$mod->{'dir'}'>\n";
78 print "<input type=hidden name=_acl_host value='$host->{'id'}'>\n";
80 print "<input type=hidden name=_acl_group value='$group->{'name'}'>\n";
83 print "<input type=hidden name=_acl_user value='$user->{'name'}'>\n";
85 print "<table border width=100%>\n";
86 print "<tr $tb> <td><b>",
87 $mod->{'dir'} ? &text('acl_options', $mod->{'desc'}, &server_name($serv))
88 : &text('acl_optionsg', &server_name($serv)),
90 print "<tr $cb> <td><table width=100%>\n";
93 print "<tr> <td><b>$text{'acl_config'}</b></td> <td>\n";
94 printf "<input type=radio name=noconfig value=0 %s> $text{'yes'}\n",
95 $access{'noconfig'} ? "" : "checked";
96 printf "<input type=radio name=noconfig value=1 %s> $text{'no'}</td>\n",
97 $access{'noconfig'} ? "checked" : "";
98 print "<td width=50% colspan=2></td> </tr>\n";
101 $mdir = &module_root_directory($mod->{'dir'});
102 if (!&foreign_exists($mod->{'dir'})) {
103 # This server doesn't have the module .. use text editor
104 print "<tr> <td colspan=4><hr></td> </tr>\n" if ($mod->{'dir'});
105 print "<tr> <td colspan=4><b>$text{'acl_raw'}</b><br>\n";
106 print "<textarea rows=10 cols=70 name=_acl_raw>\n";
107 foreach $k (sort { $a cmp $b } keys %access) {
108 print "$k=$access{$k}\n";
110 print "</textarea></td> </tr>\n";
112 elsif (-r "$mdir/acl_security.pl") {
113 print "<tr> <td colspan=4><hr></td> </tr>\n" if ($mod->{'dir'});
114 &foreign_require($mod->{'dir'}, "acl_security.pl");
115 &foreign_call($mod->{'dir'}, "acl_security_form", \%access);
118 print "</table></td></tr></table>\n";
119 print "<input type=submit name=all value='",&text('acl_save1'),"'>\n";
120 print "<input type=submit value='",&text('acl_save2', &server_name($serv)),"'>\n";
122 &ui_print_footer("", $text{'index_return'});