[2469] | 1 | From e90c8e59a93e5dde747e6dec7b960d2a6f2523ab Mon Sep 17 00:00:00 2001 |
---|
[2422] | 2 | From: Alexander Chernyakhovsky <achernya@mit.edu> |
---|
| 3 | Date: Fri, 3 May 2013 22:43:28 -0400 |
---|
[2469] | 4 | Subject: [PATCH] Export method to fixup a single virtual host |
---|
[1602] | 5 | |
---|
[2422] | 6 | Apache normally provides ap_fixup_virtual_hosts, which merges the |
---|
| 7 | configuration from the main server into each virtual host. Refactor |
---|
| 8 | this code to allow merging the configuration into a single virtual |
---|
| 9 | host, and export this method for use in mod_vhost_ldap. |
---|
[1602] | 10 | |
---|
[2422] | 11 | Additionally, call the newly created method in the loop in |
---|
| 12 | ap_fixup_virtual_hosts. |
---|
| 13 | --- |
---|
[2469] | 14 | include/http_config.h | 9 ++++++++ |
---|
| 15 | server/config.c | 58 ++++++++++++++++++++++++++++----------------------- |
---|
[2422] | 16 | 2 files changed, 41 insertions(+), 26 deletions(-) |
---|
| 17 | |
---|
[1602] | 18 | diff --git a/include/http_config.h b/include/http_config.h |
---|
[2422] | 19 | index 7ee3760..e3657ea 100644 |
---|
[1602] | 20 | --- a/include/http_config.h |
---|
| 21 | +++ b/include/http_config.h |
---|
[2422] | 22 | @@ -1012,6 +1012,15 @@ AP_DECLARE(void) ap_register_hooks(module *m, apr_pool_t *p); |
---|
| 23 | */ |
---|
| 24 | AP_DECLARE(void) ap_fixup_virtual_hosts(apr_pool_t *p, |
---|
[1602] | 25 | server_rec *main_server); |
---|
| 26 | +/** |
---|
[2422] | 27 | + * Setup all virtual hosts |
---|
[1602] | 28 | + * @param p The pool to allocate from |
---|
[2422] | 29 | + * @param main_server The head of the server_rec list |
---|
| 30 | + * @param virt The individual virtual host to fix |
---|
[1602] | 31 | + */ |
---|
| 32 | +AP_DECLARE(void) ap_fixup_virtual_host(apr_pool_t *p, |
---|
| 33 | + server_rec *main_server, |
---|
| 34 | + server_rec *virt); |
---|
| 35 | |
---|
| 36 | /** |
---|
[2422] | 37 | * Reserve some modules slots for modules loaded by other means than |
---|
[1602] | 38 | diff --git a/server/config.c b/server/config.c |
---|
[2469] | 39 | index c1aae17..254c5d2 100644 |
---|
[1602] | 40 | --- a/server/config.c |
---|
| 41 | +++ b/server/config.c |
---|
[2469] | 42 | @@ -2245,46 +2245,52 @@ AP_DECLARE(void) ap_merge_log_config(const struct ap_logconf *old_conf, |
---|
[2422] | 43 | } |
---|
[1602] | 44 | } |
---|
| 45 | |
---|
| 46 | -AP_DECLARE(void) ap_fixup_virtual_hosts(apr_pool_t *p, server_rec *main_server) |
---|
| 47 | +AP_DECLARE(void) ap_fixup_virtual_host(apr_pool_t *p, server_rec *main_server, |
---|
[2422] | 48 | + server_rec *virt) |
---|
[1602] | 49 | { |
---|
| 50 | - server_rec *virt; |
---|
[2422] | 51 | core_dir_config *dconf = |
---|
| 52 | ap_get_core_module_config(main_server->lookup_defaults); |
---|
| 53 | dconf->log = &main_server->log; |
---|
[1602] | 54 | |
---|
| 55 | - for (virt = main_server->next; virt; virt = virt->next) { |
---|
| 56 | - merge_server_configs(p, main_server->module_config, |
---|
| 57 | - virt->module_config); |
---|
[2422] | 58 | + merge_server_configs(p, main_server->module_config, |
---|
| 59 | + virt->module_config); |
---|
[1602] | 60 | |
---|
| 61 | - virt->lookup_defaults = |
---|
| 62 | - ap_merge_per_dir_configs(p, main_server->lookup_defaults, |
---|
| 63 | - virt->lookup_defaults); |
---|
[2422] | 64 | + virt->lookup_defaults = |
---|
| 65 | + ap_merge_per_dir_configs(p, main_server->lookup_defaults, |
---|
| 66 | + virt->lookup_defaults); |
---|
[1602] | 67 | |
---|
| 68 | - if (virt->server_admin == NULL) |
---|
| 69 | - virt->server_admin = main_server->server_admin; |
---|
[2422] | 70 | + if (virt->server_admin == NULL) |
---|
| 71 | + virt->server_admin = main_server->server_admin; |
---|
[1602] | 72 | |
---|
| 73 | - if (virt->timeout == 0) |
---|
| 74 | - virt->timeout = main_server->timeout; |
---|
[2422] | 75 | + if (virt->timeout == 0) |
---|
| 76 | + virt->timeout = main_server->timeout; |
---|
[1602] | 77 | |
---|
| 78 | - if (virt->keep_alive_timeout == 0) |
---|
| 79 | - virt->keep_alive_timeout = main_server->keep_alive_timeout; |
---|
[2422] | 80 | + if (virt->keep_alive_timeout == 0) |
---|
| 81 | + virt->keep_alive_timeout = main_server->keep_alive_timeout; |
---|
[1602] | 82 | |
---|
| 83 | - if (virt->keep_alive == -1) |
---|
| 84 | - virt->keep_alive = main_server->keep_alive; |
---|
[2422] | 85 | + if (virt->keep_alive == -1) |
---|
| 86 | + virt->keep_alive = main_server->keep_alive; |
---|
[1602] | 87 | |
---|
| 88 | - if (virt->keep_alive_max == -1) |
---|
| 89 | - virt->keep_alive_max = main_server->keep_alive_max; |
---|
[2422] | 90 | + if (virt->keep_alive_max == -1) |
---|
| 91 | + virt->keep_alive_max = main_server->keep_alive_max; |
---|
[1602] | 92 | |
---|
[2422] | 93 | - ap_merge_log_config(&main_server->log, &virt->log); |
---|
| 94 | + ap_merge_log_config(&main_server->log, &virt->log); |
---|
| 95 | |
---|
| 96 | - dconf = ap_get_core_module_config(virt->lookup_defaults); |
---|
| 97 | - dconf->log = &virt->log; |
---|
| 98 | + dconf = ap_get_core_module_config(virt->lookup_defaults); |
---|
| 99 | + dconf->log = &virt->log; |
---|
| 100 | |
---|
[1602] | 101 | - /* XXX: this is really something that should be dealt with by a |
---|
| 102 | - * post-config api phase |
---|
| 103 | - */ |
---|
| 104 | - ap_core_reorder_directories(p, virt); |
---|
| 105 | - } |
---|
[2422] | 106 | + /* XXX: this is really something that should be dealt with by a |
---|
| 107 | + * post-config api phase |
---|
| 108 | + */ |
---|
| 109 | + ap_core_reorder_directories(p, virt); |
---|
| 110 | +} |
---|
| 111 | + |
---|
[1602] | 112 | +AP_DECLARE(void) ap_fixup_virtual_hosts(apr_pool_t *p, server_rec *main_server) |
---|
| 113 | +{ |
---|
| 114 | + server_rec *virt; |
---|
[2422] | 115 | + |
---|
[1602] | 116 | + for (virt = main_server->next; virt; virt = virt->next) |
---|
| 117 | + ap_fixup_virtual_host(p, main_server, virt); |
---|
| 118 | |
---|
| 119 | ap_core_reorder_directories(p, main_server); |
---|
| 120 | } |
---|
[2422] | 121 | -- |
---|
[2469] | 122 | 1.8.1.2 |
---|
[2422] | 123 | |
---|