diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 7d10d5c044c..f401bd192a2 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -653,7 +653,7 @@ function_entry basic_functions[] = { PHP_FE(closedir, NULL) PHP_FE(chdir, NULL) -#if defined(HAVE_CHROOT) && !defined(ZTS) +#if defined(HAVE_CHROOT) && !defined(ZTS) && ENABLE_CHROOT_FUNC PHP_FE(chroot, NULL) #else PHP_FALIAS(chroot, warn_not_available, NULL) diff --git a/ext/standard/config.m4 b/ext/standard/config.m4 index cdfa5269dc3..e0043d23a78 100644 --- a/ext/standard/config.m4 +++ b/ext/standard/config.m4 @@ -229,4 +229,8 @@ AC_ARG_WITH(system-regex, fi ]) +if test "$PHP_SAPI" = "cgi"; then + AC_DEFINE(ENABLE_CHROOT_FUNC, 1, [Whether to enable chroot() function]) +fi + PHP_EXTENSION(standard) diff --git a/ext/standard/dir.c b/ext/standard/dir.c index b0022e28e52..186318a6bf4 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -221,7 +221,7 @@ PHP_FUNCTION(closedir) /* }}} */ -#if defined(HAVE_CHROOT) && !defined(ZTS) +#if defined(HAVE_CHROOT) && !defined(ZTS) && ENABLE_CHROOT_FUNC /* {{{ proto int chroot(string directory) Change root directory */ diff --git a/ext/standard/php_dir.h b/ext/standard/php_dir.h index 186a7cdc890..3b648c62df5 100644 --- a/ext/standard/php_dir.h +++ b/ext/standard/php_dir.h @@ -28,7 +28,7 @@ PHP_RINIT_FUNCTION(dir); PHP_FUNCTION(opendir); PHP_FUNCTION(closedir); PHP_FUNCTION(chdir); -#if defined(HAVE_CHROOT) && !defined(ZTS) +#if defined(HAVE_CHROOT) && !defined(ZTS) && ENABLE_CHROOT_FUNC PHP_FUNCTION(chroot); #endif PHP_FUNCTION(getcwd);