Changeset 235e109 in mod_gnutls


Ignore:
Timestamp:
Apr 9, 2018, 2:24:59 AM (20 months ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
debian/master, debian/stretch-backports, master, upstream
Children:
23e98b3
Parents:
fe21671
Message:

Unify initialization of mod_gnutls connection context

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/gnutls_hooks.c

    rfe21671 r235e109  
    2222#include "gnutls_cache.h"
    2323#include "gnutls_ocsp.h"
     24#include "gnutls_util.h"
    2425#include "http_vhost.h"
    2526#include "ap_mpm.h"
     
    957958static void create_gnutls_handle(conn_rec * c)
    958959{
    959     /* Get mod_gnutls server configuration */
    960     mgs_srvconf_rec *sc = (mgs_srvconf_rec *)
    961             ap_get_module_config(c->base_server->module_config, &gnutls_module);
    962 
    963960    _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__);
    964961
    965962    /* Get connection specific configuration */
    966     mgs_handle_t *ctxt = (mgs_handle_t *) ap_get_module_config(c->conn_config, &gnutls_module);
    967     if (ctxt == NULL)
    968     {
    969         ctxt = apr_pcalloc(c->pool, sizeof (*ctxt));
    970         ap_set_module_config(c->conn_config, &gnutls_module, ctxt);
    971         ctxt->is_proxy = GNUTLS_ENABLED_FALSE;
    972     }
     963    mgs_handle_t *ctxt = init_gnutls_ctxt(c);
    973964    ctxt->enabled = GNUTLS_ENABLED_TRUE;
    974     ctxt->c = c;
    975     ctxt->sc = sc;
    976965    ctxt->status = 0;
    977966    ctxt->input_rc = APR_SUCCESS;
  • src/gnutls_util.c

    rfe21671 r235e109  
    126126    return rv;
    127127}
     128
     129
     130
     131mgs_handle_t *init_gnutls_ctxt(conn_rec *c)
     132{
     133    mgs_handle_t *ctxt = (mgs_handle_t *)
     134        ap_get_module_config(c->conn_config, &gnutls_module);
     135    if (ctxt == NULL)
     136    {
     137        ctxt = apr_pcalloc(c->pool, sizeof (*ctxt));
     138        ap_set_module_config(c->conn_config, &gnutls_module, ctxt);
     139
     140        /* Get mod_gnutls server configuration */
     141        mgs_srvconf_rec *sc = (mgs_srvconf_rec *)
     142            ap_get_module_config(c->base_server->module_config,
     143                                 &gnutls_module);
     144
     145        /* Set up connection and server references */
     146        ctxt->c = c;
     147        ctxt->sc = sc;
     148        /* Default, unconditionally changed in proxy setup functions */
     149        ctxt->is_proxy = GNUTLS_ENABLED_FALSE;
     150    }
     151    return ctxt;
     152}
  • src/gnutls_util.h

    rfe21671 r235e109  
    2121#include <apr_uri.h>
    2222#include <gnutls/gnutls.h>
     23#include "mod_gnutls.h"
    2324
    2425#ifndef __MOD_GNUTLS_UTIL_H__
     
    6768    __attribute__((nonnull));
    6869
     70/**
     71 * Allocate the connection configuration structure if necessary, set
     72 * some defaults.
     73 */
     74mgs_handle_t *init_gnutls_ctxt(conn_rec *c);
     75
    6976#endif /* __MOD_GNUTLS_UTIL_H__ */
  • src/mod_gnutls.c

    rfe21671 r235e109  
    2020#include "mod_gnutls.h"
    2121#include "gnutls_ocsp.h"
     22#include "gnutls_util.h"
    2223
    2324#ifdef APLOG_USE_MODULE
     
    107108
    108109    /* disable TLS for this connection */
    109     mgs_handle_t *ctxt = (mgs_handle_t *)
    110         ap_get_module_config(c->conn_config, &gnutls_module);
    111     if (ctxt == NULL)
    112     {
    113         ctxt = apr_pcalloc(c->pool, sizeof (*ctxt));
    114         ap_set_module_config(c->conn_config, &gnutls_module, ctxt);
    115     }
     110    mgs_handle_t *ctxt = init_gnutls_ctxt(c);
    116111    ctxt->enabled = GNUTLS_ENABLED_FALSE;
    117112    ctxt->is_proxy = GNUTLS_ENABLED_TRUE;
     
    139134
    140135    /* enable TLS for this connection */
    141     mgs_handle_t *ctxt = (mgs_handle_t *)
    142         ap_get_module_config(c->conn_config, &gnutls_module);
    143     if (ctxt == NULL)
    144     {
    145         ctxt = apr_pcalloc(c->pool, sizeof (*ctxt));
    146         ap_set_module_config(c->conn_config, &gnutls_module, ctxt);
    147     }
     136    mgs_handle_t *ctxt = init_gnutls_ctxt(c);
    148137    ctxt->enabled = GNUTLS_ENABLED_TRUE;
    149138    ctxt->is_proxy = GNUTLS_ENABLED_TRUE;
Note: See TracChangeset for help on using the changeset viewer.