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