]> granicus.if.org Git - php/commitdiff
Some more work, I'll finish this when I get home
authorZeev Suraski <zeev@php.net>
Sun, 30 Jan 2000 20:49:16 +0000 (20:49 +0000)
committerZeev Suraski <zeev@php.net>
Sun, 30 Jan 2000 20:49:16 +0000 (20:49 +0000)
ext/standard/basic_functions.c
ext/standard/basic_functions.h

index e095902acb1096436c83e464cf659c26c25fb1a6..308022f0e727f1c30629aee1faf0a2da044fbed7 100644 (file)
@@ -309,6 +309,17 @@ function_entry basic_functions[] = {
 
 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 @@ static void basic_globals_ctor(BLS_D)
 {
        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_MINIT_FUNCTION(basic)
 
 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 @@ PHP_FUNCTION(putenv)
                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 4f1d5a178dc2ace75f1331a9dff6e987f37ee786..202b32ac6114738ec9666ae93832b690a70ff8bc 100644 (file)
@@ -183,8 +183,6 @@ typedef struct {
 #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_"