php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65226 chroot() does not get enabled
Submitted: 2013-07-09 14:37 UTC Modified: 2013-07-10 22:56 UTC
From: josh at servebyte dot com Assigned: ab
Status: Closed Package: CGI/CLI related
PHP Version: 5.5.0 OS: Debian 7
Private report: No CVE-ID:
 [2013-07-09 14:37 UTC] josh at servebyte dot com
Description:
------------
PHP Fatal error:  Call to undefined function chroot() in Command line code on line 1

During the configure process it states that chroot is available: "checking for chroot... yes"

The php version: "PHP 5.5.0 (cli) (built: Jul  9 2013 15:30:23)"

The user is root.

As per the documentation, these are the only requirements. Perhaps I missing a configure variable? I have tested with just "./configure" with no params to ensure nothing else is interfering.

Thread safety is disabled: "checking whether to enable thread-safety... no"

Test script:
---------------
php -r "chroot('/var/chroot/');"

Expected result:
----------------
The chroot function should be available

Actual result:
--------------
The chroot function is excluded from the PHP build

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-10 16:00 UTC] josh at servebyte dot com
Seems to work fine with PHP 5.3


# php -r "chroot();"
Warning: chroot() expects exactly 1 parameter, 0 given in Command line code on line 1

PHP 5.3.26 (cli) (built: Jul 10 2013 16:52:53)
 [2013-07-10 16:43 UTC] josh at servebyte dot com
However the problem is in PHP 5.4 too

#php -r "chroot();"
Fatal error: Call to undefined function chroot() in Command line code on line 1

PHP 5.4.17 (cli) (built: Jul 10 2013 17:36:53)
 [2013-07-10 16:51 UTC] josh at servebyte dot com
PHP 5.3... during the configure $PHP_SAPI is set to: cgi
PHP 5.5... during the configure $PHP_SAPI is set to: none
 [2013-07-10 17:09 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2013-07-10 17:09 UTC] ab@php.net
#if defined(HAVE_CHROOT) && !defined(ZTS) && ENABLE_CHROOT_FUNC

thats what has to match.

please post the output of 

./config.nice | grep chroot
 [2013-07-10 17:24 UTC] josh at servebyte dot com
There's no file called config.nice in the 5.5.0 tar?

./configure | grep chroot
checking for chroot... yes

I can get it working by editing the configure file and commenting these lines like so;

if test "$PHP_SAPI" = "cgi" || test "$PHP_SAPI" = "cli" || test "$PHP_SAPI" = $
$as_echo "#define ENABLE_CHROOT_FUNC 1" >>confdefs.h
fi

to 

#if test "$PHP_SAPI" = "cgi" || test "$PHP_SAPI" = "cli" || test "$PHP_SAPI" = $
$as_echo "#define ENABLE_CHROOT_FUNC 1" >>confdefs.h
#fi

The variable $PHP_SAPI is set to "none" so it seems to be a configure bug of some sort.
 [2013-07-10 17:40 UTC] ab@php.net
That's clear that you can trick it to out the desired define :) ... 

Ok, i also see 'checking for chroot ... yes', but i do --enable-cgi --enable-cli 
too, not just ./configure . That might be the difference. Haven't looked where 
PHP_SAPI is set, you could debug it.

config.nice is created once ./configure was run, so you don't have to type all 
the options again.
 [2013-07-10 19:18 UTC] josh at servebyte dot com
Adding "--enable-cgi --enable-cli" to configure didn't change anything. 

$PHP_SAPI is in A LOT of files. I don't know where to start looking for it. :(
 [2013-07-10 22:52 UTC] ab@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=2acc38627092123ac462f3a23780bf887bf69286
Log: Fixed bug #65226 chroot() does not get enabled
 [2013-07-10 22:52 UTC] ab@php.net
-Status: Feedback +Status: Closed
 [2013-07-10 22:56 UTC] ab@php.net
-Assigned To: +Assigned To: ab
 [2013-07-10 22:56 UTC] ab@php.net
Please test on 5.4+ git. You still have to disable any SAPI other than 
CLI/CGI/embed for that to work.
 [2013-07-11 12:52 UTC] josh at servebyte dot com
I tested both the PHP 5.4 and 5.5 git branches and can confirm that this is fixed.

I used this command for testing: ./configure --prefix=/opt/php/5.x 

Thank you very much!
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 25 07:02:14 2014 UTC