Skip Menu |

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

Report information
The Basics
Id: 44244
Status: resolved
Worked: 20 min
Priority: 0/
Queue: Net-SFTP-Foreign

People
Owner: salva [...] cpan.org
Requestors: erikweidel [...] web.de
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.48_03
Fixed in: (no value)



Subject: setcwd with relative path causes error when cwd is /
I just came across some strange behaviour: The setcwd-function returns a failure when being in "/" and then calling setcwd with a relative path. Example-code: ------------ use Net::SFTP::Foreign; my $known_hosts_opt = "-oUserKnownHostsFile=c:\\temp\\ssh\\known_hosts"; my $ref_more_opts = [-i => "c:\\temp\\ssh\\id_rsa", ' "'.$known_hosts_opt.'"', ]; $ftp = Net::SFTP::Foreign->new( host => "127.0.0.1", user => "erik", port => 22, ssh_cmd => "ssh.exe", ssh_cmd_interface => 'ssh', more => $ref_more_opts, ); print "login\n"; print "cwd: ".$ftp->cwd()."\n"; $ftp->setcwd("/"); print "cwd: ".$ftp->cwd()."\n"; $ftp->setcwd("home"); print "error: ".$ftp->error."\n"; print "cwd: ".$ftp->cwd()."\n"; $ftp->setcwd("erik"); print "cwd: ".$ftp->cwd()."\n"; ---------- The script hangs for a few seconds in $ftp->setcwd("home") then says "error: Couldn't get realpath for remote '//home': Failure". When calling $ftp->setcwd("/home"), everything works fine. I have traced it to the _rel2abs function in Foreign.pm. The statement return "$sftp->{cwd}/$path" produces the second slash. Replacing it with something like my $tmp_path = "$sftp->{cwd}/$path"; $tmp_path =~ s#//+#/#g; return $tmp_path; helps. My working environment is Windows XP with a local runnig COP-SSH-server which is a "OpenSSH_5.1p1, OpenSSL 0.9.8j 07 Jan 2009" and the ssh.exe is from there, too. I have tested it with Strawberry Perl 5.8.8.4. I have also tried connecting to a openssh-server 4.7p1 on a Ubuntu-Linux 8.04. Here the problem does not occur. Maybe the ssh-server version 5.1 is more restrictive on that or is even buggy ? Nevertheless: sending "//home" does not seem to make sense to me so I thought, maybe you want to fix it :-)
solved in 1.49