Changeset 63468af in mod_gnutls for src/gnutls_hooks.c


Ignore:
Timestamp:
Apr 16, 2016, 11:14:26 AM (4 years ago)
Author:
Daniel Kahn Gillmor <dkg@…>
Branches:
debian/master, debian/stretch-backports, jessie-backports, upstream
Children:
b586b27, ce12806
Parents:
02c8e54 (diff), c6cfe6e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Imported Upstream version 0.7.4

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gnutls_hooks.c

    r02c8e54 r63468af  
    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);
    1677         if (ctxt && ctxt->session != NULL) {
    1678 #if GNUTLS_VERSION_MAJOR < 3
    1679             ap_rprintf(r, "<dt>This TLS Session:</dt><dd>%s</dd>\n",
    1680                 gnutls_cipher_suite_get_name(gnutls_kx_get(ctxt->session),
    1681                 gnutls_cipher_get(ctxt->session),
    1682                 gnutls_mac_get(ctxt->session)));
    1683 #else
    1684             char* z = NULL;
    1685             z = gnutls_session_get_desc(ctxt->session);
    1686             if (z) {
    1687                 ap_rprintf(r, "<dt>This TLS Session:</dt><dd>%s</dd>\n", z);
    1688                 gnutls_free(z);
     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);
     1705        if (ctxt && ctxt->session != NULL)
     1706        {
     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);
    16891716            }
    1690 #endif
    1691         }
    1692     }
    1693 
    1694     ap_rputs("</dl>\n", r);
     1717        }
     1718    }
     1719
     1720    if (!(flags & AP_STATUS_SHORT))
     1721        ap_rputs("</dl>\n", r);
     1722
    16951723    return OK;
    16961724}
Note: See TracChangeset for help on using the changeset viewer.