Skip to content

Commit 7a988fb

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 b48f262 commit 7a988fb

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
@@ -923,9 +923,12 @@ static int sapi_cgi_activate(void)
923923
if (fcgi_is_fastcgi()) {
924924
fcgi_request *request = (fcgi_request*) SG(server_context);
925925

926-
doc_root = FCGI_GETENV(request, "DOCUMENT_ROOT");
926+
/* Prefer CONTEXT_DOCUMENT_ROOT if set */
927+
doc_root = FCGI_GETENV(request, "CONTEXT_DOCUMENT_ROOT");
928+
doc_root = doc_root ? doc_root : FCGI_GETENV(request, "DOCUMENT_ROOT");
927929
} else {
928-
doc_root = getenv("DOCUMENT_ROOT");
930+
doc_root = getenv("CONTEXT_DOCUMENT_ROOT");
931+
doc_root = doc_root ? doc_root : getenv("DOCUMENT_ROOT");
929932
}
930933
/* DOCUMENT_ROOT should also be defined at this stage..but better check it anyway */
931934
if (doc_root) {

sapi/fpm/fpm/fpm_main.c

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

744744
/* Load and activate user ini files in path starting from DOCUMENT_ROOT */
745745
if (PG(user_ini_filename) && *PG(user_ini_filename)) {
746-
doc_root = FCGI_GETENV(request, "DOCUMENT_ROOT");
746+
/* Prefer CONTEXT_DOCUMENT_ROOT if set */
747+
doc_root = FCGI_GETENV(request, "CONTEXT_DOCUMENT_ROOT");
748+
doc_root = doc_root ? doc_root : FCGI_GETENV(request, "DOCUMENT_ROOT");
749+
747750
/* DOCUMENT_ROOT should also be defined at this stage..but better check it anyway */
748751
if (doc_root) {
749752
doc_root_len = strlen(doc_root);

0 commit comments

Comments
 (0)