3 # Display a form for editing the ACL for some module for some user or group
5 require './cluster-webmin-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");
73 $aref = &remote_eval($serv->{'host'}, "acl",
74 "\%rv = &get_module_acl('$who', '$mod->{'dir'}'); \\%rv");
77 $aref = &remote_eval($serv->{'host'}, "acl",
78 "\%rv = &get_group_module_acl('$who', '$mod->{'dir'}'); \\%rv");
82 # Display the editor form from this host
83 print &ui_form_start("save_acl.cgi", "post");
84 print &ui_hidden("_acl_mod", $in{'mod'}),"\n";
85 print &ui_hidden("_acl_host", $in{'host'}),"\n";
87 print &ui_hidden("_acl_group", $who),"\n";
90 print &ui_hidden("_acl_user", $who),"\n";
92 print &ui_table_start(
93 $mod->{'dir'} ? &text('acl_options', $mod->{'desc'}, &server_name($serv))
94 : &text('acl_optionsg', &server_name($serv)),
98 # Show module config editing option
99 print &ui_table_row($text{'acl_config'},
100 &ui_radio("noconfig", $access{'noconfig'} ? 1 : 0,
101 [ [ 0, $text{'yes'} ], [ 1, $text{'no'} ] ]), 3);
104 $mdir = &module_root_directory($mod->{'dir'});
105 if (!&foreign_exists($mod->{'dir'})) {
106 # This server doesn't have the module .. use text editor
107 print &ui_table_hr() if ($mod->{'dir'});
109 foreach $k (sort { $a cmp $b } keys %access) {
110 $raw .= "$k=$access{$k}\n";
112 print &ui_table_row($text{'acl_raw'},
113 &ui_textarea("_acl_raw", $raw, 10, 70));
115 elsif (-r "$mdir/acl_security.pl") {
116 # Show the module's ACL editor
117 print &ui_table_hr() if ($mod->{'dir'});
118 &foreign_require($mod->{'dir'}, "acl_security.pl");
119 &foreign_call($mod->{'dir'}, "acl_security_form", \%access);
122 print &ui_table_end();
123 print "<input type=submit name=all value='",&text('acl_save1'),"'>\n";
124 print "<input type=submit value='",&text('acl_save2', &server_name($serv)),"'>\n";
125 print &ui_form_end();
126 &ui_print_footer("", $text{'index_return'});