The chroot() doesn't get properly enabled/disabled when building SAPIs
まだ誰も着手していません。
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.2k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
ext/standard/config.m4 と main/main.c から始め、その後、configure コマンドに記述されている SAPI 固有のビルド動作を比較します。--enable-embed を付けた場合と付けない場合で再ビルドし、litespeed SAPI を通じて check-chroot.php を実行します。chroot() の利用可能性が意図した SAPI 設計と一致し、一貫性のないビルドを導入していなければ完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, php
- 領域
- build-system
- issue の種類
- バグ
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100