--- lib/PXElator/client.pm 2009/09/09 09:04:04 406 +++ lib/PXElator/client.pm 2009/09/29 19:28:24 443 @@ -64,6 +64,7 @@ $value = $default; } elsif ( -f $path ) { $value = read_file $path; + chomp $value; } else { warn "# $name missing $path\n" if $debug; } @@ -74,10 +75,10 @@ my $ip = shift; my $path = ip_path $ip || return; my $conf; - foreach my $file ( glob("$path/*") ) { + foreach my $file ( glob("$path/*"), glob("$path/*/*") ) { my $name = $file; - $name =~ s{^.+/([^/]+)$}{$1}; - $conf->{ $name } = read_file $file; + $name =~ s{^$path/+}{} || die "can't remove $path from $name"; + $conf->{ $name } = read_file $file if -f $file; } return $conf; } @@ -85,8 +86,8 @@ my $mac = shift; $mac = format::mac($mac); - if ( $server::new_clients-- ) { - warn "# clients left: $server::new_clients\n"; + if ( $server::new_clients > 0 ) { + warn "# clients left: ", --$server::new_clients; } else { warn "W: no new clients accepted"; return '0.0.0.0'; @@ -113,7 +114,7 @@ sub save_ip_mac { my ($ip,$mac) = @_; $mac = format::mac($mac); - return if $mac eq '00:00:00:00:00:00'; + return if $mac eq '00:00:00:00:00:00' || $ip eq '0.0.0.0'; mkdir ip_path($ip) unless -e ip_path($ip); @@ -173,7 +174,6 @@ sub remove { my $ip = shift; - unlink $_ foreach grep { -e $_ } ( glob "$server::conf/ip/$ip/*" ); if ( my $mac = mac_from_ip $ip ) { unlink "$server::conf/mac/$mac"; }