Changeset bc539d5 in mod_gnutls


Ignore:
Timestamp:
Jan 27, 2016, 12:30:40 PM (3 years ago)
Author:
Thomas Klute <thomas2.klute@…>
Branches:
debian/master, debian/stretch-backports, jessie-backports, master, upstream
Children:
29d3311
Parents:
600cf16
git-author:
Thomas Klute <thomas2.klute@…> (01/27/16 02:26:34)
git-committer:
Thomas Klute <thomas2.klute@…> (01/27/16 12:30:40)
Message:

Implement short message for mod_status reports

Until now the flags parameter from mod_status was ignored, and
mod_gnutls always returned an HTML report. With this change the flags
are checked for AP_STATUS_SHORT, and a non-HTML report is written if
it is set.

The formatting of the HTML report has been changed a little, too, so
the expected test output is updated accordingly.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/gnutls_hooks.c

    r600cf16 rbc539d5  
    44 *  Copyright 2011 Dash Shendy
    55 *  Copyright 2013-2014 Daniel Kahn Gillmor
    6  *  Copyright 2015 Thomas Klute
     6 *  Copyright 2015-2016 Thomas Klute
    77 *
    88 *  Licensed under the Apache License, Version 2.0 (the "License");
     
    16551655#endif /* ENABLE_MSVA */
    16561656
    1657 static int mgs_status_hook(request_rec *r, int flags __attribute__((unused)))
     1657
     1658
     1659/*
     1660 * This hook writes the mod_gnutls status message for a mod_status
     1661 * report. According to the comments in mod_status.h, the "flags"
     1662 * parameter is a bitwise OR of the AP_STATUS_ flags.
     1663 *
     1664 * Note that this implementation gives flags explicitly requesting a
     1665 * simple response priority, e.g. if AP_STATUS_SHORT is set, flags
     1666 * requesting an HTML report will be ignored. As of Apache 2.4.10, the
     1667 * following flags were defined in mod_status.h:
     1668 *
     1669 * AP_STATUS_SHORT (short, non-HTML report requested)
     1670 * AP_STATUS_NOTABLE (HTML report without tables)
     1671 * AP_STATUS_EXTENDED (detailed report)
     1672 */
     1673static int mgs_status_hook(request_rec *r, int flags)
    16581674{
    1659     mgs_srvconf_rec *sc;
    1660 
    16611675    if (r == NULL)
    16621676        return OK;
    16631677
    1664     sc = (mgs_srvconf_rec *) ap_get_module_config(r->server->module_config, &gnutls_module);
     1678    mgs_srvconf_rec *sc = (mgs_srvconf_rec *)
     1679        ap_get_module_config(r->server->module_config, &gnutls_module);
    16651680
    16661681    _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__);
    16671682
    1668     ap_rputs("<hr>\n", r);
    1669     ap_rputs("<h2>GnuTLS Information:</h2>\n<dl>\n", r);
    1670 
    1671     ap_rprintf(r, "<dt>GnuTLS version:</dt><dd>%s</dd>\n", gnutls_check_version(NULL));
    1672     ap_rputs("<dt>Built against:</dt><dd>" GNUTLS_VERSION "</dd>\n", r);
    1673     ap_rprintf(r, "<dt>using TLS:</dt><dd>%s</dd>\n", (sc->enabled == GNUTLS_ENABLED_FALSE ? "no" : "yes"));
    1674     if (sc->enabled != GNUTLS_ENABLED_FALSE) {
    1675         mgs_handle_t* ctxt;
    1676         ctxt = ap_get_module_config(r->connection->conn_config, &gnutls_module);
     1683    if (flags & AP_STATUS_SHORT)
     1684    {
     1685        ap_rprintf(r, "Using GnuTLS version: %s\n", gnutls_check_version(NULL));
     1686        ap_rputs("Built against GnuTLS version: " GNUTLS_VERSION "\n", r);
     1687    }
     1688    else
     1689    {
     1690        ap_rputs("<hr>\n", r);
     1691        ap_rputs("<h2>GnuTLS Information:</h2>\n<dl>\n", r);
     1692
     1693        ap_rprintf(r, "<dt>Using GnuTLS version:</dt><dd>%s</dd>\n",
     1694                   gnutls_check_version(NULL));
     1695        ap_rputs("<dt>Built against GnuTLS version:</dt><dd>"
     1696                 GNUTLS_VERSION "</dd>\n", r);
     1697        ap_rprintf(r, "<dt>Using TLS:</dt><dd>%s</dd>\n",
     1698                   (sc->enabled == GNUTLS_ENABLED_FALSE ? "no" : "yes"));
     1699    }
     1700
     1701    if (sc->enabled != GNUTLS_ENABLED_FALSE)
     1702    {
     1703        mgs_handle_t* ctxt =
     1704            ap_get_module_config(r->connection->conn_config, &gnutls_module);
    16771705        if (ctxt && ctxt->session != NULL)
    16781706        {
    1679             char* z = NULL;
    1680             z = gnutls_session_get_desc(ctxt->session);
    1681             if (z) {
    1682                 ap_rprintf(r, "<dt>This TLS Session:</dt><dd>%s</dd>\n", z);
    1683                 gnutls_free(z);
     1707            char* s_info = gnutls_session_get_desc(ctxt->session);
     1708            if (s_info)
     1709            {
     1710                if (flags & AP_STATUS_SHORT)
     1711                    ap_rprintf(r, "Current TLS session: %s\n", s_info);
     1712                else
     1713                    ap_rprintf(r, "<dt>Current TLS session:</dt><dd>%s</dd>\n",
     1714                               s_info);
     1715                gnutls_free(s_info);
    16841716            }
    16851717        }
    16861718    }
    16871719
    1688     ap_rputs("</dl>\n", r);
     1720    if (!(flags & AP_STATUS_SHORT))
     1721        ap_rputs("</dl>\n", r);
     1722
    16891723    return OK;
    16901724}
  • test/tests/16_view-status/output

    r600cf16 rbc539d5  
    1 <dt>using TLS:</dt><dd>yes</dd>
    2 <dt>This TLS Session:</dt><dd>(TLS1.0)-(RSA)-(AES-128-CBC)-(SHA1)</dd>
     1<dt>Using TLS:</dt><dd>yes</dd>
     2<dt>Current TLS session:</dt><dd>(TLS1.0)-(RSA)-(AES-128-CBC)-(SHA1)</dd>
    33</dl>
    44</body></html>
Note: See TracChangeset for help on using the changeset viewer.