jani Wed Aug 13 00:49:59 2008 UTC
Modified files:
/php-src Makefile.global
/php-src/ext/standard info.c
/php-src/main php_ini.c
/php-src/sapi/cgi cgi_main.c
/php-src/sapi/cli php_cli.c
/php-src/sapi/milter php_milter.c
Log:
[DOC]- Added methods to change/disable --with-config-file-scan-dir=PATH at
[DOC] startup:
[DOC]
[DOC] To disable: Override default php.ini by using both -c and -n with
[DOC] CGI/CLI or set "PHP_INI_SCAN_DIR" environment variable
[DOC] to an empty string.
[DOC]
[DOC] To change: Simply set "PHP_INI_SCAN_DIR" environment variable to point
[DOC] to another path.
- Fixed bug #42604 ("make test" fails with
--with-config-file-scan-dir=/some/path)
- Implemented FR #45114 (Option to change --with-config-file-scan-dir)
http://cvs.php.net/viewvc.cgi/php-src/Makefile.global?r1=1.87&r2=1.88&diff_format=u
Index: php-src/Makefile.global
diff -u php-src/Makefile.global:1.87 php-src/Makefile.global:1.88
--- php-src/Makefile.global:1.87 Mon Jun 9 19:27:43 2008
+++ php-src/Makefile.global Wed Aug 13 00:49:58 2008
@@ -87,16 +87,21 @@
CC="$(CC)" \
$(PHP_EXECUTABLE) $(PHP_TEST_SETTINGS)
$(top_srcdir)/run-tests.php -d extension_dir=modules/
$(PHP_TEST_SHARED_EXTENSIONS) tests/; \
elif test ! -z "$(SAPI_CLI_PATH)" && test -x "$(SAPI_CLI_PATH)"; then \
- INI_FILE=`$(top_builddir)/$(SAPI_CLI_PATH) -r 'echo
php_ini_loaded_file();'`; \
+ INI_FILE=`$(top_builddir)/$(SAPI_CLI_PATH) -d
'display_errors=stderr' -r 'echo php_ini_loaded_file();' 2> /dev/null`; \
if test "$$INI_FILE"; then \
$(EGREP) -v '^(zend_)?extension(_debug)?(_ts)?[\t\ ]*='
"$$INI_FILE" > $(top_builddir)/tmp-php.ini; \
else \
echo > $(top_builddir)/tmp-php.ini; \
fi; \
+ INI_SCANNED_PATH=`$(top_builddir)/$(SAPI_CLI_PATH) -d
'display_errors=stderr' -r '$$a = explode(",\n",
trim(php_ini_scanned_files())); echo $$a[0];' 2> /dev/null`; \
+ if test "$$INI_SCANNED_PATH"; then \
+ INI_SCANNED_PATH=`$(top_srcdir)/build/shtool path -d
$$INI_SCANNED_PATH`; \
+ $(EGREP) -h -v '^(zend_)?extension(_debug)?(_ts)?[\t\
]*=' "$$INI_SCANNED_PATH"/*.ini >> $(top_builddir)/tmp-php.ini; \
+ fi; \
TEST_PHP_EXECUTABLE=$(top_builddir)/$(SAPI_CLI_PATH) \
TEST_PHP_SRCDIR=$(top_srcdir) \
CC="$(CC)" \
- $(top_builddir)/$(SAPI_CLI_PATH) $(PHP_TEST_SETTINGS)
$(top_srcdir)/run-tests.php -c $(top_builddir)/tmp-php.ini -d
extension_dir=$(top_builddir)/modules/ $(PHP_TEST_SHARED_EXTENSIONS) $(TESTS); \
+ $(top_builddir)/$(SAPI_CLI_PATH) -n -c
$(top_builddir)/tmp-php.ini $(PHP_TEST_SETTINGS) $(top_srcdir)/run-tests.php -n
-c $(top_builddir)/tmp-php.ini -d extension_dir=$(top_builddir)/modules/
$(PHP_TEST_SHARED_EXTENSIONS) $(TESTS); \
else \
echo "ERROR: Cannot run tests without CLI sapi."; \
fi
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/info.c?r1=1.291&r2=1.292&diff_format=u
Index: php-src/ext/standard/info.c
diff -u php-src/ext/standard/info.c:1.291 php-src/ext/standard/info.c:1.292
--- php-src/ext/standard/info.c:1.291 Tue Jul 22 10:04:53 2008
+++ php-src/ext/standard/info.c Wed Aug 13 00:49:59 2008
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: info.c,v 1.291 2008/07/22 10:04:53 pajoye Exp $ */
+/* $Id: info.c,v 1.292 2008/08/13 00:49:59 jani Exp $ */
#include "php.h"
#include "php_ini.h"
@@ -59,6 +59,7 @@
} \
PHPAPI extern char *php_ini_opened_path;
+PHPAPI extern char *php_ini_scanned_path;
PHPAPI extern char *php_ini_scanned_files;
static int php_info_print_html_esc(const char *str, int len) /* {{{ */
@@ -567,14 +568,9 @@
php_info_print_table_row(2, "Configuration File (php.ini)
Path", PHP_CONFIG_FILE_PATH);
php_info_print_table_row(2, "Loaded Configuration File",
php_ini_opened_path ? php_ini_opened_path : "(none)");
+ php_info_print_table_row(2, "Scan this dir for additional .ini
files", php_ini_scanned_path ? php_ini_scanned_path : "(none)");
+ php_info_print_table_row(2, "additional .ini files parsed",
php_ini_scanned_files ? php_ini_scanned_files : "(none)");
- if (strlen(PHP_CONFIG_FILE_SCAN_DIR)) {
- php_info_print_table_row(2, "Scan this dir for
additional .ini files", PHP_CONFIG_FILE_SCAN_DIR);
- if (php_ini_scanned_files) {
- php_info_print_table_row(2, "additional .ini
files parsed", php_ini_scanned_files);
- }
- }
-
snprintf(temp_api, sizeof(temp_api), "%d", PHP_API_VERSION);
php_info_print_table_row(2, "PHP API", temp_api);
http://cvs.php.net/viewvc.cgi/php-src/main/php_ini.c?r1=1.167&r2=1.168&diff_format=u
Index: php-src/main/php_ini.c
diff -u php-src/main/php_ini.c:1.167 php-src/main/php_ini.c:1.168
--- php-src/main/php_ini.c:1.167 Tue Aug 12 17:15:59 2008
+++ php-src/main/php_ini.c Wed Aug 13 00:49:59 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_ini.c,v 1.167 2008/08/12 17:15:59 felipe Exp $ */
+/* $Id: php_ini.c,v 1.168 2008/08/13 00:49:59 jani Exp $ */
#include "php.h"
#include "ext/standard/info.h"
@@ -54,6 +54,7 @@
static int has_per_host_config = 0;
PHPAPI char *php_ini_opened_path=NULL;
static php_extension_lists extension_lists;
+PHPAPI char *php_ini_scanned_path=NULL;
PHPAPI char *php_ini_scanned_files=NULL;
/* {{{ php_ini_displayer_cb
@@ -517,9 +518,18 @@
PG(open_basedir) = NULL;
+ /*
+ * Find and open actual ini file
+ */
+
memset(&fh, 0, sizeof(fh));
- /* Check if php_ini_path_override is a file */
- if (!sapi_module.php_ini_ignore) {
+
+ /* If SAPI does not want to ignore all ini files OR an overriding
file/path is given.
+ * This allows disabling scanning for ini files in the
PHP_CONFIG_FILE_SCAN_DIR but still
+ * load an optional ini file. */
+ if (!sapi_module.php_ini_ignore || sapi_module.php_ini_path_override) {
+
+ /* Check if php_ini_file_name is a file and can be opened */
if (php_ini_file_name && php_ini_file_name[0]) {
struct stat statbuf;
@@ -532,7 +542,8 @@
}
}
}
- /* Search php-%sapi-module-name%.ini file in search path */
+
+ /* Otherwise search for php-%sapi-module-name%.ini file in
search path */
if (!fh.handle.fp) {
const char *fmt = "php-%s.ini";
char *ini_fname;
@@ -543,7 +554,8 @@
fh.filename = php_ini_opened_path;
}
}
- /* Search php.ini file in search path */
+
+ /* If still no ini file found, search for php.ini file in
search path */
if (!fh.handle.fp) {
fh.handle.fp = php_fopen_with_path("php.ini", "r",
php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
if (fh.handle.fp) {
@@ -580,9 +592,16 @@
}
}
- /* If the config_file_scan_dir is set at compile-time, go and scan this
directory and
- * parse any .ini files found in this directory. */
- if (!sapi_module.php_ini_ignore && strlen(PHP_CONFIG_FILE_SCAN_DIR)) {
+ /* 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!) */
+ php_ini_scanned_path = PHP_CONFIG_FILE_SCAN_DIR;
+ }
+ int php_ini_scanned_path_len = strlen(php_ini_scanned_path);
+
+ /* Scan and parse any .ini files found in scan path if path not empty.
*/
+ if (!sapi_module.php_ini_ignore && php_ini_scanned_path_len) {
struct dirent **namelist;
int ndir, i;
struct stat sb;
@@ -596,7 +615,7 @@
/* Reset active ini section */
RESET_ACTIVE_INI_HASH();
- if ((ndir = php_scandir(PHP_CONFIG_FILE_SCAN_DIR, &namelist, 0,
php_alphasort)) > 0) {
+ if ((ndir = php_scandir(php_ini_scanned_path, &namelist, 0,
php_alphasort)) > 0) {
zend_llist_init(&scanned_ini_list, sizeof(char *),
(llist_dtor_func_t) free_estring, 1);
memset(&fh, 0, sizeof(fh));
@@ -607,7 +626,11 @@
free(namelist[i]);
continue;
}
- snprintf(ini_file, MAXPATHLEN, "%s%c%s",
PHP_CONFIG_FILE_SCAN_DIR, DEFAULT_SLASH, namelist[i]->d_name);
+ if
(IS_SLASH(php_ini_scanned_path[php_ini_scanned_path_len - 1])) {
+ snprintf(ini_file, MAXPATHLEN, "%s%s",
php_ini_scanned_path, namelist[i]->d_name);
+ } else {
+ snprintf(ini_file, MAXPATHLEN,
"%s%c%s", php_ini_scanned_path, DEFAULT_SLASH, namelist[i]->d_name);
+ }
if (VCWD_STAT(ini_file, &sb) == 0) {
if (S_ISREG(sb.st_mode)) {
if ((fh.handle.fp =
VCWD_FOPEN(ini_file, "r"))) {
@@ -645,6 +668,9 @@
}
zend_llist_destroy(&scanned_ini_list);
}
+ } else {
+ /* Make sure an empty php_ini_scanned_path ends up as NULL */
+ php_ini_scanned_path = NULL;
}
if (sapi_module.ini_entries) {
http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.359&r2=1.360&diff_format=u
Index: php-src/sapi/cgi/cgi_main.c
diff -u php-src/sapi/cgi/cgi_main.c:1.359 php-src/sapi/cgi/cgi_main.c:1.360
--- php-src/sapi/cgi/cgi_main.c:1.359 Mon Aug 4 07:20:44 2008
+++ php-src/sapi/cgi/cgi_main.c Wed Aug 13 00:49:59 2008
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: cgi_main.c,v 1.359 2008/08/04 07:20:44 dmitry Exp $ */
+/* $Id: cgi_main.c,v 1.360 2008/08/13 00:49:59 jani Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -1734,15 +1734,6 @@
CG(interactive) = 0;
if (!cgi && !fastcgi) {
- if (cgi_sapi_module.php_ini_path_override &&
cgi_sapi_module.php_ini_ignore) {
- no_headers = 1;
- SG(headers_sent) = 1;
- php_printf("You cannot use both -n and
-c switch. Use -h for help.\n");
- php_output_end_all(TSRMLS_C);
- exit_status = 1;
- goto out;
- }
-
while ((c = php_getopt(argc, argv, OPTIONS,
&php_optarg, &php_optind, 0, 2)) != -1) {
switch (c) {
http://cvs.php.net/viewvc.cgi/php-src/sapi/cli/php_cli.c?r1=1.193&r2=1.194&diff_format=u
Index: php-src/sapi/cli/php_cli.c
diff -u php-src/sapi/cli/php_cli.c:1.193 php-src/sapi/cli/php_cli.c:1.194
--- php-src/sapi/cli/php_cli.c:1.193 Fri Jul 25 15:05:33 2008
+++ php-src/sapi/cli/php_cli.c Wed Aug 13 00:49:59 2008
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_cli.c,v 1.193 2008/07/25 15:05:33 tony2001 Exp $ */
+/* $Id: php_cli.c,v 1.194 2008/08/13 00:49:59 jani Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -760,12 +760,6 @@
CG(in_compilation) = 0; /* not initialized but needed for
several options */
EG(uninitialized_zval_ptr) = NULL;
- if (cli_sapi_module.php_ini_path_override &&
cli_sapi_module.php_ini_ignore) {
- PUTS("You cannot use both -n and -c switch. Use -h for
help.\n");
- exit_status=1;
- goto err;
- }
-
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg,
&php_optind, 0, 2)) != -1) {
switch (c) {
http://cvs.php.net/viewvc.cgi/php-src/sapi/milter/php_milter.c?r1=1.25&r2=1.26&diff_format=u
Index: php-src/sapi/milter/php_milter.c
diff -u php-src/sapi/milter/php_milter.c:1.25
php-src/sapi/milter/php_milter.c:1.26
--- php-src/sapi/milter/php_milter.c:1.25 Wed Jul 16 11:59:34 2008
+++ php-src/sapi/milter/php_milter.c Wed Aug 13 00:49:59 2008
@@ -18,6 +18,7 @@
+----------------------------------------------------------------------+
*/
+/* $Id: php_milter.c,v 1.26 2008/08/13 00:49:59 jani Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -1057,13 +1058,6 @@
zend_uv.html_errors = 0; /* tell the engine we're in non-html
mode */
- if (milter_sapi_module.php_ini_path_override &&
milter_sapi_module.php_ini_ignore) {
- SG(headers_sent) = 1;
- SG(request_info).no_headers = 1;
- PUTS("You cannot use both -n and -c switch. Use -h for
help.\n");
- exit(1);
- }
-
while ((c = ap_php_getopt(argc, argv, OPTSTRING)) != -1) {
switch (c) {