2012-03-12 9 views
3

私はmod_vhost_aliasを使用しており、各ユーザに動的にopen_basedirを設定したいと思っています。mod_vhost_aliasを使った動的open_basedir

php_admin_valueのopen_basedirのは/ var/www /のバーチャルホスト/%のようなものは、1

しかし、それは動作しません。私は多くの仮想ホスト(4000-5000)を持っているので、mod_macroは私に合っていません。

私はこのパッチ http://wiki.preshweb.co.uk/doku.php?id=apache:securemassvhosting

を適用しようとしているが、成功しませんよ。助言がありますか?

答えて

0

誰か興味があるかもしれません。私は正常にそれはPHP-5.3.10でテストしたパッチ(http://www.phpbuilder.com/lists/php-developer-list/2000101/0994.php

*** main/fopen_wrappers.c  2010-04-22 01:22:31.000000000 +0300 
--- main/fopen_wrappers.c  2012-03-14 17:22:49.130299133 +0200 
*************** 
*** 145,156 **** 
--- 145,168 ---- 
     char resolved_name[MAXPATHLEN]; 
     char resolved_basedir[MAXPATHLEN]; 
     char local_open_basedir[MAXPATHLEN]; 
+  char *local_open_basedir_sub; /* Substring pointer for strstr */ 
     char path_tmp[MAXPATHLEN]; 
     char *path_file; 
     int resolved_basedir_len; 
     int resolved_name_len; 
     int path_len; 
     int nesting_level = 0; 
+ 
+  /* Special case for VIRTUAL_DOCUMENT_ROOT in the open_basedir value, which gets changed to the document root */ 
+  if ((strncmp(basedir, "VIRTUAL_DOCUMENT_ROOT", strlen("VIRTUAL_DOCUMENT_ROOT")) == 0) && SG(request_info).path_translated && *SG(request_info).path_translated) 
+  { 
+   strlcpy(local_open_basedir, SG(request_info).path_translated, sizeof(local_open_basedir)); 
+ 
+   local_open_basedir_sub=strstr(local_open_basedir,SG(request_info).request_uri); 
+   /* Now insert null to break apart the string */ 
+   if (local_open_basedir_sub) *local_open_basedir_sub = '\0'; 
+ 
+  } else 

     /* Special case basedir==".": Use script-directory */ 
     if (strcmp(basedir, ".") || !VCWD_GETCWD(local_open_basedir, MAXPATHLEN)) { 

を変更しているし、それは素晴らしい仕事です。

2

php.iniでauto_prependオプションを使用すると、最初に実行されるスクリプトを提供できます。 open_basedirは$ _SERVER配列の内容に基づいてini_set()関数で設定できます。

+0

このようなことができます: 'ini_set( 'open_basedir'、"/var/www/hosts/$ hostname /:/ tmp/");' – Sunry

関連する問題