# chroot function availability disqualifiers

- Thread: https://externals.io/message/50113
- Original archive: https://news-web.php.net/php.internals/50113
- Started by Justin Martin on 2010-11-06T20:37:54+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #50113 — Justin Martin — 2010-11-06T20:37:54+00:00

URL: https://externals.io/message/50113#50113

Hello everyone,

As a bit of proactive documentation, I'm trying to determine exactly 
what the disqualifying conditions are for chroot's availability in PHP.

So far as I can tell, from ext/standard/dir.c, chroot is only compiled 
in #if defined(HAVE_CHROOT) && !defined(ZTS) && ENABLE_CHROOT_FUNC

HAVE_CHROOT seems to always be set to 1 by php_config.h, so far as I can 
tell. ZTS, as I understand it, indicates whether PHP is being compiled 
threadsafe, and ENABLE_CHROOT_FUNC seems to be related to the 
deprecated(?) --enable-chroot-func switch.

Could someone with a better understanding of the compile process 
illuminate me as to all of the reasons why chroot might not be available?

Thanks,
Justin Martin, a.k.a. FrozenFire

---

## #50115 — johannes@schlueters.de — 2010-11-06T21:27:39+00:00

URL: https://externals.io/message/50113#50115 · In reply to: #50113

Hi,


> So far as I can tell, from ext/standard/dir.c, chroot is only compiled 
> in #if defined(HAVE_CHROOT) && !defined(ZTS) && ENABLE_CHROOT_FUNC

The relevant checks are in ext/standard/config.m4:

        if test "$PHP_SAPI" = "cgi" || test "$PHP_SAPI" = "cli" || test "$PHP_SAPI" = "embed"; then
          AC_DEFINE(ENABLE_CHROOT_FUNC, 1, [Whether to enable chroot() function])
        fi

and configure.in:
        
        AC_CHECK_FUNCS(
        ...
        chroot \
        ...
        )

The first test checks the sapi as we don't want to allow chroot() from
withina server module, like chroot()ing an apache child etc.

The later check sets HAVE_CHROOT if it can be found on the host OS. I
assume any used "Unix" system has chroot() in it's libc library.

johannes
