[PATCH] for safe_mode
| From: | Tomek Lipski | Date: | Sun, 28 Oct 2001 20:17:03 +0000 |
| Subject: | [PATCH] for safe_mode | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-69211@lists.php.net to get a copy of this message | ||
Hi!
I've produced a simple patch for PHP 4.0.6 which enables administrator to
allow scripts access to include dir eg. for some common php scripts, during
safe_mode of course.
Anyway it may produce a bug [dunno why :(] that causes open_basedir to be
turned on automagically when include_path is set.
--
email: [Tomek.Lipski@ecl.pl] gsm: +48 606 787423
echo Ecl.Pl Al. NMP 31 Częstochowa http://www.ecl.pl/
// Ja zacznę programować, a ty dowiedz się, czego chcą
diff -ur main.orig/main.c main/main.c --- main.orig/main.c Tue May 8 22:11:46 2001 +++ main/main.c Sun Oct 28 20:21:04 2001 @@ -221,6 +221,7 @@ PHP_INI_ENTRY("max_execution_time", "30", PHP_INI_ALL, OnUpdateTimeout) STD_PHP_INI_ENTRY("open_basedir", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, open_basedir, php_core_globals, core_globals) STD_PHP_INI_ENTRY("safe_mode_exec_dir", "1", PHP_INI_SYSTEM, OnUpdateString, safe_mode_exec_dir, php_core_globals, core_globals) + STD_PHP_INI_ENTRY("safe_mode_include_dir", "1", PHP_INI_SYSTEM, OnUpdateString, safe_mode_include_dir, php_core_globals, core_globals) STD_PHP_INI_ENTRY("upload_max_filesize", "2M", PHP_INI_ALL, OnUpdateInt, upload_max_filesize, php_core_globals, core_globals) STD_PHP_INI_ENTRY("file_uploads", "1", PHP_INI_ALL, OnUpdateBool, file_uploads, php_core_globals, core_globals) STD_PHP_INI_ENTRY("post_max_size", "8M", PHP_INI_SYSTEM, OnUpdateInt, post_max_size, sapi_globals_struct,sapi_globals) diff -ur main.orig/php_globals.h main/php_globals.h --- main.orig/php_globals.h Wed Apr 4 22:46:26 2001 +++ main/php_globals.h Sun Oct 28 20:20:35 2001 @@ -74,6 +74,7 @@ char *output_handler; char *safe_mode_exec_dir; + char *safe_mode_include_dir; long memory_limit; diff -ur main.orig/safe_mode.c main/safe_mode.c --- main.orig/safe_mode.c Mon Apr 30 14:43:40 2001 +++ main/safe_mode.c Sun Oct 28 20:23:27 2001 @@ -69,6 +69,16 @@ return 1; } + /* + * Added by Tomek.Lipski@ecl.pl - check if the file is in special + * directory where all system includes go [like autoprepend directives] + */ + + if ( !strncasecmp(filename, PG(safe_mode_include_dir), + strlen( PG(safe_mode_include_dir) )) ) { + return 1; + } + if (mode != CHECKUID_ALLOW_ONLY_DIR) { ret = VCWD_STAT(filename, &sb); if (ret < 0) {
diff -ur main.orig/main.c main/main.c --- main.orig/main.c Tue May 8 22:11:46 2001 +++ main/main.c Sun Oct 28 20:21:04 2001 @@ -221,6 +221,7 @@ PHP_INI_ENTRY("max_execution_time", "30", PHP_INI_ALL, OnUpdateTimeout) STD_PHP_INI_ENTRY("open_basedir", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, open_basedir, php_core_globals, core_globals) STD_PHP_INI_ENTRY("safe_mode_exec_dir", "1", PHP_INI_SYSTEM, OnUpdateString, safe_mode_exec_dir, php_core_globals, core_globals) + STD_PHP_INI_ENTRY("safe_mode_include_dir", "1", PHP_INI_SYSTEM, OnUpdateString, safe_mode_include_dir, php_core_globals, core_globals) STD_PHP_INI_ENTRY("upload_max_filesize", "2M", PHP_INI_ALL, OnUpdateInt, upload_max_filesize, php_core_globals, core_globals) STD_PHP_INI_ENTRY("file_uploads", "1", PHP_INI_ALL, OnUpdateBool, file_uploads, php_core_globals, core_globals) STD_PHP_INI_ENTRY("post_max_size", "8M", PHP_INI_SYSTEM, OnUpdateInt, post_max_size, sapi_globals_struct,sapi_globals) diff -ur main.orig/php_globals.h main/php_globals.h --- main.orig/php_globals.h Wed Apr 4 22:46:26 2001 +++ main/php_globals.h Sun Oct 28 20:20:35 2001 @@ -74,6 +74,7 @@ char *output_handler; char *safe_mode_exec_dir; + char *safe_mode_include_dir; long memory_limit; diff -ur main.orig/safe_mode.c main/safe_mode.c --- main.orig/safe_mode.c Mon Apr 30 14:43:40 2001 +++ main/safe_mode.c Sun Oct 28 20:23:27 2001 @@ -69,6 +69,16 @@ return 1; } + /* + * Added by Tomek.Lipski@ecl.pl - check if the file is in special + * directory where all system includes go [like autoprepend directives] + */ + + if ( !strncasecmp(filename, PG(safe_mode_include_dir), + strlen( PG(safe_mode_include_dir) )) ) { + return 1; + } + if (mode != CHECKUID_ALLOW_ONLY_DIR) { ret = VCWD_STAT(filename, &sb); if (ret < 0) {