ASF Bugzilla – Attachment 33804 Details for
Bug 59376
Provide an option to dump included configuration paths
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
0001: Add a DUMP_INCLUDES switch to show config files
0001-Add-a-DUMP_INCLUDES-switch-to-show-config-files.patch (text/plain), 5.95 KB, created by
Jacob Champion
on 2016-04-25 22:44:58 UTC
(
hide
)
Description:
0001: Add a DUMP_INCLUDES switch to show config files
Filename:
MIME Type:
Creator:
Jacob Champion
Created:
2016-04-25 22:44:58 UTC
Size:
5.95 KB
patch
obsolete
>From b0d11b312cb8d47a29ce111aeeec9508ae999be3 Mon Sep 17 00:00:00 2001 >From: Jacob Champion <champion.p@gmail.com> >Date: Fri, 22 Apr 2016 10:00:08 -0700 >Subject: [PATCH] Add a DUMP_INCLUDES switch to show config files > >When the -D DUMP_INCLUDES switch is provided, httpd will dump the names >of the configuration files, and the line numbers they were Included on, >as the tree is walked. This helps debug complex configuration trees. >--- > server/config.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > server/core.c | 22 ++++++++++++++++++++ > server/main.c | 5 +++++ > 3 files changed, 89 insertions(+) > >diff --git a/server/config.c b/server/config.c >index 7d8f8fc..493bcf7 100644 >--- a/server/config.c >+++ b/server/config.c >@@ -1782,6 +1782,54 @@ static int fname_alphasort(const void *fn1, const void *fn2) > return strcmp(f1->fname,f2->fname); > } > >+/** >+ * Used by -D DUMP_INCLUDES to output the config file "tree". >+ */ >+static void dump_config_name(const char *fname, apr_pool_t *p) >+{ >+ unsigned i, recursion, line_number; >+ void *data; >+ apr_file_t *out = NULL; >+ >+ apr_file_open_stdout(&out, p); >+ >+ /* ap_include_sentinel is defined by the core Include directive; use it to >+ * figure out how deep in the stack we are. >+ */ >+ apr_pool_userdata_get(&data, "ap_include_sentinel", p); >+ >+ if (data) { >+ recursion = *(unsigned *)data; >+ } else { >+ recursion = 0; >+ } >+ >+ /* Indent once for each level. */ >+ for (i = 0; i < (recursion + 1); ++i) { >+ apr_file_printf(out, " "); >+ } >+ >+ /* ap_include_lineno is similarly defined to tell us where in the last >+ * config file we were. >+ */ >+ apr_pool_userdata_get(&data, "ap_include_lineno", p); >+ >+ if (data) { >+ line_number = *(unsigned *)data; >+ } else { >+ line_number = 0; >+ } >+ >+ /* Print the line number and the name of the parsed file. */ >+ if (line_number > 0) { >+ apr_file_printf(out, "(%u)", line_number); >+ } else { >+ apr_file_printf(out, "(*)"); >+ } >+ >+ apr_file_printf(out, " %s\n", fname); >+} >+ > AP_DECLARE(const char *) ap_process_resource_config(server_rec *s, > const char *fname, > ap_directive_t **conftree, >@@ -1806,6 +1854,10 @@ AP_DECLARE(const char *) ap_process_resource_config(server_rec *s, > fname, &rv); > } > >+ if (ap_exists_config_define("DUMP_INCLUDES")) { >+ dump_config_name(fname, p); >+ } >+ > parms.config_file = cfp; > error = ap_build_config(&parms, p, ptemp, conftree); > ap_cfg_closefile(cfp); >@@ -2402,6 +2454,16 @@ AP_DECLARE(server_rec*) ap_read_config(process_rec *process, apr_pool_t *ptemp, > > init_config_globals(p); > >+ if (ap_exists_config_define("DUMP_INCLUDES")) { >+ apr_file_t *out = NULL; >+ apr_file_open_stdout(&out, p); >+ >+ /* Included files will be dumped as the config is walked; print a >+ * header. >+ */ >+ apr_file_printf(out, "Included configuration files:\n"); >+ } >+ > /* All server-wide config files now have the SAME syntax... */ > error = process_command_config(s, ap_server_pre_read_config, conftree, > p, ptemp); >diff --git a/server/core.c b/server/core.c >index 169dd5c..fce7846 100644 >--- a/server/core.c >+++ b/server/core.c >@@ -3247,6 +3247,10 @@ static const char *include_config (cmd_parms *cmd, void *dummy, > int optional = cmd->cmd->cmd_data ? 1 : 0; > void *data; > >+ /* NOTE: ap_include_sentinel is also used by ap_process_resource_config() >+ * during DUMP_INCLUDES; don't change its type or remove it without updating >+ * the other. >+ */ > apr_pool_userdata_get(&data, "ap_include_sentinel", cmd->pool); > if (data) { > recursion = data; >@@ -3271,6 +3275,24 @@ static const char *include_config (cmd_parms *cmd, void *dummy, > name, NULL); > } > >+ if (ap_exists_config_define("DUMP_INCLUDES")) { >+ unsigned *line_number; >+ >+ /* NOTE: ap_include_lineno is used by ap_process_resource_config() >+ * during DUMP_INCLUDES; don't change its type or remove it without >+ * updating the other. >+ */ >+ apr_pool_userdata_get(&data, "ap_include_lineno", cmd->pool); >+ if (data) { >+ line_number = data; >+ } else { >+ data = line_number = apr_palloc(cmd->pool, sizeof(*line_number)); >+ apr_pool_userdata_setn(data, "ap_include_lineno", NULL, cmd->pool); >+ } >+ >+ *line_number = cmd->config_file->line_number; >+ } >+ > error = ap_process_fnmatch_configs(cmd->server, conffile, &conftree, > cmd->pool, cmd->temp_pool, > optional); >diff --git a/server/main.c b/server/main.c >index bbc2b12..351f0f1 100644 >--- a/server/main.c >+++ b/server/main.c >@@ -448,6 +448,8 @@ static void usage(process_rec *process) > ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, > " -M : a synonym for -t -D DUMP_MODULES"); > ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, >+ " -t -D DUMP_INCLUDES: show all included configuration files"); >+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, > " -t : run syntax check for config files"); > ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, > " -T : start without DocumentRoot(s) check"); >@@ -546,6 +548,9 @@ int main(int argc, const char * const argv[]) > /* Setting -D DUMP_MODULES is equivalent to setting -M */ > else if (strcmp(opt_arg, "DUMP_MODULES") == 0) > ap_run_mode = AP_SQ_RM_CONFIG_DUMP; >+ /* Setting -D DUMP_INCLUDES is a type of configuration dump */ >+ else if (strcmp(opt_arg, "DUMP_INCLUDES") == 0) >+ ap_run_mode = AP_SQ_RM_CONFIG_DUMP; > break; > > case 'e': >-- >1.9.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 59376
: 33804