Req #48506 [Opn->Fbk]: upcoming apr closes descriptors by default
| From: | cmb@php.net | Date: | Thu, 05 Nov 2020 13:49:52 +0000 |
| Subject: | Req #48506 [Opn->Fbk]: upcoming apr closes descriptors by default | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-230132@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=48506&edit=1
ID: 48506
Updated by: cmb@php.net
Reported by: arekm at maven dot pl
Summary: upcoming apr closes descriptors by default
-Status: Open
+Status: Feedback
Type: Feature/Change Request
Package: Apache2 related
PHP Version: 5.2.9
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
I assume that this has already been catered to, hasn't it?
Previous Comments:
------------------------------------------------------------------------
[2009-07-25 15:01:53] arekm at maven dot pl
Note that latest released stable apr 1.3.6 also contains these changes and distributions will start
to pick up these soon.)
------------------------------------------------------------------------
[2009-06-09 14:09:23] scottmac@php.net
The details are here https://issues.apache.org/bugzilla/show_bug.cgi?id=46425
------------------------------------------------------------------------
[2009-06-09 13:47:52] arekm at maven dot pl
Description:
------------
Upcoming apr 2.0.0 (or 1.3 with backported patch) uses O_CLOEXEC for own descriptors by default.
This means that when using shell_exec() the run script/binary has no stdin/stdout/stderr due to
O_CLOEXEC. This also means that if any output is produced then script ends with EPIPE.
Tested with apache + apr 1.3 with backported patch.
http://svn.apache.org/viewvc/apr/apr/trunk/CHANGES?r1=747357&r2=748988
Reproduce code:
---------------
<?php
echo shell_exec("LC_ALL=C strace -o /tmp/WYNIK -f -F -s 200 ls -l /notexistingfile");
?>
Run from apache + php + apr 1.3 + backported O_CLOEXEC patch like this one http://cvs.pld-linux.org/cgi-bin/cvsweb/packages/apr/apr-bug-46425.patch?rev=1.8
Expected result:
----------------
run "ls -l" and produce some output about file not existing
Actual result:
--------------
30120 lstat("/notexistingfile", 0x18f55f0) = -1 ENOENT (No such file or directory)
30120 write(2, "ls: ", 4) = -1 EBADF (Bad file descriptor)
30120 write(2, "cannot access /notexistingfile", 30) = -1 EBADF (Bad file descriptor)
30120 write(2, ": No such file or directory", 27) = -1 EBADF (Bad file descriptor)
30120 write(2, "\n", 1) = -1 EBADF (Bad file descriptor)
30120 close(1) = 0
30120 close(2) = -1 EBADF (Bad file descriptor)
30120 exit_group(2)
As you can see there is no file descriptor 2 and this means that ls output is lost.
Probably the best for php is to always provide own descriptors without relying on apache provided
one.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=48506&edit=1