Handle hostnames with upper-case letters
[webmin.git] / zones / save_rctl.cgi
1 #!/usr/local/bin/perl
2 # Update, add or delete a resource control
3
4 require './zones-lib.pl';
5 do 'forms-lib.pl';
6 &ReadParse();
7 $zinfo = &get_zone($in{'zone'});
8 $zinfo || &error($text{'edit_egone'});
9 if (!$in{'new'}) {
10         # Find the rctl object
11         ($rctl) = grep { $_->{'name'} eq $in{'old'} } @{$zinfo->{'rctl'}};
12         $rctl || &error($text{'rctl_egone'});
13         }
14 else {
15         $rctl = { 'keytype' => 'rctl' };
16         }
17
18 if ($in{'delete'}) {
19         # Just remove this resource control
20         &delete_zone_object($zinfo, $rctl);
21         }
22 else {
23         # Validate inputs
24         $form = &get_rctl_form(\%in, $zinfo, $rctl);
25         $table = $form->get_section(1);
26         $form->validate_redirect("edit_rctl.cgi");
27         $rctl->{'name'} = $form->get_value("name");
28         @values = ( );
29         for($i=0; $i<$table->get_rowcount(); $i++) {
30                 local ($priv, $limit, $action) = $table->get_values($i);
31                 if ($priv) {
32                         push(@values,
33                              "(priv=$priv,limit=$limit,action=$action)");
34                         }
35                 }
36         @values || &error($text{'rctl_evalues'});
37         $rctl->{'value'} = join("\0", @values);
38         &find_clash($zinfo, $rctl) &&
39                 $form->validate_redirect("edit_fs.cgi",
40                         [ [ "name", $text{'rctl_eclash'} ] ]);
41
42         # Save the rctl
43         if ($in{'new'}) {
44                 &create_zone_object($zinfo, $rctl);
45                 }
46         else {
47                 &modify_zone_object($zinfo, $rctl);
48                 }
49         }
50
51 &webmin_log($in{'new'} ? "create" : $in{'delete'} ? "delete" : "modify",
52             "rctl", $in{'old'} || $rctl->{'name'}, $rctl);
53 &redirect("edit_zone.cgi?zone=$in{'zone'}");
54