Project

General

Profile

Actions

Feature #2383

closed

mod_alias: use alias directory as doc-root too

Added by molliver about 12 years ago. Updated almost 8 years ago.

Status:
Fixed
Priority:
Normal
Category:
mod_alias
Target version:
ASK QUESTIONS IN Forums:

Description

11:23 <darix> we just wrap that 1 line into an option
11:23 <darix> something like alias.update-docroot or so
11:24 <darix> then pixie79 and others can have change the behavior and we dont break the rest
11:24 <stbuehler> i'm lazy and wait for a patch :P

diff --git a/src/mod_alias.c b/src/mod_alias.c
index 5b7b510..6702bbc 100644
--- a/src/mod_alias.c
+++ b/src/mod_alias.c
@@ -173,6 +173,9 @@ PHYSICALPATH_FUNC(mod_alias_physical_handler) {
                        /* matched */

                        buffer_copy_string_buffer(con->physical.basedir, ds->value);
+            if (0 == (con->conf.alias.update-docroot->used == 0) {
+                buffer_copy_string_buffer(con->physical.doc_root, ds->value);
+            }
                        buffer_copy_string_buffer(srv->tmp_buf, ds->value);
                        buffer_append_string(srv->tmp_buf, uri_ptr + alias_len);
                        buffer_copy_string_buffer(con->physical.path, srv->tmp_buf);
Actions #1

Updated by stbuehler about 12 years ago

  • Description updated (diff)
  • Target version changed from 1.4.31 to 1.4.x
Actions #2

Updated by stbuehler almost 12 years ago

  • Description updated (diff)
Actions #3

Updated by stbuehler almost 12 years ago

This patch won't work. C (and lighttpd) is a little bit more complex.

Actions #4

Updated by gstrauss about 8 years ago

It seems some context from IRC did not make it into the issue description. What was/is the intent?

Actions #5

Updated by stbuehler about 8 years ago

  • Subject changed from mod_alias to mod_alias: use alias directory as doc-root too
Actions #6

Updated by stbuehler about 8 years ago

IIRC the intention was that the backend gets a "physical base directory" as docroot to search for application specific configurations (e.g. http://php.net/manual/en/configuration.file.per-user.php)

Actions #7

Updated by gstrauss almost 8 years ago

  • Status changed from New to Need Feedback

DOCUMENT_ROOT is not part of the CGI specification (https://tools.ietf.org/html/rfc3875)

http://php.net/manual/en/reserved.variables.php describes numerous ways to attempt to reverse engineer $_SERVER['DOCUMENT_ROOT'] if not provided (for whatever reason)

Since lighttpd sets DOCUMENT_ROOT for the benefit of PHP, why not always set DOCUMENT_ROOT to con->physical.basedir instead of con->physical.doc_root?

Note: con->physical.basedir is equivalent to con->physical.doc_root, unless con->physical.basedir has been changed by modules such as mod_alias and mod_userdir, among others. It seems like an oversight that this is not already the case. When the base directory changes it is surprising that such is not reflected in DOCUMENT_ROOT.

(I understand that changing this now is a behavior change which might surprise some people, so perhaps there should be a server directive to user con->physical.basedir when setting DOCUMENT_ROOT in CGI, FastCGI, SCGI, and SSI.)

Actions #8

Updated by gstrauss almost 8 years ago

mod_fastcgi, mod_scgi, and mod_cgi already set DOCUMENT_ROOT to con->physical.basedir. Only mod_ssi and mod_cml_lua do not, and those should probably be considered bugs. (Why does mod_cml_lua set the PHP env var DOCUMENT_ROOT at all?)

See #2216

commit adc97e5ba3f4b42afd2ed1b0d689565dc67736e8
Author: Stefan Bühler <stbuehler@web.de>
Date:   Mon Jun 13 12:22:02 2011 +0000

    [*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

What the issue in this ticket already (mostly) solved before this ticket was created?

Actions #9

Updated by gstrauss almost 8 years ago

A post in 2014 at http://article.gmane.org/gmane.comp.web.lighttpd/5361 points out the inconsistency in mod_ssi and mod_cml_lua

Actions #10

Updated by gstrauss almost 8 years ago

  • Status changed from Need Feedback to Patch Pending
  • Target version changed from 1.4.x to 1.4.40
diff --git a/src/mod_cml_lua.c b/src/mod_cml_lua.c
index 519f9c8..67f989e 100644
--- a/src/mod_cml_lua.c
+++ b/src/mod_cml_lua.c
@@ -152,7 +152,7 @@ int cache_parse_lua(server *srv, connection *con, plugin_data *p, buffer *fn) {
                c_to_lua_push(L, header_tbl, CONST_STR_LEN("REQUEST_URI"), CONST_BUF_LEN(con->request.orig_uri));
                c_to_lua_push(L, header_tbl, CONST_STR_LEN("SCRIPT_NAME"), CONST_BUF_LEN(con->uri.path));
                c_to_lua_push(L, header_tbl, CONST_STR_LEN("SCRIPT_FILENAME"), CONST_BUF_LEN(con->physical.path));
-               c_to_lua_push(L, header_tbl, CONST_STR_LEN("DOCUMENT_ROOT"), CONST_BUF_LEN(con->physical.doc_root));
+               c_to_lua_push(L, header_tbl, CONST_STR_LEN("DOCUMENT_ROOT"), CONST_BUF_LEN(con->physical.basedir));
                if (!buffer_string_is_empty(con->request.pathinfo)) {
                        c_to_lua_push(L, header_tbl, CONST_STR_LEN("PATH_INFO"), CONST_BUF_LEN(con->request.pathinfo));
                }
diff --git a/src/mod_ssi.c b/src/mod_ssi.c
index 9172fa2..8d4452a 100644
--- a/src/mod_ssi.c
+++ b/src/mod_ssi.c
@@ -283,7 +283,7 @@ static int build_ssi_cgi_vars(server *srv, connection *con, plugin_data *p) {
        }

        ssi_env_add(p->ssi_cgi_env, CONST_STRING("SCRIPT_FILENAME"), con->physical.path->ptr);
-       ssi_env_add(p->ssi_cgi_env, CONST_STRING("DOCUMENT_ROOT"), con->physical.doc_root->ptr);
+       ssi_env_add(p->ssi_cgi_env, CONST_STRING("DOCUMENT_ROOT"), con->physical.basedir->ptr);

        ssi_env_add(p->ssi_cgi_env, CONST_STRING("REQUEST_URI"), con->request.uri->ptr);

Actions #11

Updated by gstrauss almost 8 years ago

  • Status changed from Patch Pending to Fixed
  • % Done changed from 0 to 100
Actions

Also available in: Atom