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 Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
36 + 5 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Thu Apr 25 14:01:31 2024 UTC