|  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: 2014-07-13 02:50 UTC
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:
Status: Open Package: Directory function related
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
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
From manual page:

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/";

Expected result:
the directory resource

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-05-07 18:23 UTC] bluej100 at gmail dot com
This is discussed at, 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]
-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.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Sep 28 23:03:37 2021 UTC