The chroot() doesn't get properly enabled/disabled when building SAPIs
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C
- Star
- 40.4k
- Fork
- 8.2k
- Merge trung bình
- 2 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 96
Mô tả
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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với ext/standard/config.m4 và main/main.c, sau đó so sánh hành vi build dành riêng cho SAPI được mô tả trong các lệnh configure. Build lại với và không có --enable-embed rồi chạy check-chroot.php thông qua litespeed SAPI. Được xem là hoàn tất khi khả năng sử dụng chroot() khớp với thiết kế SAPI dự kiến mà không tạo ra các build không nhất quán.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- c, php
- Lĩnh vực
- build-system
- Loại issue
- Lỗi
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100