Subject: | Net::SFTP not handling extended attributes in directory listings |
Date: | Tue, 19 Aug 2008 16:00:57 +0000 |
To: | bug-Net-SFTP [...] rt.cpan.org |
From: | Rob Coward <Rob.Coward [...] game.co.uk> |
I have recently had to try connecting via SFTP to a IBM z9 Enterprise
Class Mainframe running OpenSSH 3.8.1p1. The Net::SFTP library was
unable to correctly return a directory listing.
After much digging, it appears that the code has not been written to
handle the optional extended attribute pairs, so the parsing of the
SSH2_FXP_NAME response was losing the boundaries between directory
entries.
I am using perl-Net-SFTP-0.10-2.fc9.src.rpm as downloaded from the
Fedora9 sources. The following diff will add the necessary support for
extended attributes.
Hope someone else finds this useful.
Regards,
Rob Coward
--- /usr/lib/perl5/vendor_perl/5.8.8/Net/SFTP/Attributes.pm
2001-05-16 02:38:01.000000000 +0100
+++ perl/Net/SFTP/Attributes.pm 2008-08-19 16:25:32.000000000 +0100
@@ -58,6 +58,14 @@
$a->{atime} = $buf->get_int32;
$a->{mtime} = $buf->get_int32;
}
+ if ($a->{flags} & SSH2_FILEXFER_ATTR_EXTENDED) {
+ my $extended_count = $buf->get_int32;
+ for (1..$extended_count) {
+ my $name = $buf->get_str;
+ my $value = $buf->get_str;
+ $a->{$name} = $value;
+ }
+ }
}
$a;
}
Please consider the environment before printing this email.
GAME Stores Group Ltd has been awarded ‘Retailer of the Year’ at the 2006 and 2007 Golden Joystick Awards and
'Thames Valley Business Award' for Outstanding Employer of Choice 2006.
This e-mail and any files transmitted with it are confidential and intended solely for the use of the
individual or entity to whom they are addressed. If you have received this e-mail in error please
notify the system manager at:
mailto:postmaster@game.co.uk
The recipient acknowledges that the transmissions made via the Internet can be corrupted and therefore
THE GAME GROUP PLC and any of its subsidiaries do not give any warranty as to the quality or accuracy of
any information contained in the message or assume any liability for it or for its transmission, reception or storage.
This footnote also confirms that this e-mail message has been swept by anti-virus software for the presence of computer viruses.
http://www.game.co.uk
http://www.gamegroup.plc.uk
Registered Number: 1937170
Registered Office: Unity House, Telford Road, Basingstoke, Hampshire. RG21 6YJ Registered in England and Wales.