[PHP4BETA] cvs: /php4/ext/standard basic_functions.c basic_functions.h From: Zeev Suraski (zeev <email protected>)
Date: 01/30/00

zeev Sun Jan 30 21:49:46 2000 EDT

  Modified files:
    /php4/ext/standard basic_functions.c basic_functions.h
  Log:
  Some more work, I'll finish this when I get home
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.150 php4/ext/standard/basic_functions.c:1.151
--- php4/ext/standard/basic_functions.c:1.150 Sun Jan 30 21:31:41 2000
+++ php4/ext/standard/basic_functions.c Sun Jan 30 21:49:16 2000
@@ -309,6 +309,17 @@
 
 static PHP_INI_MH(OnUpdateSafeModeProtectedEnvVars)
 {
+ char *protected_vars, *protected_var;
+ int dummy=1;
+ BLS_FETCH();
+
+ protected_vars = estrndup(new_value, new_value_length);
+ zend_hash_clean(&BG(protected_env_vars));
+
+ while (protected_var=strtok(protected_vars, ",")) {
+ zend_hash_update(&BG(protected_env_vars), protected_var, strlen(protected_var), &dummy, sizeof(int), NULL);
+ }
+ efree(protected_vars);
         return SUCCESS;
 }
 
@@ -364,13 +375,20 @@
 {
         BG(next) = NULL;
         BG(left) = -1;
+ zend_hash_init(&BG(protected_env_vars), 5, NULL, NULL, 1);
 }
 
+static void basic_globals_dtor(BLS_D)
+{
+ zend_hash_destroy(&BG(protected_env_vars));
+}
+
+
 PHP_MINIT_FUNCTION(basic)
 {
         ELS_FETCH();
 #ifdef ZTS
- basic_globals_id = ts_allocate_id(sizeof(php_basic_globals), (ts_allocate_ctor) basic_globals_ctor, NULL);
+ basic_globals_id = ts_allocate_id(sizeof(php_basic_globals), (ts_allocate_ctor) basic_globals_ctor, basic_globals_dtor);
 #else
         basic_globals_ctor(BLS_C);
 #endif
@@ -388,10 +406,14 @@
 
 PHP_MSHUTDOWN_FUNCTION(basic)
 {
+ BLS_FETCH();
+
+ basic_globals_dtor(BLS_C);
+
 #ifdef ZTS
         ts_free_id(basic_globals_id);
 #endif
-
+
         UNREGISTER_INI_ENTRIES();
         return SUCCESS;
 }
@@ -509,7 +531,12 @@
                 int ret;
                 char *p,**env;
                 putenv_entry pe;
+ PLS_FETCH();
                 
+ if (PG(safe_mode)) {
+ /* check the protected_env_vars table */
+ }
+
                 pe.putenv_string = estrndup((*str)->value.str.val,(*str)->value.str.len);
                 pe.key = (*str)->value.str.val;
                 if ((p=strchr(pe.key,'='))) { /* nullify the '=' if there is one */
Index: php4/ext/standard/basic_functions.h
diff -u php4/ext/standard/basic_functions.h:1.40 php4/ext/standard/basic_functions.h:1.41
--- php4/ext/standard/basic_functions.h:1.40 Sun Jan 30 21:31:41 2000
+++ php4/ext/standard/basic_functions.h Sun Jan 30 21:49:16 2000
@@ -29,7 +29,7 @@
  */
 
 
-/* $Id: basic_functions.h,v 1.40 2000/01/30 20:31:41 zeev Exp $ */
+/* $Id: basic_functions.h,v 1.41 2000/01/30 20:49:16 zeev Exp $ */
 
 #ifndef _BASIC_FUNCTIONS_H
 #define _BASIC_FUNCTIONS_H
@@ -183,8 +183,6 @@
 #endif
 
 /* Values are coma-delimited
- * All variables, beginning with the following prefixes, will be protected
- * from change by the PHP runtime function putenv()
  */
 #define SAFE_MODE_PROTECTED_ENV_VARS "LD_"
 

-- 
PHP 4.0 Beta Mailing List <http://www.php.net/version4/>
To unsubscribe, e-mail: php4beta-unsubscribe <email protected>
For additional commands, e-mail: php4beta-help <email protected>
To contact the list administrators, e-mail: php4beta-admin <email protected>