Handle hostnames with upper-case letters
[webmin.git] / frox / save_net.cgi
1 #!/usr/local/bin/perl
2 # Save networking-related options
3
4 require './frox-lib.pl';
5 &ReadParse();
6 &error_setup($text{'net_err'});
7 $conf = &get_config();
8
9 &save_opt_textbox($conf, "Listen", \&check_listen);
10 &save_textbox($conf, "Port", \&check_port);
11 &save_opt_textbox($conf, "BindToDevice", \&check_iface);
12 &save_yesno($conf, "FromInetd");
13 &save_exists($conf, "NoDetach");
14 &save_opt_textbox($conf, "FTPProxy", \&check_proxy);
15 &save_opt_textbox($conf, "TcpOutgoingAddr", \&check_ip);
16 &save_opt_textbox($conf, "PASVAddress", \&check_ip);
17 &save_opt_textbox($conf, "ResolvLoadHack", \&check_resolv);
18
19 &lock_file($config{'frox_conf'});
20 &flush_file_lines();
21 &unlock_file($config{'frox_conf'});
22 &webmin_log("net");
23 &redirect("");
24
25 sub check_listen
26 {
27 return &to_ipaddress($_[0]) ? undef : $text{'net_ehost'};
28 }
29
30 sub check_port
31 {
32 return $_[0] =~ /^\d+$/ ? undef : $text{'net_eport'};
33 }
34
35 sub check_iface
36 {
37 return $_[0] =~ /^[a-z]+(\d*)(:\d+)?$/ ? undef : $text{'net_eiface'};
38 }
39
40 sub check_proxy
41 {
42 return $_[0] =~ /^(\S+):(\d+)$/ && &to_ipaddress($1) ?
43         undef : $text{'net_eproxy'};
44 }
45
46 sub check_ip
47 {
48 return &check_ipaddress($_[0]) ? undef : $text{'net_eip'};
49 }
50
51 sub check_resolv
52 {
53 return $_[0] =~ /^[a-z0-9\.\-\_]+$/i ? undef : $text{'net_eresolv'};
54 }
55