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
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:
25 + 11 = ?
Subscribe to this entry?

 
 [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: Fri Dec 06 05:01:29 2024 UTC