The chroot() doesn't get properly enabled/disabled when building SAPIs
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- C
- Estrellas
- 40.4k
- Forks
- 8.2k
- Merge medio
- 2 d 13 h
- PR fusionados (30 d)
- 96
Descripción
Description
The following code:
<?php
// check-chroot.php
if(function_exists('chroot')) {
echo 'chroot() exists';
} else {
echo 'chroot() not available';
}
Resulted in this output when building like this:
./buildconf
./configure --disable-embed --enable-litespeed
make -j$(nproc)
./sapi/litespeed/php check-chroot.php
# chroot() not available (which is ok by current design)
And resulted in this output when building like this:
./buildconf
./configure --enable-embed --enable-litespeed
make -j$(nproc)
./sapi/litespeed/php check-chroot.php
# chroot() exists (probably not ok)
But I would probably expect this output instead:
./buildconf
./configure --enable-embed --enable-litespeed
make -j$(nproc)
./sapi/litespeed/php check-chroot.php
# chroot() not available
There is a check for relatively dangerous chroot() function in ext/standard/config.m4, where ENABLE_CHROOT_FUNC constant gets defined depending on the selected SAPI:
AC_DEFINE(ENABLE_CHROOT_FUNC, 1, [Whether to enable chroot() function])
However, this is one of the parts that complicates the PHP build process. To get proper SAPIs, they all need to be build separately according to current design.
I'm just noting this bug for possible future reference. I'm not sure yet how to fix this better. Because disabling chroot() function might seem more appropriate in the C code directly in the main/main.c (however, this is probably not good fix yet):
--- a/main/main.c
+++ b/main/main.c
@@ -2223,6 +2223,10 @@ zend_result php_module_startup(sapi_module_struct *sf, zend_module_entry *additi
}
}
+ if (strcmp(sapi_module.name, "cli") != 0 && strcmp(sapi_module.name, "cgi-fcgi") != 0 && strcmp(sapi_module.name, "phpdbg") != 0 && strcmp(sapi_module.name, "embed") != 0) {
+ zend_disable_functions("chroot");
+ }
+
/* disable certain classes and functions as requested by php.ini */
zend_disable_functions(INI_STR("disable_functions"));
php_disable_classes();
PHP Version
PHP 8.1+
Operating System
*nix
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con ext/standard/config.m4 y main/main.c; después, compara el comportamiento de compilación específico de SAPI descrito en los comandos configure. Vuelve a compilar con y sin --enable-embed y ejecuta check-chroot.php mediante la litespeed SAPI. Se considera completado cuando la disponibilidad de chroot() coincide con el diseño previsto de SAPI sin introducir compilaciones inconsistentes.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- c, php
- Área
- build-system
- Tipo de issue
- Error
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100