Handle hostnames with upper-case letters
[webmin.git] / acl / edit_acl.cgi
1 #!/usr/local/bin/perl
2 # edit_acl.cgi
3 # Display a form for editing the access control options for some module
4
5 require './acl-lib.pl';
6 &ReadParse();
7 $access{'acl'} || &error($text{'acl_emod'});
8 if ($in{'group'}) {
9         $access{'groups'} || &error($text{'acl_egroup'});
10         $who = $in{'group'};
11         }
12 else {
13         $me = &get_user($base_remote_user);
14         @mcan = $access{'mode'} == 1 ? @{$me->{'modules'}} :
15                 $access{'mode'} == 2 ? split(/\s+/, $access{'mods'}) :
16                                        ( &list_modules() , "" );
17         &indexof($in{'mod'}, @mcan) >= 0 || &error($text{'acl_emod'});
18         &can_edit_user($in{'user'}) || &error($text{'acl_euser'});
19         $who = $in{'user'};
20         }
21
22 %minfo = $in{'mod'} ? &get_module_info($in{'mod'})
23                     : ( 'desc' => $text{'index_global'} );
24 $below = &text($in{'group'} ? 'acl_title3' : 'acl_title2', "<tt>$who</tt>",
25                "<tt>$minfo{'desc'}</tt>");
26 &ui_print_header($below, $text{'acl_title'}, "",
27                  -r &help_file($in{'mod'}, "acl_info") ?
28                         [ "acl_info", $in{'mod'} ] : undef);
29 %maccess = $in{'group'} ? &get_group_module_acl($who, $in{'mod'})
30                         : &get_module_acl($who, $in{'mod'}, 1);
31
32 # display the form
33 print &ui_form_start("save_acl.cgi", "post");
34 print &ui_hidden("_acl_mod", $in{'mod'}),"\n";
35 if ($in{'group'}) {
36         print &ui_hidden("_acl_group", $who),"\n";
37         }
38 else {
39         print &ui_hidden("_acl_user", $who),"\n";
40         }
41 print &ui_table_start(&text('acl_options', $minfo{'desc'}), "width=100%", 4);
42
43 if ($in{'mod'} && $in{'user'} && &supports_rbac($in{'mod'}) &&
44     !$gconfig{'rbacdeny_'.$who}) {
45         # Show RBAC option
46         print &ui_table_row($text{'acl_rbac'},
47                 &ui_radio("rbac", $maccess{'rbac'} ? 1 : 0,
48                         [ [ 1, $text{'acl_rbacyes'} ],
49                           [ 0, $text{'no'} ] ]), 3);
50         }
51
52 if ($in{'mod'}) {
53         # Show module config editing option
54         print &ui_table_row($text{'acl_config'},
55                 &ui_radio("noconfig", $maccess{'noconfig'} ? 1 : 0,
56                         [ [ 0, $text{'yes'} ], [ 1, $text{'no'} ] ]), 3);
57         }
58
59 $mdir = &module_root_directory($in{'mod'});
60 if (-r "$mdir/acl_security.pl") {
61         print &ui_table_hr() if ($in{'mod'});
62         &foreign_require($in{'mod'}, "acl_security.pl");
63         &foreign_call($in{'mod'}, "load_theme_library");
64         &foreign_call($in{'mod'}, "acl_security_form", \%maccess);
65         }
66
67 print &ui_table_end();
68 print &ui_form_end([ [ undef, $text{'save'} ],
69                      [ "reset", $text{'acl_reset'} ] ]);
70
71 &ui_print_footer("", $text{'index_return'});
72