php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64169 opendir not working with sftp since upgrade from php 5.3.14 to 5.3.21
Submitted: 2013-02-07 11:17 UTC Modified: 2021-10-24 04:22 UTC
Votes:12
Avg. Score:4.2 ± 0.8
Reproduced:11 of 11 (100.0%)
Same Version:3 (27.3%)
Same OS:6 (54.5%)
From: michael dot dalbosco at gmail dot com Assigned: cmb (profile)
Status: No Feedback Package: ssh2 (PECL)
PHP Version: 5.6.0-dev OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: michael dot dalbosco at gmail dot com
New email:
PHP Version: OS:

 

 [2013-02-07 11:17 UTC] michael dot dalbosco at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.opendir#refsect1-function.opendir-description
---

I'm connecting to a Sftp server and try to open a directory on this server. It worked fine on php 5.3.10 and php 5.3.14 but since we upgraded to 5.3.21 it doesn't work anymore, opendir returns false.


Test script:
---------------
$con = ssh2_connect($server, $port);
ssh2_auth_pubkey_file ( $con, $login, $pubKeyFile, $privKeyFile);
$sftp = ssh2_sftp($con);
$dir = "ssh2.sftp://$sftp/";
var_dump(opendir($dir));

Expected result:
----------------
the directory resource

Actual result:
--------------
false

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-05-07 18:23 UTC] bluej100 at gmail dot com
This is discussed at http://stackoverflow.com/a/16238476/69173, which notes that you can work around the issue by appending an explicit current-directory period.

I'm willing to try to create a patch for this. It'll be a little tough to write a test case for it, though--should I include a reference to a public sftp share?
 [2013-05-07 18:25 UTC] bluej100 at gmail dot com
This ticket may belong under PECL->SSH2 rather than directory functions.
 [2013-05-07 23:48 UTC] bluej100 at gmail dot com
I've done a build of 5.6.0-dev head with ssh2 0.12 and confirmed that this bug is still present.
 [2013-05-18 16:44 UTC] bluej100 at gmail dot com
To clarify, this issue specifically affects the root directory, if Michael and I are seeing the same thing. Subdirectory listing works fine.
 [2014-07-13 02:50 UTC] yohgaki@php.net
-Operating System: Debian 4.4.5-8 +Operating System: Linux -PHP Version: 5.3.21 +PHP Version: 5.6.0-dev
 [2018-06-07 09:54 UTC] cr at keppler-it dot de
Bug still exists with PHP 7.2.6 and SSH2 PECL Plugin 1.1.2-alpha 

Possible Workaround still is to appending a dot (.) to the root directory.
 [2019-03-20 18:27 UTC] ken at pardiac dot com
This is the same problem as bug #69981. I've put a patch there that fixes this. I also added a comment explaining the bug and the fix. I'm not sure how to get the fix into the code base though.
 [2021-10-11 11:07 UTC] cmb@php.net
-Status: Open +Status: Feedback -Package: Directory function related +Package: ssh2 -Assigned To: +Assigned To: cmb
 [2021-10-11 11:07 UTC] cmb@php.net
Is this still an issue with latest ssh2 (1.3.1)?
 [2021-10-24 04:22 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 22:01:28 2024 UTC