Bug #73556 [NEW]: Regression in mkdir() with ssh2 extension wrapper URL (ssh2.sftp://...)
| From: | jerome dot auge at anakeen dot com | Date: | Thu, 17 Nov 2016 17:00:05 +0000 |
| Subject: | Bug #73556 [NEW]: Regression in mkdir() with ssh2 extension wrapper URL (ssh2.sftp://...) | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-205436@lists.php.net to get a copy of this message | ||
From: jerome dot auge at anakeen dot com
Operating system: Linux
PHP version: 5.6.28
Package: URL related
Bug Type: Bug
Bug description:Regression in mkdir() with ssh2 extension wrapper URL (ssh2.sftp://...)
Description:
------------
After upgrading to PHP 5.6.28 it is not possible to create directories
with the mkdir("ssh2.sftp://Resource id #5/somepath")
notation: the
mkdir() call returns bool(false) and the directory is not created on the
remote host.
After instrumenting
ssh2_fopen_wrappers.c and ext/standard/url.c I
found that the problem is that the call to
php_url_parse("ssh2.sftp://Resource id #5/somepath") is
returning a
resource->path set to NULL.
Reverting the change introduced by #73192
(https://bugs.php.net/bug.php?id=73192), a call to
mkdir("ssh2.sftp://Resource id #5/somepath") correctly
creates the
remote dir and returns bool(true).
The ssh2 extension relies on the '#' character in the hostname part of
the URL to detect the underlying resource.
Test script:
---------------
$username = "sftp";
$hostname = "test.example.net";
$port = 22;
$pk = "/path/to/id_rsa.pub";
$sk = "/path/to/id_rsa";
$passphrase = "";
$dir = "/home/sftp/xxx";
$conn_ssh = ssh2_connect($hostname, $port);
ssh2_auth_pubkey_file($conn_ssh, $username, $pk, $sk, $passphrase);
$conn_sftp = ssh2_sftp($conn_ssh)
$uri = sprintf("ssh2.sftp://%s/%s", $conn_sftp, $dir);
if (mkdir($uri) === false) {
printf("Error creating directory '%s'\n", $uri);
exit(1);
}
printf("OK\n");
exit(0);
Expected result:
----------------
OK
Actual result:
--------------
Error creating directory 'ssh2.sftp://Resource id
#5//home/sftp/xxx'
--
Edit bug report at https://bugs.php.net/bug.php?id=73556&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73556&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73556&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73556&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=73556&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=73556&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=73556&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=73556&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=73556&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=73556&r=support
Expected behavior: https://bugs.php.net/fix.php?id=73556&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=73556&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=73556&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=73556&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73556&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=73556&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=73556&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=73556&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=73556&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=73556&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=73556&r=mysqlcfg