Commit 4ba991d7 authored by Patrick J Cherry's avatar Patrick J Cherry
Browse files

httpd: Updated vhost_bytemark to move the manipulation to work on the

document root, rather than the request filename, and then use this to
set the DOCUMENT_ROOT variable.
parent a31ba4e6
......@@ -400,19 +400,11 @@ static void vhost_alias_interpolate(request_rec *r, mva_sconf_t *conf,
++uri;
}
if (r->filename) {
r->filename = apr_pstrcat(r->pool, r->filename, buf, uri, NULL);
}
else {
r->filename = apr_pstrcat(r->pool, buf, uri, NULL);
}
/*
* A this point we either have a request which points to a file
* on disk - or not.
* A this point we either have a document root which points to something on
* disk - or not.
*
* If the request doesn't exist on disk we can *attempt* to remap
* If the docroot doesn't exist on disk we can *attempt* to remap
* that to the real file.
*
* If this remapping fails we don't care as the result will be a 404,
......@@ -425,8 +417,7 @@ static void vhost_alias_interpolate(request_rec *r, mva_sconf_t *conf,
/**
* If we have:
*
* A request.
* That mapped to a filename.
* A document root
* Which doesn't exist.
*
* Then:
......@@ -434,9 +425,8 @@ static void vhost_alias_interpolate(request_rec *r, mva_sconf_t *conf,
* Attempt to fix.
*
*/
if ( ( NULL != r ) &&
( NULL != r->filename ) &&
( stat( r->filename, &buffer ) < 0 ) )
if ( ( NULL != buf ) &&
( stat( buf, &buffer ) < 0 ) )
{
/**
......@@ -444,43 +434,32 @@ static void vhost_alias_interpolate(request_rec *r, mva_sconf_t *conf,
* after the /srv prefix which will result in
* a request being rewritten from (for example)
*
* /srv/test.example.com/public/htdocs/test/index.php
* /srv/test.example.com/public/htdocs/
*
* to:
*
* /srv/example.com/public/htdocs/test/index.php
* /srv/example.com/public/htdocs/
*
*/
update_vhost_request( r->filename );
update_vhost_request( buf );
}
}
if (r->filename) {
r->filename = apr_pstrcat(r->pool, r->filename, buf, uri, NULL);
}
else {
r->filename = apr_pstrcat(r->pool, buf, uri, NULL);
}
/**
* Set the document root for non-CGI requests.
* Set the document root
*/
if (conf->set_doc_root)
if (conf->set_doc_root && NULL != r && NULL != buf)
{
/* ignore cgi requests. */
const char *cgi;
if ( ( NULL != r ) &&
( NULL != r->uri ) )
cgi = strstr(r->uri, "cgi-bin/");
if ( NULL == cgi )
{
request_rec *top = (r->main)?r->main:r;
char *tmp = apr_pstrdup(top->pool, r->filename);
char *p = NULL;
p = strstr(tmp, "/htdocs/" );
if ( p != NULL )
p[strlen( "/htdocs/" ) ] = '\0';
core_server_config *core = (core_server_config *) ap_get_module_config(r->server->module_config, &core_module);
core->ap_document_root = tmp;
}
core_server_config *core = (core_server_config *) ap_get_module_config(r->server->module_config, &core_module);
char *tmp = apr_pstrdup(r->pool, buf);
core->ap_document_root = tmp;
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment