Skip Menu |

This queue is for tickets about the Net-xFTP CPAN distribution.

Report information
The Basics
Id: 74082
Status: resolved
Priority: 0/
Queue: Net-xFTP

People
Owner: turnerjw784 [...] yahoo.com
Requestors: cpan.org [...] mavit.org.uk
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.46
Fixed in: 0.50



Subject: Net::xFTP::Foreign::isadir() to GlobalSCAPE EFT
Net::xFTP::Foreign::isadir() identifies directories by calling opendir() on them and assuming that if this is successful, the given path must be a directory. However, when the remote SSH server is GlobalSCAPE EFT, calling opendir() on a regular file causes it to open the parent directory. The attached patch additionally calls stat() on the given path and checks the type. One would hope that a call to stat() on it's own would be sufficient, but perhaps there's some SFTP server out there where this doesn't work either, so it may be best to call both opendir() and stat().
Subject: xFTP_Foreign.pm-isadir.patch
--- xFTP_Foreign.pm~ Tue Nov 30 03:45:39 2010 +++ xFTP_Foreign.pm Mon Jan 16 16:38:51 2012 @@ -472,7 +472,12 @@ if (defined($ok) && $ok) { eval { $self->{xftp}->closedir($ok) }; - return 1; + + my $stat = $self->{xftp}->stat($path); + if (defined($stat) && S_ISDIR($stat->perm)) + { + return 1; + } } return 0; }
On Tue Jan 17 06:52:27 2012, MAVIT wrote: Show quoted text
> Net::xFTP::Foreign::isadir() identifies directories by calling opendir() > on them and assuming that if this is successful, the given path must be > a directory. > > However, when the remote SSH server is GlobalSCAPE EFT, calling > opendir() on a regular file causes it to open the parent directory. The > attached patch additionally calls stat() on the given path and checks > the type. > > One would hope that a call to stat() on it's own would be sufficient, > but perhaps there's some SFTP server out there where this doesn't work > either, so it may be best to call both opendir() and stat().
Thank you for the patch. I'll check it out as soon as I get a chance. Jim Turner
On Thu Oct 18 23:04:33 2012, TURNERJW wrote: Show quoted text
> On Tue Jan 17 06:52:27 2012, MAVIT wrote:
> > Net::xFTP::Foreign::isadir() identifies directories by calling opendir() > > on them and assuming that if this is successful, the given path must be > > a directory. > > > > However, when the remote SSH server is GlobalSCAPE EFT, calling > > opendir() on a regular file causes it to open the parent directory. The > > attached patch additionally calls stat() on the given path and checks > > the type. > > > > One would hope that a call to stat() on it's own would be sufficient, > > but perhaps there's some SFTP server out there where this doesn't work > > either, so it may be best to call both opendir() and stat().
> > Thank you for the patch. I'll check it out as soon as I get a chance. > > Jim Turner
Patch applied to new v. 0.50! Jim Turner
On Sat Jan 24 12:44:15 2015, TURNERJW wrote: Show quoted text
> On Thu Oct 18 23:04:33 2012, TURNERJW wrote:
> > On Tue Jan 17 06:52:27 2012, MAVIT wrote:
> > > Net::xFTP::Foreign::isadir() identifies directories by calling opendir() > > > on them and assuming that if this is successful, the given path must be > > > a directory. > > > > > > However, when the remote SSH server is GlobalSCAPE EFT, calling > > > opendir() on a regular file causes it to open the parent directory. The > > > attached patch additionally calls stat() on the given path and checks > > > the type. > > > > > > One would hope that a call to stat() on it's own would be sufficient, > > > but perhaps there's some SFTP server out there where this doesn't work > > > either, so it may be best to call both opendir() and stat().
> > > > Thank you for the patch. I'll check it out as soon as I get a chance. > > > > Jim Turner
> > > Patch applied to new v. 0.50! > > Jim Turner