php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58109 Wrong return value from unlink() when using together with ssh2.sftp
Submitted: 2008-03-19 09:53 UTC Modified: 2008-12-02 17:10 UTC
From: martin at netserver dot ch Assigned: mikesul (profile)
Status: Closed Package: ssh2 (PECL)
PHP Version: 5.2.1 OS: Debian Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: martin at netserver dot ch
New email:
PHP Version: OS:

 

 [2008-03-19 09:53 UTC] martin at netserver dot ch
Description:
------------
Target: Connecting with ssh2 to host, authenticate with pubkey, read Directory, copy every file to host and delete those files on remote server.

Copy() gives the correct return value (bool(true)) if the file could be copied and i can check this value. Unlink() returns false, but the file on the server has been deleted.

Using:
- Debian Linux with 2.6.22-2-686 #1 SMP Kernel
- OpenSSH_4.7p1 Debian-2, OpenSSL 0.9.8g 19 Oct 2007
- PHP 5.2.5-3 (cli)

Reproduce code:
---------------
$ssl_conn = ssh2_connect('hostname');
$ssl_auth = ssh2_auth_pubkey_file($ssl_conn, 'username', './.ssh/id_rsa.pub', './.ssh/id_rsa');

$sftp = ssh2_sftp($ssl_conn);
$path = 'ssh2.sftp://' . $sftp . '/path/';

$dir = opendir($path);
while (($entry = readdir($dir)) !== false)
{
    print $path . "\n";
    print $entry . "\n";

    $copy = copy($path . $entry, 'path/' . $entry);
    var_dump($copy);
    print_r($copy);
    
    $unlink = unlink($path . $entry);
    var_dump($unlink);
    print_r($unlink);
}

Expected result:
----------------
ssh2.sftp://Resource id #5/path/
filename
bool(true)
1
bool(true)
1


Actual result:
--------------
ssh2.sftp://Resource id #5/path/
filename
bool(true)
1
bool(false)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-02 17:10 UTC] mike at regexia dot com
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.

Applied to rename, unlink, mkdir, and rmdir. Also applied to their SFTP specific functions (not just the stream wrappers).
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Mar 29 13:01:26 2020 UTC