php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73556 Regression in mkdir() with ssh2 extension wrapper URL (ssh2.sftp://...)
Submitted: 2016-11-17 17:00 UTC Modified: 2016-11-17 17:15 UTC
From: jerome dot auge at anakeen dot com Assigned:
Status: Duplicate Package: URL related
PHP Version: 5.6.28 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jerome dot auge at anakeen dot com
New email:
PHP Version: OS:

 

 [2016-11-17 17:00 UTC] jerome dot auge at anakeen dot com
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'

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-17 17:15 UTC] requinix@php.net
-Status: Open +Status: Duplicate
 [2016-11-17 17:15 UTC] requinix@php.net
Duplicate of bug #73506
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 22 01:01:30 2024 UTC