Handle hostnames with upper-case letters
[webmin.git] / nis / save_ethers.cgi
1 #!/usr/local/bin/perl
2 # save_ethers.cgi
3 # Create, update or delete an ethernet address
4
5 require './nis-lib.pl';
6 &ReadParse();
7
8 ($t, $lnums, $ether) = &table_edit_setup($in{'table'}, $in{'line'}, '\s+');
9 if ($in{'delete'}) {
10         # Just delete the ether
11         &table_delete($t, $lnums);
12         }
13 else {
14         # Validate inputs and save the host
15         &error_setup($text{'ethers_err'});
16         lc($in{'mac'}) =~ /^([0-9a-f]{2}:){5}[0-9a-f]{2}$/ ||
17                 &error($text{'ethers_emac'});
18         &to_ipaddress($in{'ip'}) || &to_ip6address($in{'ip'}) ||
19                 &error($text{'ethers_eip'});
20         @ether = ( $in{'mac'}, $in{'ip'} );
21         if ($in{'line'} eq '') {
22                 &table_add($t, "\t", \@ether);
23                 }
24         else {
25                 &table_update($t, $lnums, "\t", \@ether);
26                 }
27         }
28 &apply_table_changes() if (!$config{'manual_build'});
29 &redirect("edit_tables.cgi?table=$in{'table'}");
30