]> TLD Linux GIT Repositories - packages/apache.git/blob - apache-mod_vhost_alias_docroot.patch
- release 2
[packages/apache.git] / apache-mod_vhost_alias_docroot.patch
1 --- old/modules/mappers/mod_vhost_alias.c       2006-07-24 13:07:15.000000000 +0100
2 +++ new/modules/mappers/mod_vhost_alias.c       2006-07-24 13:09:21.000000000 +0100
3 @@ -33,6 +33,8 @@
4   * both written by James Grinter <jrg@blodwen.demon.co.uk>.
5   */
6  
7 +#define CORE_PRIVATE
8 +
9  #include "apr.h"
10  #include "apr_strings.h"
11  #include "apr_hooks.h"
12 @@ -67,6 +69,7 @@
13      const char *cgi_root;
14      mva_mode_e doc_root_mode;
15      mva_mode_e cgi_root_mode;
16 +    int set_doc_root;
17  } mva_sconf_t;
18  
19  static void *mva_create_server_config(apr_pool_t *p, server_rec *s)
20 @@ -78,6 +81,7 @@
21      conf->cgi_root = NULL;
22      conf->doc_root_mode = VHOST_ALIAS_UNSET;
23      conf->cgi_root_mode = VHOST_ALIAS_UNSET;
24 +    conf->set_doc_root = 0;
25      return conf;
26  }
27  
28 @@ -104,6 +108,8 @@
29          conf->cgi_root_mode = child->cgi_root_mode;
30          conf->cgi_root = child->cgi_root;
31      }
32 +
33 +    conf->set_doc_root = child->set_doc_root;
34      return conf;
35  }
36  
37 @@ -212,6 +218,18 @@
38      return NULL;
39  }
40  
41 +
42 +static const char *vhost_set_docroot(cmd_parms *cmd, void *dummy,
43 +                                    const char *str)
44 +{
45 +    mva_sconf_t *conf;
46 +    conf = (mva_sconf_t *) ap_get_module_config(cmd->server->module_config,
47 +                                               &vhost_alias_module);
48 +    conf->set_doc_root = (strcasecmp(str, "yes") == 0 ||
49 +                         strcasecmp(str, "on") == 0) ? 1 : 0;
50 +    return NULL;
51 +}
52 +
53  static const command_rec mva_commands[] =
54  {
55      AP_INIT_TAKE1("VirtualScriptAlias", vhost_alias_set,
56 @@ -226,6 +244,9 @@
57      AP_INIT_TAKE1("VirtualDocumentRootIP", vhost_alias_set,
58                    &vhost_alias_set_doc_root_ip, RSRC_CONF,
59                    "how to create the DocumentRoot based on the host"),
60 +    AP_INIT_TAKE1("SetVirtualDocumentRoot", vhost_set_docroot,
61 +                 NULL, RSRC_CONF,
62 +                 "set DOCUMENT_ROOT to parsed document root"),
63      { NULL }
64  };
65  
66 @@ -250,8 +271,9 @@
67      }
68  }
69  
70 -static void vhost_alias_interpolate(request_rec *r, const char *name,
71 -                                    const char *map, const char *uri)
72 +static void vhost_alias_interpolate(request_rec *r, mva_sconf_t *conf,
73 +                                   const char *name, const char *map,
74 +                                   const char *uri)
75  {
76      /* 0..9 9..0 */
77      enum { MAXDOTS = 19 };
78 @@ -378,6 +400,13 @@
79      else {
80          r->filename = apr_pstrcat(r->pool, buf, uri, NULL);
81      }
82 +
83 +    if (conf->set_doc_root) {
84 +       request_rec *top = (r->main)?r->main:r;
85 +       core_server_config *core = (core_server_config *) ap_get_module_config(r->server->module_config, &core_module);
86 +
87 +       core->ap_document_root = apr_pstrdup(top->pool, buf);
88 +    }
89  }
90  
91  static int mva_translate(request_rec *r)
92 @@ -426,7 +455,7 @@
93       * canonical_path buffer.
94       */
95      r->canonical_filename = "";
96 -    vhost_alias_interpolate(r, name, map, uri);
97 +    vhost_alias_interpolate(r, conf, name, map, uri);
98  
99      if (cgi) {
100          /* see is_scriptaliased() in mod_cgi */