From: Joe Orton Date: Thu, 26 Jun 2025 09:21:25 +0000 (+0000) Subject: mod_so: Add -D DUMP_MODULE_DATA to print module data in structured X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=36f619966be667d244eb8122b359e68ce1159413;p=thirdparty%2Fapache%2Fhttpd.git mod_so: Add -D DUMP_MODULE_DATA to print module data in structured format (TOML) including MMN information. * modules/core/mod_so.c (print_mod_data): New function. (dump_loaded_modules): Use it if DUMP_MODULE_DATA is defined. * docs/manual/programs/httpd.xml: Move -DDUMP_* docs to a new section, cover the above new option. Github: closes #537 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1926737 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/programs/httpd.xml b/docs/manual/programs/httpd.xml index 13fc50d081..8ad4a278f6 100644 --- a/docs/manual/programs/httpd.xml +++ b/docs/manual/programs/httpd.xml @@ -101,7 +101,6 @@ config files.
Process the configuration directive after reading config files.
-
-D parameter
Sets a configuration parameter which can be used with @@ -154,15 +153,11 @@ shows the virtualhost settings).
-t
Run syntax tests for configuration files only. The program -immediately exits after these syntax parsing tests with either a return code -of 0 (Syntax OK) or return code not equal to 0 (Syntax Error). If -D -DUMP_VHOSTS is also set, details of the virtual host -configuration will be printed. If -D DUMP_MODULES is -set, all loaded modules will be printed. If -D DUMP_CERTS -is set and mod_ssl is used, configured SSL certificates will -be printed. If -D DUMP_CA__CERTS is set and -mod_ssl is used, configured SSL CA certificates and configured -directories containing SSL CA certificates will be printed.
+immediately exits after these syntax parsing tests with either a +return code of 0 (Syntax OK) or return code not equal to 0 (Syntax +Error). This option can be combined with various -D +DUMP_... arguments to print information about the configuration, +as listed below.
-v
@@ -203,4 +198,25 @@ be read. +
Dumping configuration data + +

The following options can be combined with -t to show +information about the configuration:

+ +
+
-D DUMP_VHOSTS
print details of the virtual + host configuration.
+ +
-D DUMP_MODULES
print (human-readable) + details of all loaded modules.
+ +
-D DUMP_MODULES -D DUMP_MODULE_DATA
+
print details of all loaded modules in a structured (TOML) format.
+ +
-D DUMP_CERTS
+
If mod_ssl is loaded, print details of + configured SSL/TLS certificates.
+
+
+ diff --git a/modules/core/mod_so.c b/modules/core/mod_so.c index 26ed8cd821..c2f6f1084c 100644 --- a/modules/core/mod_so.c +++ b/modules/core/mod_so.c @@ -361,12 +361,26 @@ static module *ap_find_loaded_module_symbol(server_rec *s, const char *modname) return NULL; } +/* Print structured module data in TOML format for -D DUMP_MODULE_DATA + * output. */ +static void print_mod_data(apr_file_t *out, int is_static, + const ap_module_symbol_t *modsym) +{ + const char *name = modsym->name; + const module *mod = modsym->modp; + + apr_file_printf(out, "%s.static = %d\n", name, is_static); + apr_file_printf(out, "%s.source = \"%s\"\n", name, mod->name); + apr_file_printf(out, "%s.major = %d\n", name, mod->version); + apr_file_printf(out, "%s.minor = %d\n", name, mod->minor_version); +} + static void dump_loaded_modules(apr_pool_t *p, server_rec *s) { ap_module_symbol_t *modie; ap_module_symbol_t *modi; so_server_conf *sconf; - int i; + int i, toml = ap_exists_config_define("DUMP_MODULE_DATA"); apr_file_t *out = NULL; if (!ap_exists_config_define("DUMP_MODULES")) { @@ -375,14 +389,17 @@ static void dump_loaded_modules(apr_pool_t *p, server_rec *s) apr_file_open_stdout(&out, p); - apr_file_printf(out, "Loaded Modules:\n"); + if (!toml) apr_file_printf(out, "Loaded Modules:\n"); sconf = (so_server_conf *)ap_get_module_config(s->module_config, &so_module); for (i = 0; ; i++) { modi = &ap_prelinked_module_symbols[i]; if (modi->name != NULL) { - apr_file_printf(out, " %s (static)\n", modi->name); + if (toml) + print_mod_data(out, 1, modi); + else + apr_file_printf(out, " %s (static)\n", modi->name); } else { break; @@ -393,7 +410,10 @@ static void dump_loaded_modules(apr_pool_t *p, server_rec *s) for (i = 0; i < sconf->loaded_modules->nelts; i++) { modi = &modie[i]; if (modi->name != NULL) { - apr_file_printf(out, " %s (shared)\n", modi->name); + if (toml) + print_mod_data(out, 0, modi); + else + apr_file_printf(out, " %s (shared)\n", modi->name); } } }