Handle hostnames with upper-case letters
[webmin.git] / zones / edit_zone.cgi
1 #!/usr/local/bin/perl
2 # Shows the details of one zone, with links to make changes
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
10 $p = new Webmin::Page(&zone_title($in{'zone'}), $text{'edit_title'}, "edit");
11
12 # Show general information
13 $gform = &get_zone_form(\%in, $zinfo);
14 $p->add_form($gform);
15
16 # Show network interfaces
17 $p->add_separator();
18 $nform = new Webmin::Form();
19 $p->add_form($nform);
20 $nform->set_input(\%in);
21 $ntable = new Webmin::Table([ $text{'edit_netaddress'},
22                               $text{'edit_netname'},
23                               $text{'edit_netmask'},
24                               $text{'edit_netbroad'} ], "100%", "ntable");
25 $nform->add_section($ntable);
26 $ntable->set_heading($text{'edit_net'});
27 foreach $net (@{$zinfo->{'net'}}) {
28         $active = &get_active_interface($zinfo, $net);
29         ($address, $netmask) = &get_address_netmask($net, $active);
30         $ntable->add_row([
31                 "<a href='edit_net.cgi?zone=$in{'zone'}&old=$net->{'address'}'>$address</a>",
32                 $active->{'fullname'} || $text{'edit_netdown'},
33                 $netmask,
34                 $active->{'broadcast'} ]);
35         }
36 $ntable->set_emptymsg($text{'edit_netnone'});
37 $ntable->add_link("edit_net.cgi?zone=$in{'zone'}&new=1", $text{'edit_netadd'});
38
39 # Show package directories
40 $p->add_separator();
41 $pform = new Webmin::Form();
42 $p->add_form($pform);
43 $pform->set_input(\%in);
44 $ptable = new Webmin::Table([ $text{'edit_pkgdir'} ], "100%", "ptable");
45 $pform->add_section($ptable);
46 $ptable->set_heading($text{'edit_pkg'});
47 foreach $pkg (@{$zinfo->{'inherit-pkg-dir'}}) {
48         if ($zinfo->{'status'} eq 'configured') {
49                 $ptable->add_row([ "<a href='edit_pkg.cgi?zone=$in{'zone'}&old=$pkg->{'dir'}'>$pkg->{'dir'}</a>" ]);
50                 }
51         else {
52                 $ptable->add_row([ "<tt>$pkg->{'dir'}</tt>" ]);
53                 }
54         }
55 $ptable->set_emptymsg($text{'edit_pkgnone'});
56 if ($zinfo->{'status'} eq 'configured') {
57         $ptable->add_link("edit_pkg.cgi?zone=$in{'zone'}&new=1",
58                           $text{'edit_pkgadd'});
59         }
60 else {
61         $p->add_message($text{'edit_pkgcannot'});
62         }
63
64 # Show other filesystems
65 $p->add_separator();
66 $fform = new Webmin::Form("edit_fs.cgi");
67 $p->add_form($fform);
68 $fform->set_input(\%in);
69 $ftable = new Webmin::Table([ $text{'edit_fsdir'},
70                               $text{'edit_fsspecial'},
71                               $text{'edit_fstype'},
72                               $text{'edit_fsmounted'} ], "100%", "ftable");
73 $fform->add_section($ftable);
74 $ftable->set_heading($text{'edit_fs'});
75 foreach $fs (@{$zinfo->{'fs'}}) {
76         $ftable->add_row([
77                 "<a href='edit_fs.cgi?zone=$in{'zone'}&old=$fs->{'dir'}'>$fs->{'dir'}</a>",
78                 &mount::device_name($fs->{'special'}),
79                 &mount::fstype_name($fs->{'type'}),
80                 &get_active_mount($zinfo, $fs) ?
81                         $text{'yes'} : $text{'no'},
82                 ]);
83         }
84 $ftable->set_emptymsg($text{'edit_fsnone'});
85 $ftable->add_input(new Webmin::Submit($text{'edit_fsadd'}));
86 $ftable->add_input(new Webmin::Select("type", "ufs",
87         [ map { [ $_, &mount::fstype_name($_) ] } &list_filesystems() ]));
88 $fform->add_hidden("new", 1);
89 $fform->add_hidden("zone", $in{'zone'});
90
91 # Show resource controls
92 $p->add_separator();
93 $rform = new Webmin::Form();
94 $p->add_form($rform);
95 $rform->set_input(\%in);
96 $rtable = new Webmin::Table([ $text{'edit_rctlname'},
97                               $text{'edit_rctlpriv'},
98                               $text{'edit_rctllimit'},
99                               $text{'edit_rctlaction'}, ], "100%", "rtable");
100 $rform->add_section($rtable);
101 $rtable->set_heading($text{'edit_rctl'});
102 foreach $rctl (@{$zinfo->{'rctl'}}) {
103         @values = split(/\0/, $rctl->{'value'});
104         local (@privs, @limits, @actions);
105         foreach $v (@values) {
106                 ($priv, $limit, $action) = &get_rctl_value($v);
107                 push(@privs, $text{'rctl_'.$priv});
108                 push(@limits, $limit);
109                 push(@actions, $text{'rctl_'.$action});
110                 }
111         $rtable->add_row([
112                 "<a href='edit_rctl.cgi?zone=$in{'zone'}&old=$rctl->{'name'}'>$rctl->{'name'}</a>",
113                 join("<br>", @privs),
114                 join("<br>", @limits),
115                 join("<br>", @actions),
116                 ]);
117         }
118 $rtable->set_emptymsg($text{'edit_rctlnone'});
119 $rtable->add_link("edit_rctl.cgi?zone=$in{'zone'}&new=1",
120                   $text{'edit_rctladd'});
121
122 # Show generic attributes
123 $p->add_separator();
124 $gform = new Webmin::Form();
125 $p->add_form($gform);
126 $gform->set_input(\%in);
127 $gtable = new Webmin::Table([ $text{'edit_attrname'},
128                               $text{'edit_attrtype'},
129                               $text{'edit_attrvalue'}, ], "100%", "gtable");
130 $gform->add_section($gtable);
131 $gtable->set_heading($text{'edit_attr'});
132 foreach $attr (@{$zinfo->{'attr'}}) {
133         $gtable->add_row([
134                 "<a href='edit_attr.cgi?zone=$in{'zone'}&old=$attr->{'name'}'>$attr->{'name'}</a>",
135                 $text{'attr_'.$attr->{'type'}},
136                 $attr->{'value'},
137                 ]);
138         }
139 $gtable->set_emptymsg($text{'edit_attrnone'});
140 $gtable->add_link("edit_attr.cgi?zone=$in{'zone'}&new=1",
141                   $text{'edit_attradd'});
142
143 $p->add_footer("index.cgi", $text{'index_return'});
144 $p->print();
145
146