--- bin/tftpd.pl 2009/07/26 00:38:57 1 +++ bin/tftpd.pl 2009/07/27 22:25:06 13 @@ -6,11 +6,12 @@ die "need to run $0 as root like this\nsudo $0\n" unless $< == 0; # change ROOTDIR to your TFTP root directory -my $rootdir = $ARGV[0] || 'tftp'; +my $rootdir = 'conf/' . readlink('conf/tftp.dir'); +$rootdir =~ s{[^/]+/\.\./([^/]+)}{$1}; unless(-d $rootdir) { - print "\nUsage: $0 path/to/rootdir\n\n"; + print "$rootdir isn't directory!\nUsage: $0 path/to/rootdir\n\n"; exit 1; } @@ -27,6 +28,8 @@ { # WRQ printf "block: %u\/%u\n", $req->{'_REQUEST_'}{'LASTBLK'}, $req->{'_REQUEST_'}{'LASTACK'}; + } else { + warn "IGNORED: ", dump( $req ); } } @@ -42,7 +45,7 @@ BlkSize => 1456, # IBM GE seems to be picky Debug => 99, ) or die Net::TFTPd->error; -printf "TFTP listener is bound to %s:%d\nTFTP listener is waiting %d seconds for a request\n", $listener->{'LocalAddr'} ? $listener->{'LocalAddr'} : "'any address'", $listener->{'LocalPort'}, $listener->{'Timeout'}; +printf "TFTP %s:%d [timeout %d s] $rootdir\n", $listener->{'LocalAddr'} ? $listener->{'LocalAddr'} : "'any address'", $listener->{'LocalPort'}, $listener->{'Timeout'}; while(1) {