diff options
| author | Jérôme Loyet <fat@php.net> | 2010-04-23 16:05:52 +0000 |
|---|---|---|
| committer | Jérôme Loyet <fat@php.net> | 2010-04-23 16:05:52 +0000 |
| commit | 34ba9e39fafa3a980a1b69285f68b0e12ad6b876 (patch) | |
| tree | 679ad7e5c44a48a657ae93fb06b81636e5659377 | |
| parent | acf5fba0fb7574456196f04f1e0df66db1f6b81e (diff) | |
| download | php-git-34ba9e39fafa3a980a1b69285f68b0e12ad6b876.tar.gz | |
Add PHP_VALUE and PHP_ADMIN_VALUE interpretation from fastcgi headers.
It works as php_value and php_admin_value from the main conf file or apache sapi.
See bug (request) #51595
| -rw-r--r-- | sapi/fpm/fpm/fpm_main.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c index c150146ea1..512d50abc8 100644 --- a/sapi/fpm/fpm/fpm_main.c +++ b/sapi/fpm/fpm/fpm_main.c @@ -27,6 +27,10 @@ #include "php_globals.h" #include "php_variables.h" #include "zend_modules.h" +#include "php.h" +#include "zend_ini_scanner.h" +#include "zend_globals.h" +#include "zend_stream.h" #include "SAPI.h" @@ -103,6 +107,8 @@ int __riscosify_control = __RISCOSIFY_STRICT_UNIX_SPECS; #include <fpm/fpm.h> #include <fpm/fpm_request.h> #include <fpm/fpm_status.h> +#include <fpm/fpm_conf.h> +#include <fpm/fpm_php.h> #ifndef PHP_WIN32 /* XXX this will need to change later when threaded fastcgi is implemented. shane */ @@ -123,6 +129,7 @@ static int parent = 1; static int request_body_fd; static char *sapi_cgibin_getenv(char *name, size_t name_len TSRMLS_DC); +static void fastcgi_ini_parser(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg TSRMLS_DC); #define PHP_MODE_STANDARD 1 #define PHP_MODE_HIGHLIGHT 2 @@ -1070,6 +1077,7 @@ static void init_request_info(TSRMLS_D) char *env_script_filename = sapi_cgibin_getenv("SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME")-1 TSRMLS_CC); char *env_path_translated = sapi_cgibin_getenv("PATH_TRANSLATED", sizeof("PATH_TRANSLATED")-1 TSRMLS_CC); char *script_path_translated = env_script_filename; + char *ini; /* some broken servers do not have script_filename or argv0 * an example, IIS configured in some ways. then they do more @@ -1354,6 +1362,58 @@ static void init_request_info(TSRMLS_D) auth = sapi_cgibin_getenv("HTTP_AUTHORIZATION", sizeof("HTTP_AUTHORIZATION")-1 TSRMLS_CC); php_handle_auth_data(auth TSRMLS_CC); } + + /* INI stuff */ + ini = sapi_cgibin_getenv("PHP_VALUE", sizeof("PHP_VALUE")-1 TSRMLS_CC); + if (ini) { + int mode = ZEND_INI_USER; + char *tmp; + spprintf(&tmp, 0, "%s\n", ini); + zend_parse_ini_string(tmp, 1, ZEND_INI_SCANNER_RAW, (zend_ini_parser_cb_t)fastcgi_ini_parser, &mode TSRMLS_CC); + efree(tmp); + } + + ini = sapi_cgibin_getenv("PHP_ADMIN_VALUE", sizeof("PHP_ADMIN_VALUE")-1 TSRMLS_CC); + if (ini) { + int mode = ZEND_INI_SYSTEM; + char *tmp; + spprintf(&tmp, 0, "%s\n", ini); + zend_parse_ini_string(tmp, 1, ZEND_INI_SCANNER_RAW, (zend_ini_parser_cb_t)fastcgi_ini_parser, &mode TSRMLS_CC); + efree(tmp); + } +} +/* }}} */ + +static void fastcgi_ini_parser(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg TSRMLS_DC) /* {{{ */ +{ + int *mode = (int *)arg; + char *key = Z_STRVAL_P(arg1); + char *value = Z_STRVAL_P(arg2); + struct key_value_s kv; + + if (!mode) return; + + if (callback_type != ZEND_INI_PARSER_ENTRY) { + fprintf(stderr, "Passing INI directive through FastCGI: only classic entries are allowed\n"); + return; + } + + if (!key || strlen(key) < 1) { + fprintf(stderr, "Passing INI directive through FastCGI: empty key\n"); + return; + } + + if (!value || strlen(value) < 1) { + fprintf(stderr, "Passing INI directive through FastCGI: empty value for key '%s'\n", key); + return; + } + + kv.key = key; + kv.value = value; + kv.next = NULL; + if (fpm_php_apply_defines_ex(&kv, *mode) == -1) { + fprintf(stderr, "Passing INI directive through FastCGI: unable to set '%s'\n", key); + } } /* }}} */ |
