Bug #66884 [Asn]: php://fd/x file descriptors not usable outside CLI mode

From: Date: Sun, 13 Apr 2014 01:14:14 +0000
Subject: Bug #66884 [Asn]: php://fd/x file descriptors not usable outside CLI mode
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185195@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66884&edit=1 ID: 66884 Updated by: tyrael@php.net Reported by: dfuhry at gmail dot com Summary: php://fd/x file descriptors not usable outside CLI mode Status: Assigned Type: Bug Package: Streams related Operating System: Linux 2.6.32-5-amd64 PHP Version: 5.6.0alpha3 Assigned To: stas Block user comment: N Private report: N New Comment: as far as I know it was changed, because it opened a can op worms from the security point of view, see: http://www.slideshare.net/phdays/on-secure-application-of-php-wrappers Previous Comments: ------------------------------------------------------------------------ [2014-03-11 15:55:56] dfuhry at gmail dot com Description: ------------ Commit df2a38e7f8603f51afa4c2257b3369067817d818 removed the ability to use php://fd/x file descriptors in non-CLI mode. Thus, sometime after PHP 5.3 it became no longer possible to issue parallel async database queries and stream_select on the array of database connection socket file descriptors. When trying to fopen("php://fd/x") (for some file descriptor number "x") the unhelpful error I receive is: "failed to open stream: operation failed". Neither the commit nor source comments make clear to me why the change was made, but if it is possible to revert it, or otherwise make alterations to allow the above use case, I would advocate doing so. I use unexposed pg_socket() method in the below, which returns the file descriptor of the socket of the database connection. Test script: --------------- $conn1 = pg_connect("dbname=a user=b host=c"); $conn2 = pg_connect("dbname=a user=b host=c"); // Next two lines should return resources representing file descriptors // but instead error and return FALSE. $r1 = fopen("php://fd/" . pg_socket($conn1)); $r2 = fopen("php://fd/" . pg_socket($conn2)); pg_send_query($conn1, "SELECT pg_sleep(random())"); pg_send_query($conn2, "SELECT pg_sleep(random())"); $r = array($r1, r2); $w = array(); $e = array(); stream_select($r, $w, $e, NULL); // Would return whichever conn finished first. Expected result: ---------------- fopen("php://fd/x") calls return a valid stream resource, not FALSE. Actual result: -------------- ... failed to open stream: operation failed ... ... failed to open stream: operation failed ... ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66884&edit=1

« previous php.bugs (#185195) next »