Browse Source

[*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
svn/tags/lighttpd-1.4.29
Stefan Bühler 11 years ago
parent
commit
adc97e5ba3
  1. 1
      NEWS
  2. 2
      src/mod_cgi.c
  3. 5
      src/mod_fastcgi.c
  4. 4
      src/mod_scgi.c

1
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)

2
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"))) {

5
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);

4
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)) {

Loading…
Cancel
Save