--- lib/PXElator/client.pm 2009/08/15 13:47:37 220 +++ lib/PXElator/client.pm 2009/08/25 15:00:20 286 @@ -6,7 +6,6 @@ use File::Slurp; use Net::Ping; -use Carp qw/confess/; use server; use format; @@ -31,7 +30,7 @@ } elsif ( -f $path ) { $value = read_file $path; } else { - confess "$path not file or symlink"; + warn "W: $path not file or symlink\n"; } return $value; } @@ -85,15 +84,20 @@ warn "next_ip $ip\n"; - mkdir ip_path($ip); + save_ip_mac( $ip, $mac ); + + return $ip; +} + +sub save_ip_mac { + my ($ip,$mac) = @_; + + mkdir ip_path($ip) unless -e ip_path($ip); my $mac_path = mac_path($mac); - unlink $mac_path if -e $mac_path; # XXX audit? + unlink $mac_path if -l $mac_path; # XXX audit? symlink ip_path($ip), $mac_path; write_file ip_path($ip,'mac'), $mac; - - return $ip; - } sub ip_from_mac($) {