php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch PHPINIScanDir.patch for PHP options/info functions Bug #47871

Patch version 2014-06-05 17:41 UTC

Return to Bug #47871 | Download this patch
Patch Revisions:

Developer: tyrael@php.net

--- php5.3-200904020030/main/php_ini.c.orig	2008-12-31 03:37:29.000000000 -0800
+++ php5.3-200904020030/main/php_ini.c	2009-04-01 19:01:48.077153559 -0700
@@ -617,8 +617,13 @@
 	/* Check for PHP_INI_SCAN_DIR environment variable to override/set config file scan directory */
 	php_ini_scanned_path = getenv("PHP_INI_SCAN_DIR");
 	if (!php_ini_scanned_path) {
-		/* Or fall back using possible --with-config-file-scan-dir setting (defaults to empty string!) */
+		/* Check if this is overridden within SAPI configuration
+		* Or fall back using possible --with-config-file-scan-dir setting (defaults to empty string!) */
+		if (sapi_module.php_ini_scanpath_override)
+			php_ini_scanned_path = sapi_module.php_ini_scanpath_override;
+		else
 		php_ini_scanned_path = PHP_CONFIG_FILE_SCAN_DIR;
+
 	}
 	php_ini_scanned_path_len = strlen(php_ini_scanned_path);
 
--- php5.3-200904020030/main/SAPI.h.orig	2008-12-31 09:36:17.000000000 -0800
+++ php5.3-200904020030/main/SAPI.h	2009-04-01 19:01:48.084763152 -0700
@@ -242,6 +242,7 @@
 	void (*terminate_process)(TSRMLS_D);
 
 	char *php_ini_path_override;
+	char *php_ini_scanpath_override;
 
 	void (*block_interruptions)(void);
 	void (*unblock_interruptions)(void);
--- php5.3-200904020030/sapi/apache/mod_php5.c.orig	2008-12-31 03:37:31.000000000 -0800
+++ php5.3-200904020030/sapi/apache/mod_php5.c	2009-04-01 19:01:48.095063497 -0700
@@ -891,6 +891,18 @@
 }
 /* }}} */
 
+/* {{{ php_apache_phpini_scandir_set
+ */
+static CONST_PREFIX char *php_apache_phpini_scandir_set(cmd_parms *cmd, HashTable *conf, char *arg)
+{
+	if (apache_sapi_module.php_ini_scanpath_override) {
+		return "Only first PHPINIScanDir directive honored per configuration tree - subsequent ones ignored";
+	}
+	apache_sapi_module.php_ini_scanpath_override = ap_server_root_relative(cmd->pool, arg);
+	return NULL;
+}
+/* }}} */
+
 /* {{{ int php_xbithack_handler(request_rec * r)
  */
 static int php_xbithack_handler(request_rec * r)
@@ -994,6 +1006,7 @@
 	{"php_admin_value",	php_apache_admin_value_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Value Modifier (Admin)"},
 	{"php_admin_flag",	php_apache_admin_flag_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Flag Modifier (Admin)"},
 	{"PHPINIDir",		php_apache_phpini_set, NULL, RSRC_CONF, TAKE1, "Directory containing the php.ini file"},
+	{"PHPINIScanDir",		php_apache_phpini_scandir_set, NULL, RSRC_CONF, TAKE1, "Directory to scan for any PHP extension specific INI files"},
 	{NULL}
 };
 /* }}} */
--- php5.3-200904020030/sapi/apache_hooks/mod_php5.c.orig	2008-12-31 03:37:32.000000000 -0800
+++ php5.3-200904020030/sapi/apache_hooks/mod_php5.c	2009-04-01 19:01:48.109303171 -0700
@@ -1178,6 +1178,18 @@
 }
 /* }}} */
 
+/* {{{ php_apache_phpini_scandir_set
+ */
+static CONST_PREFIX char *php_apache_phpini_scandir_set(cmd_parms *cmd, HashTable *conf, char *arg)
+{
+	if (apache_sapi_module.php_ini_scanpath_override) {
+		return "Only first PHPINIScanDir directive honored per configuration tree - subsequent ones ignored";
+	}
+	apache_sapi_module.php_ini_scanpath_override = ap_server_root_relative(cmd->pool, arg);
+	return NULL;
+}
+/* }}} */
+
 /* {{{ int php_xbithack_handler(request_rec * r)
  */
 static int php_xbithack_handler(request_rec * r)
@@ -1450,6 +1462,7 @@
 	{"php_admin_value",	php_apache_admin_value_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Value Modifier (Admin)"},
 	{"php_admin_flag",	php_apache_admin_flag_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Flag Modifier (Admin)"},
 	{"PHPINIDir",       php_apache_phpini_set, NULL, RSRC_CONF, TAKE1, "Directory containing the php.ini file"},
+	{"PHPINIScanDir",	php_apache_phpini_scandir_set, NULL, RSRC_CONF, TAKE1, "Directory to scan for any PHP extension specific INI files"},
 	{NULL}
 };
 /* }}} */
--- php5.3-200904020030/sapi/apache2filter/apache_config.c.orig	2008-12-31 03:37:31.000000000 -0800
+++ php5.3-200904020030/sapi/apache2filter/apache_config.c	2009-04-01 19:01:48.095721946 -0700
@@ -117,6 +117,14 @@
 	return NULL;
 }
 
+static const char *php_apache_phpini_scandir_set(cmd_parms *cmd, void *mconfig, const char *arg)
+{
+	if (apache2_php_ini_scanpath_override) {
+		return "Only first PHPINIScanDir directive honored per configuration tree - subsequent ones ignored";
+	}
+	apache2_php_ini_scanpath_override = ap_server_root_relative(cmd->pool, arg);
+	return NULL;
+}
 
 void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf)
 {
@@ -185,6 +193,7 @@
 	AP_INIT_TAKE2("php_admin_value", php_apache_admin_value_handler, NULL, ACCESS_CONF|RSRC_CONF, "PHP Value Modifier (Admin)"),
 	AP_INIT_TAKE2("php_admin_flag", php_apache_admin_flag_handler, NULL, ACCESS_CONF|RSRC_CONF, "PHP Flag Modifier (Admin)"),
 	AP_INIT_TAKE1("PHPINIDir", php_apache_phpini_set, NULL, RSRC_CONF, "Directory containing the php.ini file"),
+	AP_INIT_TAKE1("PHPINIScanDir", php_apache_phpini_scandir_set, NULL, RSRC_CONF, "Directory to scan for any PHP extension specific INI files"),
 	{NULL}
 };
 
--- php5.3-200904020030/sapi/apache2filter/sapi_apache2.c.orig	2008-12-31 03:37:31.000000000 -0800
+++ php5.3-200904020030/sapi/apache2filter/sapi_apache2.c	2009-04-01 19:01:48.096743920 -0700
@@ -63,6 +63,10 @@
 /* A way to specify the location of the php.ini dir in an apache directive */
 char *apache2_php_ini_path_override = NULL;
 
+/* A way to specify the location of directory to search for loading extension
+ * specific INI file within an apache directive */
+char *apache2_php_ini_scanpath_override = NULL;
+
 static int
 php_apache_sapi_ub_write(const char *str, uint str_length TSRMLS_DC)
 {
@@ -599,6 +603,7 @@
     /* When this is NULL, apache won't override the hard-coded default
      * php.ini path setting. */
     apache2_php_ini_path_override = NULL;
+    apache2_php_ini_scanpath_override = NULL;
     return OK;
 }
 
@@ -627,6 +632,9 @@
 	if (apache2_php_ini_path_override) {
 		apache2_sapi_module.php_ini_path_override = apache2_php_ini_path_override;
 	}
+	if (apache2_php_ini_scanpath_override) {
+		apache2_sapi_module.php_ini_scanpath_override = apache2_php_ini_scanpath_override;
+	}
 #ifdef ZTS
 	tsrm_startup(1, 1, 0, NULL);
 #endif
--- php5.3-200904020030/sapi/apache2filter/php_apache.h.orig	2008-12-31 03:37:31.000000000 -0800
+++ php5.3-200904020030/sapi/apache2filter/php_apache.h	2009-04-01 19:01:48.096104201 -0700
@@ -31,6 +31,10 @@
 /* A way to specify the location of the php.ini dir in an apache directive */
 extern char *apache2_php_ini_path_override;
 
+/* A way to specify the location of directory to search for loading extension
+ * specific INI file within an apache directive */
+extern char *apache2_php_ini_scanpath_override;
+
 /* The server_context used by PHP */
 typedef struct php_struct {
 	int state;
--- php5.3-200904020030/sapi/apache2handler/apache_config.c.orig	2008-12-31 07:36:52.000000000 -0800
+++ php5.3-200904020030/sapi/apache2handler/apache_config.c	2009-04-01 19:01:48.108174068 -0700
@@ -117,6 +117,15 @@
 	return NULL;
 }
 
+static const char *php_apache_phpini_scandir_set(cmd_parms *cmd, void *mconfig, const char *arg)
+{
+	if (apache2_php_ini_scanpath_override) {
+		return "Only first PHPINIScanDir directive honored per configuration tree - subsequent ones ignored";
+	}
+	apache2_php_ini_scanpath_override = ap_server_root_relative(cmd->pool, arg);
+	return NULL;
+}
+
 static zend_bool should_overwrite_per_dir_entry(HashTable *target_ht, php_dir_entry *new_per_dir_entry, zend_hash_key *hash_key, void *pData)
 {
 	php_dir_entry *orig_per_dir_entry;
@@ -207,6 +216,7 @@
 	AP_INIT_TAKE2("php_admin_value", php_apache_admin_value_handler, NULL, ACCESS_CONF|RSRC_CONF, "PHP Value Modifier (Admin)"),
 	AP_INIT_TAKE2("php_admin_flag", php_apache_admin_flag_handler, NULL, ACCESS_CONF|RSRC_CONF, "PHP Flag Modifier (Admin)"),
 	AP_INIT_TAKE1("PHPINIDir", php_apache_phpini_set, NULL, RSRC_CONF, "Directory containing the php.ini file"),
+	AP_INIT_TAKE1("PHPINIScanDir", php_apache_phpini_scandir_set, NULL, RSRC_CONF, "Directory to scan for any PHP extension specific INI files"),
 	{NULL}
 };
 
--- php5.3-200904020030/sapi/apache2handler/sapi_apache2.c.orig	2008-12-31 03:37:32.000000000 -0800
+++ php5.3-200904020030/sapi/apache2handler/sapi_apache2.c	2009-04-01 19:01:48.103148232 -0700
@@ -66,6 +66,10 @@
 /* A way to specify the location of the php.ini dir in an apache directive */
 char *apache2_php_ini_path_override = NULL;
 
+/* A way to specify the location of directory to search for loading extension
+ * specific INI file within an apache directive */
+char *apache2_php_ini_scanpath_override = NULL;
+
 static int
 php_apache_sapi_ub_write(const char *str, uint str_length TSRMLS_DC)
 {
@@ -404,6 +408,7 @@
 	/* When this is NULL, apache won't override the hard-coded default
 	 * php.ini path setting. */
 	apache2_php_ini_path_override = NULL;
+	apache2_php_ini_scanpath_override = NULL;
 	return OK;
 }
 
@@ -430,6 +435,9 @@
 	if (apache2_php_ini_path_override) {
 		apache2_sapi_module.php_ini_path_override = apache2_php_ini_path_override;
 	}
+	if (apache2_php_ini_scanpath_override) {
+		apache2_sapi_module.php_ini_scanpath_override = apache2_php_ini_scanpath_override;
+	}
 #ifdef ZTS
 	tsrm_startup(1, 1, 0, NULL);
 #endif
--- php5.3-200904020030/sapi/apache2handler/php_apache.h.orig	2008-12-31 03:37:31.000000000 -0800
+++ php5.3-200904020030/sapi/apache2handler/php_apache.h	2009-04-01 19:01:48.102301691 -0700
@@ -31,6 +31,10 @@
 /* A way to specify the location of the php.ini dir in an apache directive */
 extern char *apache2_php_ini_path_override;
 
+/* A way to specify the location of directory to search for loading extension
+ * specific INI file within an apache directive */
+extern char *apache2_php_ini_scanpath_override;
+
 /* The server_context used by PHP */
 typedef struct php_struct {
 	int state;
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 24 05:01:32 2024 UTC