From adc97e5ba3f4b42afd2ed1b0d689565dc67736e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Mon, 13 Jun 2011 12:22:02 +0000 Subject: [PATCH] [*cgi] Use physical base dir (alias, userdir) as DOCUMENT_ROOT in cgi environments (fixes #2216) git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2794 152afb58-edef-0310-8abb-c4023f1b3aa9 --- NEWS | 1 + src/mod_cgi.c | 2 +- src/mod_fastcgi.c | 5 +++-- src/mod_scgi.c | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 0f70221a..f30f405b 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,7 @@ NEWS * [ssl/md5] prefix our own md5 implementation with li_ so it doesn't conflict with the openssl one (fixes #2269) * [ssl/build] some minor fixes; fix compile without ssl, cleanup ssl config buffers * [proc,include_shell] log error if exec shell fails (fixes #2280) + * [*cgi] Use physical base dir (alias, userdir) as DOCUMENT_ROOT in cgi environments (fixes #2216) - 1.4.28 - 2010-08-22 * Rename fdevent_event_add to _set to reflect what the function does. Fix some handlers. (fixes #2249) diff --git a/src/mod_cgi.c b/src/mod_cgi.c index 3bdde3f3..25d2f652 100644 --- a/src/mod_cgi.c +++ b/src/mod_cgi.c @@ -928,7 +928,7 @@ static int cgi_create_env(server *srv, connection *con, plugin_data *p, buffer * cgi_env_add(&env, CONST_STR_LEN("CONTENT_LENGTH"), buf, strlen(buf)); cgi_env_add(&env, CONST_STR_LEN("SCRIPT_FILENAME"), CONST_BUF_LEN(con->physical.path)); cgi_env_add(&env, CONST_STR_LEN("SCRIPT_NAME"), CONST_BUF_LEN(con->uri.path)); - cgi_env_add(&env, CONST_STR_LEN("DOCUMENT_ROOT"), CONST_BUF_LEN(con->physical.doc_root)); + cgi_env_add(&env, CONST_STR_LEN("DOCUMENT_ROOT"), CONST_BUF_LEN(con->physical.basedir)); /* for valgrind */ if (NULL != (s = getenv("LD_PRELOAD"))) { diff --git a/src/mod_fastcgi.c b/src/mod_fastcgi.c index 657acfb8..0fbcc174 100644 --- a/src/mod_fastcgi.c +++ b/src/mod_fastcgi.c @@ -1968,7 +1968,7 @@ static int fcgi_create_env(server *srv, handler_ctx *hctx, size_t request_id) { if (!buffer_is_empty(host->docroot)) { buffer_copy_string_buffer(p->path, host->docroot); } else { - buffer_copy_string_buffer(p->path, con->physical.doc_root); + buffer_copy_string_buffer(p->path, con->physical.basedir); } buffer_append_string_buffer(p->path, con->request.pathinfo); FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("PATH_TRANSLATED"), CONST_BUF_LEN(p->path)),con) @@ -2008,7 +2008,7 @@ static int fcgi_create_env(server *srv, handler_ctx *hctx, size_t request_id) { } FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SCRIPT_FILENAME"), CONST_BUF_LEN(p->path)),con) - FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("DOCUMENT_ROOT"), CONST_BUF_LEN(con->physical.doc_root)),con) + FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("DOCUMENT_ROOT"), CONST_BUF_LEN(con->physical.basedir)),con) } if (host->strip_request_uri->used > 1) { @@ -3273,6 +3273,7 @@ static handler_t fcgi_handle_fdevent(server *srv, void *ctx, int revents) { */ buffer_copy_string_buffer(con->physical.doc_root, host->docroot); + buffer_copy_string_buffer(con->physical.basedir, host->docroot); buffer_copy_string_buffer(con->physical.path, host->docroot); buffer_append_string_buffer(con->physical.path, con->uri.path); diff --git a/src/mod_scgi.c b/src/mod_scgi.c index 0455fbff..59e5ccbb 100644 --- a/src/mod_scgi.c +++ b/src/mod_scgi.c @@ -1558,7 +1558,7 @@ static int scgi_create_env(server *srv, handler_ctx *hctx) { if (!buffer_is_empty(host->docroot)) { buffer_copy_string_buffer(p->path, host->docroot); } else { - buffer_copy_string_buffer(p->path, con->physical.doc_root); + buffer_copy_string_buffer(p->path, con->physical.basedir); } buffer_append_string_buffer(p->path, con->request.pathinfo); scgi_env_add(p->scgi_env, CONST_STR_LEN("PATH_TRANSLATED"), CONST_BUF_LEN(p->path)); @@ -1589,7 +1589,7 @@ static int scgi_create_env(server *srv, handler_ctx *hctx) { buffer_copy_string_buffer(p->path, con->physical.path); scgi_env_add(p->scgi_env, CONST_STR_LEN("SCRIPT_FILENAME"), CONST_BUF_LEN(p->path)); - scgi_env_add(p->scgi_env, CONST_STR_LEN("DOCUMENT_ROOT"), CONST_BUF_LEN(con->physical.doc_root)); + scgi_env_add(p->scgi_env, CONST_STR_LEN("DOCUMENT_ROOT"), CONST_BUF_LEN(con->physical.basedir)); } scgi_env_add(p->scgi_env, CONST_STR_LEN("REQUEST_URI"), CONST_BUF_LEN(con->request.orig_uri)); if (!buffer_is_equal(con->request.uri, con->request.orig_uri)) {