php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72988 ssh2.sftp wrapper does not work with multiple connections correctly
Submitted: 2016-08-31 09:34 UTC Modified: -
From: liborm85 at gmail dot com Assigned:
Status: Closed Package: ssh2 (PECL)
PHP Version: 7.0.10 OS: Debian 8.1
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: liborm85 at gmail dot com
New email:
PHP Version: OS:

 

 [2016-08-31 09:34 UTC] liborm85 at gmail dot com
Description:
------------
If I using wrappers ssh2.sftp on one connection all works correctly.
But if I connected to two servers at one time, both connections works if I using methods ssh2_..., but with ssh2.sftp wrapper works only first connection, second connection return for example this warning:
Warning:  stat(): stat failed for ssh2.sftp://Resource id #14/some/file/that/exists in /test.php on line 19

Not working function stat, file_exists, is_file, etc.

Using PHP 7.0.10, php-ssh2 1.0.

In PHP 5.4 and php-ssh2 0.12 it works fine.

Test script:
---------------
function connect($host, $user, $pass) {
  $session = ssh2_connect($host, 22);
  ssh2_auth_password($session, $user, $pass);
  $sftp = ssh2_sftp($session);
  return $sftp;
}

// first connection
$sftp1 = connect("server1.example.com", "user", "password");
$path1 = "/some/file/that/exists";
$stat1 = stat("ssh2.sftp://$sftp1" . $path1); // works
var_dump($stat1 === false ? 'ERROR' : 'OK');
$sshstat1 = ssh2_sftp_stat($sftp1, $path1); // works
var_dump($sshstat1 === false ? 'ERROR' : 'OK');

// second connection to another server
$sftp2 = connect("server2.example.com", "user", "password");
$path2 = "/some/file/that/exists";
$stat2 = stat("ssh2.sftp://$sftp2" . $path2); // doesn't work
var_dump($stat2 === false ? 'ERROR' : 'OK');
$sshstat2 = ssh2_sftp_stat($sftp2, $path2); // works
var_dump($sshstat2 === false ? 'ERROR' : 'OK');


Expected result:
----------------
string(2) "OK"
string(2) "OK"
string(2) "OK"
string(2) "OK"

Actual result:
--------------
string(2) "OK"
string(2) "OK"
<br />
<b>Warning</b>:  stat(): stat failed for ssh2.sftp://Resource id #14/some/file/that/exists in <b>/test.php</b> on line <b>19</b><br />
string(5) "ERROR"
string(2) "OK"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-09-27 03:15 UTC] langemeijer@php.net
Automatic comment on behalf of liborm85@gmail.com
Revision: http://git.php.net/?p=pecl/networking/ssh2.git;a=commit;h=de29c9a7cfb42038c707797b12733f64c3d20e28
Log: bugfix #72988
 [2016-09-27 03:15 UTC] langemeijer@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Nov 27 03:01:29 2024 UTC