Skip to content

Commit 1f19eae

Browse files
author
wbender
committed
Use CONTEXT_DOCUMENT_ROOT for scanning dir tree
* If CONTEXT_DOCUMENT_ROOT is set use that rather than DOCUMENT_ROOT to scan up the dir tree looking for .user.ini files.
1 parent 127d6f3 commit 1f19eae

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

sapi/cgi/cgi_main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -913,9 +913,12 @@ static int sapi_cgi_activate(void)
913913
if (fcgi_is_fastcgi()) {
914914
fcgi_request *request = (fcgi_request*) SG(server_context);
915915

916-
doc_root = FCGI_GETENV(request, "DOCUMENT_ROOT");
916+
/* Prefer CONTEXT_DOCUMENT_ROOT if set */
917+
doc_root = FCGI_GETENV(request, "CONTEXT_DOCUMENT_ROOT");
918+
doc_root = doc_root ? doc_root : FCGI_GETENV(request, "DOCUMENT_ROOT");
917919
} else {
918-
doc_root = getenv("DOCUMENT_ROOT");
920+
doc_root = getenv("CONTEXT_DOCUMENT_ROOT");
921+
doc_root = doc_root ? doc_root : getenv("DOCUMENT_ROOT");
919922
}
920923
/* DOCUMENT_ROOT should also be defined at this stage..but better check it anyway */
921924
if (doc_root) {

sapi/fpm/fpm/fpm_main.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,10 @@ static int sapi_cgi_activate(void) /* {{{ */
733733

734734
/* Load and activate user ini files in path starting from DOCUMENT_ROOT */
735735
if (PG(user_ini_filename) && *PG(user_ini_filename)) {
736-
doc_root = FCGI_GETENV(request, "DOCUMENT_ROOT");
736+
/* Prefer CONTEXT_DOCUMENT_ROOT if set */
737+
doc_root = FCGI_GETENV(request, "CONTEXT_DOCUMENT_ROOT");
738+
doc_root = doc_root ? doc_root : FCGI_GETENV(request, "DOCUMENT_ROOT");
739+
737740
/* DOCUMENT_ROOT should also be defined at this stage..but better check it anyway */
738741
if (doc_root) {
739742
doc_root_len = strlen(doc_root);

0 commit comments

Comments
 (0)