php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54431 opendir() does not work with ftps:// wrapper
Submitted: 2011-03-31 13:48 UTC Modified: 2016-07-23 12:08 UTC
Votes:8
Avg. Score:4.4 ± 1.0
Reproduced:7 of 7 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (14.3%)
From: chrisw at networkm dot co dot uk Assigned: nikic (profile)
Status: Closed Package: Directory function related
PHP Version: 5.2.17 OS: Windows XP & 2003 R2
Private report: No CVE-ID: None
 [2011-03-31 13:48 UTC] chrisw at networkm dot co dot uk
Description:
------------
opendir() triggers 2 warnings when used with ftps:// wrapper URLs and fails.

fopen() works with files contained within the directory I am trying to open.

If opendir() is not designed to work with ftps://, I would request this as a feature (since ftp_ssl_open() does not work in standard Windows builds).

Test script:
---------------
<?php

  // This works
  $fp = fopen("ftps://$user:$pass@$host:$port/$file");
  while ($part = fread($fp,1024)) $filedata .= $part;
  fclose($fp);
  print("Downloaded file:\n$filedata");

  // This doesn't work, triggers 2 warnings
  print("\n\nDirectory listing:\n");
  $dp = opendir("ftps://$user:$pass@$host:$port/");
  while ($file = readdir($dp)) print("$file\n");
  closedir($dp);

?>

Expected result:
----------------
Downloaded file:
<contents of file>

Directory listing:
<list of files>

Actual result:
--------------
Downloaded file:
<contents of file>

Directory listing:
Warning: opendir(): SSL/TLS already set-up for this stream in <script path> on line 11
Warning: opendir(ftps://...@host:port/): failed to open dir: Unable to activate SSL mode in <script path> on line 11

Patches

54431.patch (last revision 2016-07-21 08:47 UTC by vhu at iki dot fi)

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-03-31 14:00 UTC] chrisw at networkm dot co dot uk
Apologies, the second warning listed in actual result is incomplete.

Full message is:
Warning: opendir(ftps://...@host:port/): failed to open dir: Unable to activate SSL mode
FTP server reports 150 Accepted data connection
in <script path> on line 11

The fact that it gets far enough to recieve that error message from the remote server suggests to me that this should work, and the first message suggests that opendir() is trying to initiate the SSL/TLS connection twice.

Wireshark captures show a lot of traffic between the client and server before the errors are thrown, including a successful AUTH TLS command and a successful TLS handshake.
 [2016-07-21 08:49 UTC] vhu at iki dot fi
I can reproduce this on today's php-src/master from github. Patch as attachment.
 [2016-07-23 12:08 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 08:01:29 2024 UTC