]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_so: Add -D DUMP_MODULE_DATA to print module data in structured
authorJoe Orton <jorton@apache.org>
Thu, 26 Jun 2025 09:21:25 +0000 (09:21 +0000)
committerJoe Orton <jorton@apache.org>
Thu, 26 Jun 2025 09:21:25 +0000 (09:21 +0000)
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

docs/manual/programs/httpd.xml
modules/core/mod_so.c

index 13fc50d081663f8fc94ae1f6e564770a071328b7..8ad4a278f6ad683cbdf23dce89ca2b456219cc49 100644 (file)
@@ -101,7 +101,6 @@ config files.</dd>
 <dd>Process the configuration <var>directive</var> after reading config
 files.</dd>
 
-
 <dt><code>-D <var>parameter</var></code></dt>
 
 <dd>Sets a configuration <var>parameter </var>which can be used with
@@ -154,15 +153,11 @@ shows the virtualhost settings).</dd>
 <dt><code>-t</code></dt>
 
 <dd>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
-<var>DUMP</var>_<var>VHOSTS </var>is also set, details of the virtual host
-configuration will be printed. If -D <var>DUMP</var>_<var>MODULES </var> is
-set, all loaded modules will be printed. If -D <var>DUMP</var>_<var>CERTS </var>
-is set and <module>mod_ssl</module> is used, configured SSL certificates will
-be printed.  If -D <var>DUMP</var>_<var>CA</var>_<var>_CERTS </var> is set and
-<module>mod_ssl</module> is used, configured SSL CA certificates and configured
-directories containing SSL CA certificates will be printed.</dd>
+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 <var>-D
+DUMP_...</var> arguments to print information about the configuration,
+<a href="#dumpconf">as listed below</a>.</dd>
 
 <dt><code>-v</code></dt>
 
@@ -203,4 +198,25 @@ be read.</dd>
 
 </section>
 
+<section id="dumpconf"><title>Dumping configuration data</title>
+
+<p>The following options can be combined with <var>-t</var> to show
+information about the configuration:</p>
+
+<dl>
+  <dt><var>-D DUMP_VHOSTS</var></dt> <dd>print details of the virtual
+  host configuration.</dd>
+
+  <dt><var>-D DUMP_MODULES</var></dt> <dd>print (human-readable)
+  details of all loaded modules.</dd>
+
+  <dt><var>-D DUMP_MODULES</var> <var>-D DUMP_MODULE_DATA</var></dt>
+  <dd>print details of all loaded modules in a structured (TOML) format.</dd>
+
+  <dt><var>-D DUMP_CERTS</var></dt>
+  <dd>If <module>mod_ssl</module> is loaded, print details of
+  configured SSL/TLS certificates.</dd>
+</dl>
+</section>
+
 </manualpage>
index 26ed8cd8212bd1dc4ac69dad2cf9df04cbe17dc7..c2f6f1084cbbeee998e3d89bf7ddf3cd9987475b 100644 (file)
@@ -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);
         }
     }
 }