Handle hostnames with upper-case letters
[webmin.git] / samba / conf_net.cgi
1 #!/usr/local/bin/perl
2 # conf_net.cgi
3 # Display Unix networking options
4
5 require './samba-lib.pl';
6
7 # check acls
8
9 &error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
10 &error("$text{'eacl_np'} $text{'eacl_pcn'}") unless $access{'conf_net'};
11
12 &ui_print_header(undef, $text{'net_title'}, "");
13
14 &get_share("global");
15
16 print "<form action=save_net.cgi>\n";
17 print "<table border width=100%>\n";
18 print "<tr $tb> <td><b>$text{'net_title'}</b></td> </tr>\n";
19 print "<tr $cb> <td><table width=100%>\n";
20 print "<tr> <td><b>$text{'net_idle'}</b></td>\n";
21 printf "<td><input type=radio name=dead_time_def value=1 %s> $text{'config_never'}\n",
22         &getval("deadtime") eq "" ? "checked" : "";
23 printf "<input type=radio name=dead_time_def value=0 %s>\n",
24         &getval("deadtime") eq "" ? "" : "checked";
25 printf "<input name=dead_time size=5 value=\"%s\"> $text{'config_mins'}</td> </tr>\n",
26         &getval("deadtime");
27
28 print "<tr> <td><b>$text{'net_trustlist'}</b></td>\n";
29 printf "<td><input type=radio name=hosts_equiv_def value=1 %s> $text{'config_none'}\n",
30         &getval("hosts equiv") eq "" ? "checked" : "";
31 printf "<input type=radio name=hosts_equiv_def value=0 %s>",
32         &getval("hosts equiv") eq "" ? "" : "checked";
33 printf "<input name=hosts_equiv size=20 value=\"%s\">\n",
34         &getval("hosts equiv");
35 print &file_chooser_button("hosts_equiv", 0);
36 print "</td> </tr>\n";
37
38 print "<tr> <td valign=top><b>$text{'net_netinterface'}</b></td>\n";
39 print "<td>\n";
40 printf "<input type=radio name=interfaces_def value=1 %s> $text{'net_auto'}&nbsp;\n",
41         &getval("interfaces") ? "" : "checked";
42 printf "<input type=radio name=interfaces_def value=0 %s> $text{'net_uselist'}<br>\n",
43         &getval("interfaces") ? "checked" : "";
44 print "<table border>\n";
45 print "<tr> <td><b>$text{'net_interface'}</b></td> <td><b>$text{'net_netmask'}</b></td> </tr>\n";
46 @iflist = split(/\s+/, &getval("interfaces"));
47 $len = @iflist ? @iflist+1 : 2;
48 for($i=0; $i<$len; $i++) {
49         print "<tr>\n";
50         if ($iflist[$i] =~ /^([0-9\.]+)\/([0-9]+)$/) {
51                 for($j=0; $j<$2; $j++) { $pw += 2**(31-$j); }
52                 $n = sprintf "%u.%u.%u.%u",
53                                 ($pw>>24)&0xff, ($pw>>16)&0xff,
54                                 ($pw>>8)&0xff, ($pw)&0xff;
55                 print "<td><input name=interface_ip$i value=$1 size=15></td>\n";
56                 print "<td><input name=interface_nm$i value=$n size=15></td>\n";
57                 }
58         elsif ($iflist[$i] =~ /^([0-9\.]+)\/([0-9\.]+)$/) {
59                 print "<td><input name=interface_ip$i value=$1 size=15></td>\n";
60                 print "<td><input name=interface_nm$i value=$2 size=15></td>\n";
61                 }
62         elsif ($iflist[$i] =~ /^(\S+)$/) {
63                 print "<td><input name=interface_ip$i value=$1 size=15></td>\n";
64                 print "<td><input name=interface_nm$i size=15></td>\n";
65                 }
66         else {
67                 print "<td><input name=interface_ip$i size=15></td>\n";
68                 print "<td><input name=interface_nm$i size=15></td>\n";
69                 }
70         print "</tr>\n";
71         }
72 print "</table></td> </tr>\n";
73
74 print "<tr> <td><b>$text{'net_keepalive'}</b></td>\n";
75 printf "<td><input type=radio name=keepalive_def value=1 %s> $text{'net_notsend'}\n",
76         &getval("keepalive") eq "" ? "checked" : "";
77 printf "<input type=radio name=keepalive_def value=0 %s>\n",
78         &getval("keepalive") eq "" ? "" : "checked";
79 print "$text{'net_every'}\n";
80 printf "<input name=keepalive size=5 value=\"%s\">$text{'config_secs'}</td> </tr>\n",
81         &getval("keepalive");
82
83 print "<tr> <td><b>$text{'net_maxpacket'}</b></td>\n";
84 printf "<td><input type=radio name=max_xmit_def value=1 %s> $text{'default'}\n",
85         &getval("max xmit") eq "" ? "checked" : "";
86 printf "<input type=radio name=max_xmit_def value=0 %s>\n",
87         &getval("max xmit") eq "" ? "" : "checked";
88 printf "<input name=max_xmit size=5 value=\"%s\"> $text{'config_bytes'}</td> </tr>\n",
89         &getval("max xmit");
90
91 print "<tr> <td><b>$text{'net_listen'}</b></td>\n";
92 printf "<td><input type=radio name=socket_address_def value=1 %s> $text{'config_all'}\n",
93         &getval("socket address") eq "" ? "checked" : "";
94 printf "<input type=radio name=socket_address_def value=0 %s>\n",
95         &getval("socket address") eq "" ? "" : "checked";
96 printf "<input name=socket_address size=15 value=\"%s\"></td> </tr>\n",
97         &getval("socket address");
98
99 print "<tr> <td valign=top><b>$text{'net_socket'}</b></td>\n";
100 print "<td><table>\n";
101 foreach (split(/\s+/, &getval("socket options"))) {
102         if (/^([A-Z\_]+)=(.*)/) { $sopts{$1} = $2; }
103         else { $sopts{$_} = ""; }
104         }
105 for($i=0; $i<@sock_opts; $i++) {
106         $sock_opts[$i] =~ /^([A-Z\_]+)(.*)$/;
107         if ($i%2 == 0) { print "<tr>\n"; }
108         printf "<td><input type=checkbox name=$1 value=1 %s> $1\n",
109                 defined($sopts{$1}) ? "checked" : "";
110         if ($2 eq "*") {
111                 printf "<input size=5 name=\"$1_val\" value=\"%s\">\n",
112                         $sopts{$1};
113                 }
114         print "</td>\n";
115         if ($i%2 == 1) { print "<tr>\n"; }
116         }
117 print "</table></td> </tr>\n";
118
119 print "</table></td></tr></table><p>\n";
120 print "<input type=submit value=$text{'save'}></form>\n";
121
122 &ui_print_footer("", $text{'index_sharelist'});
123