]> sjero.net Git - wget/blob - tests/FTPServer.pm
87e7983977f897ae78fb3148d3f164c0cdccaa8b
[wget] / tests / FTPServer.pm
1 # Part of this code was borrowed from Richard Jones's Net::FTPServer
2 # http://www.annexia.org/freeware/netftpserver
3
4 package FTPServer;
5
6 use strict;
7 use warnings;
8
9 use Cwd;
10 use Socket;
11 use IO::Socket::INET;
12 use IO::Seekable;
13 use POSIX qw(strftime);
14
15 my $log        = undef;
16 my $GOT_SIGURG = 0;
17
18 # CONSTANTS
19
20 # connection states
21 my %_connection_states = (
22     'NEWCONN'  => 0x01,
23     'WAIT4PWD' => 0x02,
24     'LOGGEDIN' => 0x04,
25     'TWOSOCKS' => 0x08,
26 );
27
28 # subset of FTP commands supported by these server and the respective
29 # connection states in which they are allowed
30 my %_commands = (
31     # Standard commands from RFC 959.
32     'CWD'  => $_connection_states{LOGGEDIN} |
33               $_connection_states{TWOSOCKS},
34 #   'EPRT' => $_connection_states{LOGGEDIN},
35 #   'EPSV' => $_connection_states{LOGGEDIN},
36     'LIST' => $_connection_states{TWOSOCKS},
37 #   'LPRT' => $_connection_states{LOGGEDIN},
38 #   'LPSV' => $_connection_states{LOGGEDIN},
39     'PASS' => $_connection_states{WAIT4PWD},
40     'PASV' => $_connection_states{LOGGEDIN},
41     'PORT' => $_connection_states{LOGGEDIN},
42     'PWD'  => $_connection_states{LOGGEDIN} |
43               $_connection_states{TWOSOCKS},
44     'QUIT' => $_connection_states{LOGGEDIN} |
45               $_connection_states{TWOSOCKS},
46     'REST' => $_connection_states{TWOSOCKS},
47     'RETR' => $_connection_states{TWOSOCKS},
48     'SYST' => $_connection_states{LOGGEDIN},
49     'TYPE' => $_connection_states{LOGGEDIN} |
50               $_connection_states{TWOSOCKS},
51     'USER' => $_connection_states{NEWCONN},
52     # From ftpexts Internet Draft.
53     'SIZE' => $_connection_states{LOGGEDIN} |
54               $_connection_states{TWOSOCKS},
55 );
56
57
58
59 # COMMAND-HANDLING ROUTINES
60
61 sub _CWD_command
62 {
63     my ($conn, $cmd, $path) = @_;
64     my $paths = $conn->{'paths'};
65
66     local $_;
67     my $new_path = FTPPaths::path_merge($conn->{'dir'}, $path);
68
69     # Split the path into its component parts and process each separately.
70     if (! $paths->dir_exists($new_path)) {
71         print {$conn->{socket}} "550 Directory not found.\r\n";
72         return;
73     }
74
75     $conn->{'dir'} = $new_path;
76     print {$conn->{socket}} "200 directory changed to $new_path.\r\n";
77 }
78
79 sub _LIST_command
80 {
81     my ($conn, $cmd, $path) = @_;
82     my $paths = $conn->{'paths'};
83
84     # This is something of a hack. Some clients expect a Unix server
85     # to respond to flags on the 'ls command line'. Remove these flags
86     # and ignore them. This is particularly an issue with ncftp 2.4.3.
87     $path =~ s/^-[a-zA-Z0-9]+\s?//;
88
89     my $dir = $conn->{'dir'};
90
91     print STDERR "_LIST_command - dir is: $dir\n";
92
93     # Parse the first elements of the path until we find the appropriate
94     # working directory.
95     local $_;
96
97     $dir = FTPPaths::path_merge($dir, $path);
98     my $listing = $paths->get_list($dir);
99     unless ($listing) {
100         print {$conn->{socket}} "550 File or directory not found.\r\n";
101         return;
102     }
103
104     print STDERR "_LIST_command - dir is: $dir\n" if $log;
105
106     print {$conn->{socket}} "150 Opening data connection for file listing.\r\n";
107
108     # Open a path back to the client.
109     my $sock = __open_data_connection ($conn);
110     unless ($sock) {
111         print {$conn->{socket}} "425 Can't open data connection.\r\n";
112         return;
113     }
114
115     for my $item (@$listing) {
116         print $sock "$item\r\n";
117     }
118
119     unless ($sock->close) {
120         print {$conn->{socket}} "550 Error closing data connection: $!\r\n";
121         return;
122     }
123
124     print {$conn->{socket}} "226 Listing complete. Data connection has been closed.\r\n";
125 }
126
127 sub _PASS_command
128 {
129     my ($conn, $cmd, $pass) = @_;
130
131     # TODO: implement authentication?
132
133     print STDERR "switching to LOGGEDIN state\n" if $log;
134     $conn->{state} = $_connection_states{LOGGEDIN};
135
136     if ($conn->{username} eq "anonymous") {
137         print {$conn->{socket}} "202 Anonymous user access is always granted.\r\n";
138     } else {
139         print {$conn->{socket}} "230 Authentication not implemented yet, access is always granted.\r\n";
140     }
141 }
142
143 sub _PASV_command
144 {
145     my ($conn, $cmd, $rest) = @_;
146
147     # Open a listening socket - but don't actually accept on it yet.
148     "0" =~ /(0)/; # Perl 5.7 / IO::Socket::INET bug workaround.
149     my $sock = IO::Socket::INET->new (LocalHost => '127.0.0.1',
150                                       LocalPort => '0',
151                                       Listen => 1,
152                                       Reuse => 1,
153                                       Proto => 'tcp',
154                                       Type => SOCK_STREAM);
155
156     unless ($sock) {
157         # Return a code 550 here, even though this is not in the RFC. XXX
158         print {$conn->{socket}} "550 Can't open a listening socket.\r\n";
159         return;
160     }
161
162     $conn->{passive} = 1;
163     $conn->{passive_socket} = $sock;
164
165     # Get our port number.
166     my $sockport = $sock->sockport;
167
168     # Split the port number into high and low components.
169     my $p1 = int ($sockport / 256);
170     my $p2 = $sockport % 256;
171
172     $conn->{state} = $_connection_states{TWOSOCKS};
173
174     # We only accept connections from localhost.
175     print {$conn->{socket}} "227 Entering Passive Mode (127,0,0,1,$p1,$p2)\r\n";
176 }
177
178 sub _PORT_command
179 {
180     my ($conn, $cmd, $rest) = @_;
181
182     # The arguments to PORT are a1,a2,a3,a4,p1,p2 where a1 is the
183     # most significant part of the address (eg. 127,0,0,1) and
184     # p1 is the most significant part of the port.
185     unless ($rest =~ /^\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})/) {
186         print {$conn->{socket}} "501 Syntax error in PORT command.\r\n";
187         return;
188     }
189
190     # Check host address.
191     unless ($1  > 0 && $1 < 224 &&
192             $2 >= 0 && $2 < 256 &&
193             $3 >= 0 && $3 < 256 &&
194             $4 >= 0 && $4 < 256) {
195         print {$conn->{socket}} "501 Invalid host address.\r\n";
196         return;
197     }
198
199     # Construct host address and port number.
200     my $peeraddrstring = "$1.$2.$3.$4";
201     my $peerport = $5 * 256 + $6;
202
203     # Check port number.
204     unless ($peerport > 0 && $peerport < 65536) {
205         print {$conn->{socket}} "501 Invalid port number.\r\n";
206     }
207
208     $conn->{peeraddrstring} = $peeraddrstring;
209     $conn->{peeraddr} = inet_aton ($peeraddrstring);
210     $conn->{peerport} = $peerport;
211     $conn->{passive} = 0;
212
213     $conn->{state} = $_connection_states{TWOSOCKS};
214
215     print {$conn->{socket}} "200 PORT command OK.\r\n";
216 }
217
218 sub _PWD_command
219 {
220     my ($conn, $cmd, $rest) = @_;
221
222     # See RFC 959 Appendix II and draft-ietf-ftpext-mlst-11.txt section 6.2.1.
223     my $pathname = $conn->{dir};
224     $pathname =~ s,/+$,, unless $pathname eq "/";
225     $pathname =~ tr,/,/,s;
226
227     print {$conn->{socket}} "257 \"$pathname\"\r\n";
228 }
229
230 sub _REST_command
231 {
232     my ($conn, $cmd, $restart_from) = @_;
233
234     unless ($restart_from =~ /^([1-9][0-9]*|0)$/) {
235         print {$conn->{socket}} "501 REST command needs a numeric argument.\r\n";
236         return;
237     }
238
239     $conn->{restart} = $1;
240
241     print {$conn->{socket}} "350 Restarting next transfer at $1.\r\n";
242 }
243
244 sub _RETR_command
245 {
246     my ($conn, $cmd, $path) = @_;
247
248     $path = FTPPaths::path_merge($conn->{dir}, $path);
249     my $info = $conn->{'paths'}->get_info($path);
250
251     unless ($info->{'_type'} eq 'f') {
252         print {$conn->{socket}} "550 File not found.\r\n";
253         return;
254     }
255
256     print {$conn->{socket}} "150 Opening " .
257         ($conn->{type} eq 'A' ? "ASCII mode" : "BINARY mode") .
258         " data connection.\r\n";
259
260     # Open a path back to the client.
261     my $sock = __open_data_connection ($conn);
262
263     unless ($sock) {
264         print {$conn->{socket}} "425 Can't open data connection.\r\n";
265         return;
266     }
267
268     my $content = $info->{'content'};
269
270     # Restart the connection from previous point?
271     if ($conn->{restart}) {
272         $content = substr($content, $conn->{restart});
273         $conn->{restart} = 0;
274     }
275
276     # What mode are we sending this file in?
277     unless ($conn->{type} eq 'A') # Binary type.
278     {
279         my ($r, $buffer, $n, $w);
280
281
282         # Copy data.
283         while ($buffer = substr($content, 0, 65536))
284         {
285             $r = length $buffer;
286
287             # Restart alarm clock timer.
288             alarm $conn->{idle_timeout};
289
290             for ($n = 0; $n < $r; )
291             {
292                 $w = syswrite ($sock, $buffer, $r - $n, $n);
293
294                 # Cleanup and exit if there was an error.
295                 unless (defined $w) {
296                     close $sock;
297                     print {$conn->{socket}} "426 File retrieval error: $!. Data connection has been closed.\r\n";
298                     return;
299                 }
300
301                 $n += $w;
302             }
303
304             # Transfer aborted by client?
305             if ($GOT_SIGURG) {
306                 $GOT_SIGURG = 0;
307                 close $sock;
308                 print {$conn->{socket}} "426 Transfer aborted. Data connection closed.\r\n";
309                 return;
310             }
311         }
312
313         # Cleanup and exit if there was an error.
314         unless (defined $r) {
315             close $sock;
316             print {$conn->{socket}} "426 File retrieval error: $!. Data connection has been closed.\r\n";
317             return;
318         }
319     } else { # ASCII type.
320         # Copy data.
321         my @lines = split /\r\n?|\n/, $content;
322         for (@lines) {
323             # Remove any native line endings.
324             s/[\n\r]+$//;
325
326             # Restart alarm clock timer.
327             alarm $conn->{idle_timeout};
328
329             # Write the line with telnet-format line endings.
330             print $sock "$_\r\n";
331
332             # Transfer aborted by client?
333             if ($GOT_SIGURG) {
334                 $GOT_SIGURG = 0;
335                 close $sock;
336                 print {$conn->{socket}} "426 Transfer aborted. Data connection closed.\r\n";
337                 return;
338             }
339         }
340     }
341
342     unless (close ($sock)) {
343         print {$conn->{socket}} "550 File retrieval error: $!.\r\n";
344         return;
345     }
346
347     print {$conn->{socket}} "226 File retrieval complete. Data connection has been closed.\r\n";
348 }
349
350 sub _SIZE_command
351 {
352     my ($conn, $cmd, $path) = @_;
353
354     $path = FTPPaths::path_merge($conn->{dir}, $path);
355     my $info = $conn->{'paths'}->get_info($path);
356     unless ($info) {
357         print {$conn->{socket}} "550 File or directory not found.\r\n";
358         return;
359     }
360
361     if ($info->{'_type'} eq 'd') {
362         print {$conn->{socket}} "550 SIZE command is not supported on directories.\r\n";
363         return;
364     }
365
366     my $size = length $info->{'content'};
367
368     print {$conn->{socket}} "213 $size\r\n";
369 }
370
371 sub _SYST_command
372 {
373     my ($conn, $cmd, $dummy) = @_;
374
375     print {$conn->{socket}} "215 UNIX Type: L8\r\n";
376 }
377
378 sub _TYPE_command
379 {
380     my ($conn, $cmd, $type) = @_;
381
382     # See RFC 959 section 5.3.2.
383     if ($type =~ /^([AI])$/i) {
384         $conn->{type} = 'A';
385     } elsif ($type =~ /^([AI])\sN$/i) {
386         $conn->{type} = 'A';
387     } elsif ($type =~ /^L\s8$/i) {
388         $conn->{type} = 'L8';
389     } else {
390         print {$conn->{socket}} "504 This server does not support TYPE $type.\r\n";
391         return;
392     }
393
394     print {$conn->{socket}} "200 TYPE changed to $type.\r\n";
395 }
396
397 sub _USER_command
398 {
399     my ($conn, $cmd, $username) = @_;
400
401     print STDERR "username: $username\n" if $log;
402     $conn->{username} = $username;
403
404     print STDERR "switching to WAIT4PWD state\n" if $log;
405     $conn->{state} = $_connection_states{WAIT4PWD};
406
407     if ($conn->{username} eq "anonymous") {
408         print {$conn->{socket}} "230 Anonymous user access granted.\r\n";
409     } else {
410         print {$conn->{socket}} "331 Password required.\r\n";
411     }
412 }
413
414
415 # HELPER ROUTINES
416
417 sub __open_data_connection
418 {
419     my $conn = shift;
420
421     my $sock;
422
423     if ($conn->{passive}) {
424         # Passive mode - wait for a connection from the client.
425         accept ($sock, $conn->{passive_socket}) or return undef;
426     } else {
427         # Active mode - connect back to the client.
428         "0" =~ /(0)/; # Perl 5.7 / IO::Socket::INET bug workaround.
429         $sock = IO::Socket::INET->new (LocalAddr => '127.0.0.1',
430                                        PeerAddr => $conn->{peeraddrstring},
431                                        PeerPort => $conn->{peerport},
432                                        Proto => 'tcp',
433                                        Type => SOCK_STREAM) or return undef;
434     }
435
436     return $sock;
437 }
438
439
440 ###########################################################################
441 # FTPSERVER CLASS
442 ###########################################################################
443
444 {
445     my %_attr_data = ( # DEFAULT
446         _input           => undef,
447         _localAddr       => 'localhost',
448         _localPort       => undef,
449         _reuseAddr       => 1,
450         _rootDir         => Cwd::getcwd(),
451         _server_behavior => {},
452     );
453
454     sub _default_for
455     {
456         my ($self, $attr) = @_;
457         $_attr_data{$attr};
458     }
459
460     sub _standard_keys
461     {
462         keys %_attr_data;
463     }
464 }
465
466
467 sub new {
468     my ($caller, %args) = @_;
469     my $caller_is_obj = ref($caller);
470     my $class = $caller_is_obj || $caller;
471     my $self = bless {}, $class;
472     foreach my $attrname ($self->_standard_keys()) {
473         my ($argname) = ($attrname =~ /^_(.*)/);
474         if (exists $args{$argname}) {
475             $self->{$attrname} = $args{$argname};
476         } elsif ($caller_is_obj) {
477             $self->{$attrname} = $caller->{$attrname};
478         } else {
479             $self->{$attrname} = $self->_default_for($attrname);
480         }
481     }
482     # create server socket
483     "0" =~ /(0)/; # Perl 5.7 / IO::Socket::INET bug workaround.
484     $self->{_server_sock}
485                     = IO::Socket::INET->new (LocalHost => $self->{_localAddr},
486                                              LocalPort => $self->{_localPort},
487                                              Listen => 1,
488                                              Reuse => $self->{_reuseAddr},
489                                              Proto => 'tcp',
490                                              Type => SOCK_STREAM)
491                                         or die "bind: $!";
492
493     foreach my $file (keys %{$self->{_input}}) {
494         my $ref = \$self->{_input}{$file}{content};
495         $$ref =~ s/{{port}}/$self->sockport/eg;
496     }
497
498     return $self;
499 }
500
501
502 sub run
503 {
504     my ($self, $synch_callback) = @_;
505     my $initialized = 0;
506
507     # turn buffering off on STDERR
508     select((select(STDERR), $|=1)[0]);
509
510     # initialize command table
511     my $command_table = {};
512     foreach (keys %_commands) {
513         my $subname = "_${_}_command";
514         $command_table->{$_} = \&$subname;
515     }
516
517     my $old_ils = $/;
518     $/ = "\r\n";
519
520     if (!$initialized) {
521         $synch_callback->();
522         $initialized = 1;
523     }
524
525     $SIG{CHLD} = sub { wait };
526     my $server_sock = $self->{_server_sock};
527
528     # the accept loop
529     while (my $client_addr = accept (my $socket, $server_sock))
530     {
531         # turn buffering off on $socket
532         select((select($socket), $|=1)[0]);
533
534         # find out who connected
535         my ($client_port, $client_ip) = sockaddr_in ($client_addr);
536         my $client_ipnum = inet_ntoa ($client_ip);
537
538         # print who connected
539         print STDERR "got a connection from: $client_ipnum\n" if $log;
540
541         # fork off a process to handle this connection.
542         # my $pid = fork();
543         # unless (defined $pid) {
544         #     warn "fork: $!";
545         #     sleep 5; # Back off in case system is overloaded.
546         #     next;
547         # }
548
549         if (1) { # Child process.
550
551             # install signals
552             $SIG{URG}  = sub {
553                 $GOT_SIGURG  = 1;
554             };
555
556             $SIG{PIPE} = sub {
557                 print STDERR "Client closed connection abruptly.\n";
558                 exit;
559             };
560
561             $SIG{ALRM} = sub {
562                 print STDERR "Connection idle timeout expired. Closing server.\n";
563                 exit;
564             };
565
566             #$SIG{CHLD} = 'IGNORE';
567
568
569             print STDERR "in child\n" if $log;
570
571             my $conn = {
572                 'paths'           => FTPPaths->new($self->{'_input'},
573                                         $self->{'_server_behavior'}),
574                 'socket'          => $socket,
575                 'state'           => $_connection_states{NEWCONN},
576                 'dir'             => '/',
577                 'restart'         => 0,
578                 'idle_timeout'    => 60, # 1 minute timeout
579                 'rootdir'         => $self->{_rootDir},
580             };
581
582             print {$conn->{socket}} "220 GNU Wget Testing FTP Server ready.\r\n";
583
584             # command handling loop
585             for (;;) {
586                 print STDERR "waiting for request\n" if $log;
587
588                 last unless defined (my $req = <$socket>);
589
590                 # Remove trailing CRLF.
591                 $req =~ s/[\n\r]+$//;
592
593                 print STDERR "received request $req\n" if $log;
594
595                 # Get the command.
596                 # See also RFC 2640 section 3.1.
597                 unless ($req =~ m/^([A-Z]{3,4})\s?(.*)/i) {
598                     # badly formed command
599                     exit 0;
600                 }
601
602                 # The following strange 'eval' is necessary to work around a
603                 # very odd bug in Perl 5.6.0. The following assignment to
604                 # $cmd will fail in some cases unless you use $1 in some sort
605                 # of an expression beforehand.
606                 # - RWMJ 2002-07-05.
607                 eval '$1 eq $1';
608
609                 my ($cmd, $rest) = (uc $1, $2);
610
611                 # Got a command which matches in the table?
612                 unless (exists $command_table->{$cmd}) {
613                     print {$conn->{socket}} "500 Unrecognized command.\r\n";
614                     next;
615                 }
616
617                 # Command requires user to be authenticated?
618                 unless ($_commands{$cmd} | $conn->{state}) {
619                     print {$conn->{socket}} "530 Not logged in.\r\n";
620                     next;
621                 }
622
623                 # Handle the QUIT command specially.
624                 if ($cmd eq "QUIT") {
625                     print {$conn->{socket}} "221 Goodbye. Service closing connection.\r\n";
626                     last;
627                 }
628
629                 if (defined ($self->{_server_behavior}{fail_on_pasv})
630                         && $cmd eq 'PASV') {
631                     undef $self->{_server_behavior}{fail_on_pasv};
632                     close $socket;
633                     last;
634                 }
635
636                 # Run the command.
637                 &{$command_table->{$cmd}} ($conn, $cmd, $rest);
638             }
639         } else { # Father
640             close $socket;
641         }
642     }
643
644     $/ = $old_ils;
645 }
646
647 sub sockport {
648     my $self = shift;
649     return $self->{_server_sock}->sockport;
650 }
651
652
653 package FTPPaths;
654
655 use POSIX qw(strftime);
656
657 # not a method
658 sub final_component {
659     my $path = shift;
660
661     $path =~ s|.*/||;
662     return $path;
663 }
664
665 # not a method
666 sub path_merge {
667     my ($a, $b) = @_;
668
669     return $a unless $b;
670
671     if ($b =~ m.^/.) {
672         $a = '';
673         $b =~ s.^/..;
674     }
675     $a =~ s./$..;
676
677     my @components = split('/', $b);
678
679     foreach my $c (@components) {
680         if ($c =~ /^\.?$/) {
681             next;
682         } elsif ($c eq '..') {
683             next if $a eq '';
684             $a =~ s|/[^/]*$||;
685         } else {
686             $a .= "/$c";
687         }
688     }
689
690     return $a;
691 }
692
693 sub new {
694     my ($this, @args) = @_;
695     my $class = ref($this) || $this;
696     my $self = {};
697     bless $self, $class;
698     $self->initialize(@args);
699     return $self;
700 }
701
702 sub initialize {
703     my ($self, $urls, $behavior) = @_;
704     my $paths = {_type => 'd'};
705
706     # From a path like '/foo/bar/baz.txt', construct $paths such that
707     # $paths->{'foo'}->{'bar'}->{'baz.txt'} is
708     # $urls->{'/foo/bar/baz.txt'}.
709     for my $path (keys %$urls) {
710         my @components = split('/', $path);
711         shift @components;
712         my $x = $paths;
713         for my $c (@components) {
714             unless (exists $x->{$c}) {
715                 $x->{$c} = {_type => 'd'};
716             }
717             $x = $x->{$c};
718         }
719         %$x = %{$urls->{$path}};
720         $x->{_type} = 'f';
721     }
722
723     $self->{'_paths'} = $paths;
724     $self->{'_behavior'} = $behavior;
725 }
726
727 sub get_info {
728     my ($self, $path, $node) = @_;
729     $node = $self->{'_paths'} unless $node;
730     my @components = split('/', $path);
731     shift @components if @components && $components[0] eq '';
732
733     for my $c (@components) {
734         if ($node->{'_type'} eq 'd') {
735             $node = $node->{$c};
736         } else {
737             return undef;
738         }
739     }
740     return $node;
741 }
742
743 sub dir_exists {
744     my ($self, $path) = @_;
745     return $self->exists($path, 'd');
746 }
747
748 sub exists {
749     # type is optional, in which case we don't check it.
750     my ($self, $path, $type) = @_;
751     my $paths = $self->{'_paths'};
752
753     die "Invalid path $path (not absolute).\n" unless $path =~ m.^/.;
754     my $info = $self->get_info($path);
755     return 0 unless defined($info);
756     return $info->{'_type'} eq $type if defined($type);
757     return 1;
758 }
759
760 sub _format_for_list {
761     my ($self, $name, $info) = @_;
762
763     # XXX: mode should be specifyable as part of the node info.
764     my $mode_str;
765     if ($info->{'_type'} eq 'd') {
766         $mode_str = 'dr-xr-xr-x';
767     } else {
768         $mode_str = '-r--r--r--';
769     }
770
771     my $size = 0;
772     if ($info->{'_type'} eq 'f') {
773         $size = length  $info->{'content'};
774         if ($self->{'_behavior'}{'bad_list'}) {
775             $size = 0;
776         }
777     }
778     my $date = strftime ("%b %e %H:%M", localtime);
779     return "$mode_str 1  0  0  $size $date $name";
780 }
781
782 sub get_list {
783     my ($self, $path) = @_;
784     my $info = $self->get_info($path);
785     return undef unless defined $info;
786     my $list = [];
787
788     if ($info->{'_type'} eq 'd') {
789         for my $item (keys %$info) {
790             next if $item =~ /^_/;
791             push @$list, $self->_format_for_list($item, $info->{$item});
792         }
793     } else {
794         push @$list, $self->_format_for_list(final_component($path), $info);
795     }
796
797     return $list;
798 }
799
800 1;
801
802 # vim: et ts=4 sw=4