Handle hostnames with upper-case letters
[webmin.git] / rbac / list_prctl.cgi
1 #!/usr/local/bin/perl
2 # Show active resource limits
3
4 require './rbac-lib.pl';
5 &ReadParse();
6 &ui_print_header(undef, $text{'prctl_title'}, "", "prctl", 0, 0, 0,
7                  &help_search_link("prctl", "man"));
8
9 # Show selection form
10 print &ui_form_start("list_prctl.cgi", "get");
11 print "<table>\n";
12 print "<tr> <td valign=top rowspan=4>",&ui_submit($text{'prctl_ok'}),"</td>\n";
13
14 # For a process
15 print "<td>",&ui_oneradio("mode", 0, $text{'prctl_mode0'},
16                           $in{'mode'} == 0),"</td>\n";
17 print "<td>",&ui_textbox("pid", $in{'pid'}, 10),"</td> </tr>\n";
18
19 # For a project
20 print "<td>",&ui_oneradio("mode", 1, $text{'prctl_mode1'},
21                           $in{'mode'} == 1),"</td>\n";
22 print "<td>",&project_input("project", $in{'project'}),"</td> </tr>\n";
23
24 # For a zone
25 if (&foreign_check("zones")) {
26         &foreign_require("zones", "zones-lib.pl");
27         @zones = &zones::list_zones();
28         $nozones = 1 if (!@zones);
29         }
30 if (!$nozones) {
31         print "<td>",&ui_oneradio("mode", 2, $text{'prctl_mode2'},
32                                   $in{'mode'} == 2),"</td>\n";
33         if (@zones) {
34                 print "<td>",&ui_select("zone", $in{'zone'},
35                         [ map { [ $_->{'name'} ] } &zones::list_zones() ]),
36                         "</td> </tr>\n";
37                 }
38         else {
39                 print "<td>",&ui_textbox("zone", $in{'zone'}, 20),
40                       "</td> </tr>\n";
41                 }
42         }
43
44 # For a task
45 print "<td>",&ui_oneradio("mode", 3, $text{'prctl_mode3'},
46                           $in{'mode'} == 3),"</td>\n";
47 print "<td>",&ui_textbox("task", $in{'task'}, 10),"</td> </tr>\n";
48
49 print "</table>\n";
50 print &ui_form_end();
51
52 if (defined($in{'mode'})) {
53         # Show the results (if there were no errors in the input)
54         if ($in{'mode'} == 0) {
55                 $err = $text{'prctl_epid'} if ($in{'pid'} !~ /^\d+$/);
56                 $id = $in{'pid'};
57                 $type = "process";
58                 }
59         elsif ($in{'mode'} == 1) {
60                 $id = $in{'project'};
61                 $type = "project";
62                 }
63         elsif ($in{'mode'} == 2) {
64                 $id = $in{'zone'};
65                 $type = "zone";
66                 }
67         elsif ($in{'mode'} == 3) {
68                 $err = $text{'prctl_etask'} if ($in{'task'} !~ /^\d+$/);
69                 $id = $in{'task'};
70                 $type = "task";
71                 }
72         if ($err) {
73                 print "<b>$err</b><p>\n";
74                 }
75         elsif (@res = &list_resource_controls($type, $id)) {
76                 # Found some .. show them
77                 print &ui_columns_start([
78                         $text{'prctl_res'},
79                         $text{'prctl_priv'},
80                         $text{'prctl_limit'},
81                         $text{'prctl_action'} ]);
82                 foreach $r (@res) {
83                         print &ui_columns_row([
84                                 $r->{'res'},
85                                 $text{'project_'.$r->{'priv'}} || $r->{'priv'},
86                                 $r->{'limit'},
87                                 $r->{'action'} =~ /^signal=(\S+)$/ ?
88                                         &text('prctl_signal', "$1") :
89                                 $text{'project_'.$r->{'action'}} ||
90                                         $r->{'action'},
91                                 ]);
92                         }
93                 print &ui_columns_end();
94                 }
95         else {
96                 print "<b>$text{'prctl_none'}</b><p>\n";
97                 }
98         }
99
100 &ui_print_footer("", $text{"index_return"});
101