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
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