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
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: 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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 08 02:01:28 2024 UTC