mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
Change php_defines in configuration file to php_value,php_admin_value,php_flag,php_admin_flag (as in the apache sapi).
php_admin* sets values as ZEND_INI_SYSTEM mode while php_* sets values as ZEND_INI_USER
This commit is contained in:
parent
6dec27d58b
commit
ca8756478a
@ -239,12 +239,27 @@ static char *xml_conf_set_slot_key_value_pair(void **conf, char *name, void *vv,
|
||||
return "xml_conf_set_slot_key_value_pair(): strdup() failed";
|
||||
}
|
||||
|
||||
kv->next = **parent;
|
||||
**parent = kv;
|
||||
*parent = &kv->next;
|
||||
return NULL;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static char *xml_conf_set_slot_key_value_pair_bool(void **conf, char *name, void *vv, intptr_t offset) /* {{{ */
|
||||
{
|
||||
int value;
|
||||
void *subconf = &value;
|
||||
char *error;
|
||||
|
||||
error = xml_conf_set_slot_boolean(&subconf, name, vv, 0);
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
return(xml_conf_set_slot_key_value_pair(conf, name, value ? "On" : "Off", offset));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static struct xml_conf_section fpm_conf_set_key_value_pairs_subsection_conf = {
|
||||
.path = "key_value_pairs somewhere", /* fixme */
|
||||
.parsers = (struct xml_value_parser []) {
|
||||
@ -253,6 +268,14 @@ static struct xml_conf_section fpm_conf_set_key_value_pairs_subsection_conf = {
|
||||
}
|
||||
};
|
||||
|
||||
static struct xml_conf_section fpm_conf_set_key_value_pairs_subsection_conf_bool = {
|
||||
.path = "key_value_pairs somewhere", /* fixme */
|
||||
.parsers = (struct xml_value_parser []) {
|
||||
{ XML_CONF_SCALAR, 0, &xml_conf_set_slot_key_value_pair_bool, 0 },
|
||||
{ 0, 0, 0, 0 }
|
||||
}
|
||||
};
|
||||
|
||||
static char *fpm_conf_set_key_value_pairs_subsection(void **conf, char *name, void *xml_node, intptr_t offset) /* {{{ */
|
||||
{
|
||||
void *next_kv = (char *) *conf + offset;
|
||||
@ -260,6 +283,13 @@ static char *fpm_conf_set_key_value_pairs_subsection(void **conf, char *name, vo
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static char *fpm_conf_set_key_value_pairs_subsection_bool(void **conf, char *name, void *xml_node, intptr_t offset) /* {{{ */
|
||||
{
|
||||
void *next_kv = (char *) *conf + offset;
|
||||
return xml_conf_parse_section(&next_kv, &fpm_conf_set_key_value_pairs_subsection_conf_bool, xml_node);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void *fpm_worker_pool_config_alloc() /* {{{ */
|
||||
{
|
||||
static struct fpm_worker_pool_s *current_wp = 0;
|
||||
@ -303,7 +333,13 @@ int fpm_worker_pool_config_free(struct fpm_worker_pool_config_s *wpc) /* {{{ */
|
||||
free(wpc->listen_options->mode);
|
||||
free(wpc->listen_options);
|
||||
}
|
||||
for (kv = wpc->php_defines; kv; kv = kv_next) {
|
||||
for (kv = wpc->php_values; kv; kv = kv_next) {
|
||||
kv_next = kv->next;
|
||||
free(kv->key);
|
||||
free(kv->value);
|
||||
free(kv);
|
||||
}
|
||||
for (kv = wpc->php_admin_values; kv; kv = kv_next) {
|
||||
kv_next = kv->next;
|
||||
free(kv->key);
|
||||
free(kv->value);
|
||||
@ -334,7 +370,10 @@ static struct xml_conf_section xml_section_fpm_worker_pool_config = {
|
||||
{ XML_CONF_SCALAR, "name", &xml_conf_set_slot_string, offsetof(struct fpm_worker_pool_config_s, name) },
|
||||
{ XML_CONF_SCALAR, "listen_address", &xml_conf_set_slot_string, offsetof(struct fpm_worker_pool_config_s, listen_address) },
|
||||
{ XML_CONF_SUBSECTION, "listen_options", &fpm_conf_set_listen_options_subsection, offsetof(struct fpm_worker_pool_config_s, listen_options) },
|
||||
{ XML_CONF_SUBSECTION, "php_defines", &fpm_conf_set_key_value_pairs_subsection, offsetof(struct fpm_worker_pool_config_s, php_defines) },
|
||||
{ XML_CONF_SUBSECTION, "php_value", &fpm_conf_set_key_value_pairs_subsection, offsetof(struct fpm_worker_pool_config_s, php_values) },
|
||||
{ XML_CONF_SUBSECTION, "php_flag", &fpm_conf_set_key_value_pairs_subsection_bool, offsetof(struct fpm_worker_pool_config_s, php_values) },
|
||||
{ XML_CONF_SUBSECTION, "php_admin_value", &fpm_conf_set_key_value_pairs_subsection, offsetof(struct fpm_worker_pool_config_s, php_admin_values) },
|
||||
{ XML_CONF_SUBSECTION, "php_admin_flag", &fpm_conf_set_key_value_pairs_subsection_bool, offsetof(struct fpm_worker_pool_config_s, php_admin_values) },
|
||||
{ XML_CONF_SCALAR, "user", &xml_conf_set_slot_string, offsetof(struct fpm_worker_pool_config_s, user) },
|
||||
{ XML_CONF_SCALAR, "group", &xml_conf_set_slot_string, offsetof(struct fpm_worker_pool_config_s, group) },
|
||||
{ XML_CONF_SCALAR, "chroot", &xml_conf_set_slot_string, offsetof(struct fpm_worker_pool_config_s, chroot) },
|
||||
|
@ -50,7 +50,8 @@ struct fpm_worker_pool_config_s {
|
||||
char *name;
|
||||
char *listen_address;
|
||||
struct fpm_listen_options_s *listen_options;
|
||||
struct key_value_s *php_defines;
|
||||
struct key_value_s *php_values;
|
||||
struct key_value_s *php_admin_values;
|
||||
char *user;
|
||||
char *group;
|
||||
char *chroot;
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "fpm_cleanup.h"
|
||||
#include "fpm_worker_pool.h"
|
||||
|
||||
static int zend_ini_alter_master(char *name, int name_length, char *new_value, int new_value_length, int stage TSRMLS_DC) /* {{{ */
|
||||
static int fpm_php_zend_ini_alter_master(char *name, int name_length, char *new_value, int new_value_length, int mode, int stage TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
zend_ini_entry *ini_entry;
|
||||
char *duplicate;
|
||||
@ -32,10 +32,11 @@ static int zend_ini_alter_master(char *name, int name_length, char *new_value, i
|
||||
duplicate = strdup(new_value);
|
||||
|
||||
if (!ini_entry->on_modify
|
||||
|| ini_entry->on_modify(ini_entry, duplicate, new_value_length,
|
||||
ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage TSRMLS_CC) == SUCCESS) {
|
||||
|| ini_entry->on_modify(ini_entry, duplicate, new_value_length,
|
||||
ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage TSRMLS_CC) == SUCCESS) {
|
||||
ini_entry->value = duplicate;
|
||||
ini_entry->value_length = new_value_length;
|
||||
ini_entry->modifiable = mode;
|
||||
} else {
|
||||
free(duplicate);
|
||||
}
|
||||
@ -73,55 +74,62 @@ static void fpm_php_disable(char *value, int (*zend_disable)(char *, uint TSRMLS
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
int fpm_php_apply_defines_ex(struct key_value_s *kv, int mode) /* {{{ */
|
||||
{
|
||||
TSRMLS_FETCH();
|
||||
|
||||
char *name = kv->key;
|
||||
char *value = kv->value;
|
||||
int name_len = strlen(name);
|
||||
int value_len = strlen(value);
|
||||
|
||||
if (!strcmp(name, "extension") && *value) {
|
||||
zval zv;
|
||||
php_dl(value, MODULE_PERSISTENT, &zv, 1 TSRMLS_CC);
|
||||
return Z_BVAL(zv) ? 1 : -1;
|
||||
}
|
||||
|
||||
if (fpm_php_zend_ini_alter_master(name, name_len+1, value, value_len, mode, PHP_INI_STAGE_ACTIVATE TSRMLS_CC) == FAILURE) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!strcmp(name, "disable_functions") && *value) {
|
||||
char *v = strdup(value);
|
||||
PG(disable_functions) = v;
|
||||
fpm_php_disable(v, zend_disable_function TSRMLS_CC);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!strcmp(name, "disable_classes") && *value) {
|
||||
char *v = strdup(value);
|
||||
PG(disable_classes) = v;
|
||||
fpm_php_disable(v, zend_disable_class TSRMLS_CC);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static int fpm_php_apply_defines(struct fpm_worker_pool_s *wp) /* {{{ */
|
||||
{
|
||||
TSRMLS_FETCH();
|
||||
struct key_value_s *kv;
|
||||
|
||||
for (kv = wp->config->php_defines; kv; kv = kv->next) {
|
||||
char *name = kv->key;
|
||||
char *value = kv->value;
|
||||
int name_len = strlen(name);
|
||||
int value_len = strlen(value);
|
||||
|
||||
if (!strcmp(name, "extension") && *value) {
|
||||
zval zv;
|
||||
|
||||
#if defined(PHP_VERSION_ID) && (PHP_VERSION_ID >= 50300)
|
||||
php_dl(value, MODULE_PERSISTENT, &zv, 1 TSRMLS_CC);
|
||||
#else
|
||||
zval filename;
|
||||
ZVAL_STRINGL(&filename, value, value_len, 0);
|
||||
#if (PHP_MAJOR_VERSION >= 5)
|
||||
php_dl(&filename, MODULE_PERSISTENT, &zv, 1 TSRMLS_CC);
|
||||
#else
|
||||
php_dl(&filename, MODULE_PERSISTENT, &zv TSRMLS_CC);
|
||||
#endif
|
||||
#endif
|
||||
continue;
|
||||
for (kv = wp->config->php_values; kv; kv = kv->next) {
|
||||
if (fpm_php_apply_defines_ex(kv, ZEND_INI_USER) == -1) {
|
||||
fprintf(stderr, "Unable to set php_value '%s'", kv->key);
|
||||
}
|
||||
}
|
||||
|
||||
zend_ini_alter_master(name, name_len + 1, value, value_len, PHP_INI_STAGE_ACTIVATE TSRMLS_CC);
|
||||
|
||||
if (!strcmp(name, "disable_functions") && *value) {
|
||||
char *v = strdup(value);
|
||||
#if (PHP_MAJOR_VERSION >= 5)
|
||||
PG(disable_functions) = v;
|
||||
#endif
|
||||
fpm_php_disable(v, zend_disable_function TSRMLS_CC);
|
||||
}
|
||||
else if (!strcmp(name, "disable_classes") && *value) {
|
||||
char *v = strdup(value);
|
||||
#if (PHP_MAJOR_VERSION >= 5)
|
||||
PG(disable_classes) = v;
|
||||
#endif
|
||||
fpm_php_disable(v, zend_disable_class TSRMLS_CC);
|
||||
for (kv = wp->config->php_admin_values; kv; kv = kv->next) {
|
||||
if (fpm_php_apply_defines_ex(kv, ZEND_INI_SYSTEM) == -1) {
|
||||
fprintf(stderr, "Unable to set php_admin_value '%s'", kv->key);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static int fpm_php_set_allowed_clients(struct fpm_worker_pool_s *wp) /* {{{ */
|
||||
{
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "php.h"
|
||||
#include "build-defs.h" /* for PHP_ defines */
|
||||
#include "fpm/fpm_conf.h"
|
||||
|
||||
struct fpm_worker_pool_s;
|
||||
|
||||
@ -18,6 +19,7 @@ char *fpm_php_request_method(TSRMLS_D);
|
||||
size_t fpm_php_content_length(TSRMLS_D);
|
||||
void fpm_php_soft_quit();
|
||||
int fpm_php_init_main();
|
||||
int fpm_php_apply_defines_ex(struct key_value_s *kv, int mode);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -55,11 +55,21 @@
|
||||
|
||||
Additional php.ini defines, specific to this pool of workers.
|
||||
These settings overwrite the values previously defined in the php.ini.
|
||||
<value name="php_defines">
|
||||
<!-- <value name="sendmail_path">/usr/sbin/sendmail -t -i</value> -->
|
||||
<!-- <value name="display_errors">0</value> -->
|
||||
Like apache, you can use php_value, php_flag, php_admin_value or php_admin_flag.
|
||||
Defining 'extension' will search for the corresponding shared extension in extension_dir.
|
||||
Defining 'disable_functions' or 'disable_classes' won't overwrite previously defined
|
||||
php.ini value, but the new value will be append.
|
||||
<value name="php_value">
|
||||
<!-- <value name="error_log">/var/log/php-error.log</value> -->
|
||||
<!-- <value name="log_errors">true</value> -->
|
||||
</value>
|
||||
<value name="php_flag">
|
||||
<!-- <value name="log_errors">true</value> -->
|
||||
</value>
|
||||
<value name="php_admin_value">
|
||||
<!-- <value name="sendmail_path">/usr/sbin/sendmail -t -i</value> -->
|
||||
</value>
|
||||
<value name="php_admin_flag">
|
||||
<!-- <value name="display_errors">0</value> -->
|
||||
</value>
|
||||
|
||||
Unix user of processes
|
||||
|
Loading…
Reference in New Issue
Block a user