Handle hostnames with upper-case letters
[webmin.git] / cfengine / save_push.cgi
1 #!/usr/local/bin/perl
2 # save_push.cgi
3 # Save cfrun options
4
5 require './cfengine-lib.pl';
6 &ReadParse();
7 &error_setup($text{'push_err'});
8
9 # Validate and parse inputs
10 ($oldhosts, $opts) = &get_cfrun_hosts();
11 $in{'domain'} =~ /^[A-Za-z0-9\.\-]+$/ || &error($text{'push_edomain'});
12 $opts->{'domain'} = $in{'domain'};
13 $opts->{'access'} = join(",", split(/\s+/, $in{'access'}));
14 for($i=0; defined($in{"host_$i"}); $i++) {
15         next if (!$in{"host_$i"});
16         &to_ipaddress($in{"host_$i"}) ||
17                 &error(&text('push_ehost', $in{"host_$i"}));
18         &to_ipaddress($in{"host_$i"}) ne &to_ipaddress(&get_system_hostname())||
19                 &error(&text('push_ethis', $in{"host_$i"}));
20         push(@hosts, [ $in{"host_$i"}, $in{"opts_$i"} ] );
21         }
22
23 # Write to file
24 &lock_file($cfrun_hosts);
25 &save_cfrun_hosts(\@hosts, $opts);
26 &unlock_file($cfrun_hosts);
27 &webmin_log("push");
28
29 &redirect("");
30