ます’s Blog - どうでもいい記事100選

どうでもいい記事100選

allow_url_includeとallow_url_fopenをINI_ALLに変更するパッチ(4.4.2用)

昨日に引き続き、今回はこの辺()に関連する事ですが。ついでにこの辺()も関連します。
ひとまずタコさんパッチを放流〜。大垣さんのトコに置いて頂けるよう、お願いしてみようかしら。

--- php-4.4.2,orig/main/main.c	2006-01-01 22:46:59.000000000 +0900
+++ php-4.4.2/main/main.c	2006-02-03 13:24:10.000000000 +0900
@@ -352,7 +352,8 @@
 	PHP_INI_ENTRY("disable_functions",			"",			PHP_INI_SYSTEM,		NULL)
 	PHP_INI_ENTRY("disable_classes",			"",			PHP_INI_SYSTEM,		NULL)
 
-	STD_PHP_INI_BOOLEAN("allow_url_fopen",		"1",		PHP_INI_SYSTEM,		OnUpdateBool,			allow_url_fopen,			php_core_globals,	core_globals)
+	STD_PHP_INI_BOOLEAN("allow_url_fopen",		"1",		PHP_INI_ALL,		OnUpdateBool,			allow_url_fopen,			php_core_globals,	core_globals)
+	STD_PHP_INI_BOOLEAN("allow_url_include",		"0",		PHP_INI_ALL,		OnUpdateBool,			allow_url_include,			php_core_globals,	core_globals)
 	STD_PHP_INI_BOOLEAN("always_populate_raw_post_data",		"0",		PHP_INI_SYSTEM|PHP_INI_PERDIR,		OnUpdateBool,			always_populate_raw_post_data,			php_core_globals,	core_globals)
 
 PHP_INI_END()
--- php-4.4.2,orig/main/php_globals.h	2006-01-01 22:46:59.000000000 +0900
+++ php-4.4.2/main/php_globals.h	2006-02-03 13:24:10.000000000 +0900
@@ -138,6 +138,8 @@
 
 	zend_bool allow_url_fopen;
 
+	zend_bool allow_url_include;
+
 	zend_bool always_populate_raw_post_data;
 	
 	long serialize_precision;
--- php-4.4.2,orig/main/streams.c	2006-01-01 22:47:00.000000000 +0900
+++ php-4.4.2/main/streams.c	2006-02-03 13:27:21.000000000 +0900
@@ -2578,7 +2578,7 @@
 		return (options & STREAM_LOCATE_WRAPPERS_ONLY) ? NULL : &php_plain_files_wrapper;
 	}
 
-	if (wrapper && wrapper->is_url && !PG(allow_url_fopen)) {
+	if ((wrapper && wrapper->is_url) && (!PG(allow_url_fopen) || (options & STREAM_OPEN_FOR_INCLUDE) && !PG(allow_url_include)) ) {
 		if (options & REPORT_ERRORS)
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "URL file-access is disabled in the server configuration");
 		return NULL;

(個人的に)今ひとつなのが「allow_url_fopen」を「Off」にして「allow_url_include」を「On」にしても、includeで外部URLが参照できません(「allow_url_fopen」が「Off」なので)。
このパッチの意味合いは「allow_url_fopen」は「On」にしたいけど「allow_url_include」は「Off」にしたい。。。という事なんだろう。うーん。
厳密に行なう為には、もう少し上流の方で対応する必要がありそうです。
CVS HEADからのバックポートらしいので、将来的には変わる可能性があるかもね。