Handle hostnames with upper-case letters
[webmin.git] / pptp-server / save_conf.cgi
1 #!/usr/local/bin/perl
2 # save_conf.cgi
3 # Save PPTP server settings
4
5 require './pptp-server-lib.pl';
6 $access{'conf'} || &error($text{'conf_ecannot'});
7 &ReadParse();
8 &error_setup($text{'conf_err'});
9
10 # Validate and store inputs
11 &lock_file($config{'file'});
12 $conf = &get_config();
13 if ($in{'speed_def'}) {
14         &save_directive($conf, "speed");
15         }
16 else {
17         $in{'speed'} =~ /^\d+$/ || &error($text{'conf_espeed'});
18         &save_directive($conf, "speed", $in{'speed'});
19         }
20
21 if ($in{'listen_def'}) {
22         &save_directive($conf, "listen");
23         }
24 else {
25         &check_ipaddress($in{'listen'}) || &error($text{'conf_elisten'});
26         &save_directive($conf, "listen", $in{'listen'});
27         }
28
29 if ($in{'mode'} == 0) {
30         &save_directive($conf, "option");
31         }
32 elsif ($in{'mode'} == 1) {
33         &save_directive($conf, "option", $options_pptp);
34         }
35 else {
36         $in{'option'} =~ /^\/\S+$/ || &error($text{'conf_eoption'});
37         &save_directive($conf, "option", $in{'option'});
38         }
39
40 &save_ip_table("localip");
41
42 &save_ip_table("remoteip");
43
44 if ($in{'ipxnets_def'}) {
45         &save_directive($conf, "ipxnets");
46         }
47 else {
48         $in{'from'} =~ /^[A-F0-9]+$/ || &error($text{'conf_efrom'});
49         $in{'to'} =~ /^[A-F0-9]+$/ || &error($text{'conf_eto'});
50         &save_directive($conf, "ipxnets", $in{'from'}."-".$in{'to'});
51         }
52
53 &flush_file_lines();
54 &unlock_file($config{'file'});
55 &webmin_log("conf");
56 &redirect("");
57
58 # save_ip_table(name)
59 sub save_ip_table
60 {
61 local @ips = split(/\s+/, $in{$_[0]});
62 foreach $i (@ips) {
63         &check_ipaddress($i) || $i =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)-(\d+)$/ ||
64                 &error(&text('conf_e'.$_[0], $i));
65         }
66 &save_directive($conf, $_[0], @ips ? join(",", @ips) : undef);
67 }
68