Bug #54431 [Opn->Csd]: opendir() does not work with ftps:// wrapper

From: Date: Sat, 23 Jul 2016 12:08:16 +0000
Subject: Bug #54431 [Opn->Csd]: opendir() does not work with ftps:// wrapper
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202523@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=54431&edit=1

 ID:                 54431
 Updated by:         nikic@php.net
 Reported by:        chrisw at networkm dot co dot uk
 Summary:            opendir() does not work with ftps:// wrapper
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            Directory function related
 Operating System:   Windows XP & 2003 R2
 PHP Version:        5.2.17
-Assigned To:        
+Assigned To:        nikic
 Block user comment: N
 Private report:     N

 New Comment:

Fixed by https://github.com/php/php-src/commit/65abdb556ddf67068951020b8829c0817697a84e
in 5.6+.


Previous Comments:
------------------------------------------------------------------------
[2016-07-21 09:49:27] vhu at iki dot fi

Related To: Bug #41021

------------------------------------------------------------------------
[2016-07-21 08:49:52] vhu at iki dot fi

I can reproduce this on today's php-src/master from github. Patch as attachment.

------------------------------------------------------------------------
[2011-03-31 14:00:33] 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.

------------------------------------------------------------------------
[2011-03-31 13:48:48] 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


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=54431&edit=1


Thread (4 messages)

« previous php.bugs (#202523) next »