diff options
author | Joe Orton <jorton@apache.org> | 2008-02-25 21:09:38 +0100 |
---|---|---|
committer | Joe Orton <jorton@apache.org> | 2008-02-25 21:09:38 +0100 |
commit | 09e2a2f67a00a5102a988f3c3030dc887e27b7fe (patch) | |
tree | e8df105a7bbbcefdff9117ec29eb38d6e3bf310b /modules/ssl/ssl_engine_config.c | |
parent | * modules/ssl/ssl_engine_init.c (ssl_init_FindCAList): Cast return (diff) | |
download | apache2-09e2a2f67a00a5102a988f3c3030dc887e27b7fe.tar.xz apache2-09e2a2f67a00a5102a988f3c3030dc887e27b7fe.zip |
Session cache interface redesign, Part 4:
Move provider-specific configuration handling down into the provider
code. Eliminate all use of SSLModConfigRec within provider code.
* modules/ssl/ssl_private.h (modssl_sesscache_provider): Add 'create'
function which creates and configures the cache provider, before
initialisation. Change 'init' function to take the context pointer
as an input parameter, and reorder to be first.
* modules/ssl/ssl_scache.c (ssl_scache_init): Adjust accordingly.
* modules/ssl/ssl_scache_memcache.c (struct context): Add servers
field.
(ssl_scache_mc_create): New function.
(ssl_scache_mc_init): Use servers from context not SSLModConfigRec.
* modules/ssl/ssl_scache_dbm.c (struct context): Define.
(ssl_scache_dbm_create): New function.
(ssl_scache_dbm_init, ssl_scache_dbm_kill): Adjust to use filename
and pool from context.
(ssl_scache_dbm_store, ssl_scache_dbm_retrieve,
ssl_scache_dbm_status): Use filename from context. Use context pool
for temp storage of the DBM object, and clear before use.
(ssl_scache_dbm_expire): Remove static tLast; use last_expiry from
context. Use context pool for temp storage and clear before use.
* modules/ssl/ssl_scache_dc.c (struct context): Add target field.
(ssl_scache_dc_init, ssl_scache_dc_status): Use target from context.
* modules/ssl/ssl_scache_shmcb.c (struct context): Add data_file,
shm_size fields.
(ssl_scache_shmcb_create): New function; moved argument parsing
logic from ssl_cmd_SSLSessionCache
(ssl_scache_shmcb_init, ssl_scache_shmcb_status): Use config from
context.
* modules/ssl/ssl_engine_config.c (ssl_config_global_create): Remove
handling of old provider-specific fields.
(ssl_cmd_SSLSessionCache): Call provider ->create function to parse
the argument and create provider-specific context structure.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@630974 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/ssl/ssl_engine_config.c')
-rw-r--r-- | modules/ssl/ssl_engine_config.c | 76 |
1 files changed, 15 insertions, 61 deletions
diff --git a/modules/ssl/ssl_engine_config.c b/modules/ssl/ssl_engine_config.c index 95a4663c6f..5194e454a7 100644 --- a/modules/ssl/ssl_engine_config.c +++ b/modules/ssl/ssl_engine_config.c @@ -59,8 +59,6 @@ SSLModConfigRec *ssl_config_global_create(server_rec *s) * initialize per-module configuration */ mc->nSessionCacheMode = SSL_SCMODE_UNSET; - mc->szSessionCacheDataFile = NULL; - mc->nSessionCacheDataSize = 0; mc->sesscache = NULL; mc->nMutexMode = SSL_MUTEXMODE_UNSET; mc->nMutexMech = APR_LOCK_DEFAULT; @@ -954,7 +952,6 @@ const char *ssl_cmd_SSLSessionCache(cmd_parms *cmd, { SSLModConfigRec *mc = myModConfig(cmd->server); const char *err, *colon; - char *cp, *cp2; int arglen = strlen(arg); if ((err = ap_check_cmd_context(cmd, GLOBAL_ONLY))) { @@ -967,21 +964,15 @@ const char *ssl_cmd_SSLSessionCache(cmd_parms *cmd, if (strcEQ(arg, "none")) { mc->nSessionCacheMode = SSL_SCMODE_NONE; - mc->szSessionCacheDataFile = NULL; } else if (strcEQ(arg, "nonenotnull")) { mc->nSessionCacheMode = SSL_SCMODE_NONE_NOT_NULL; - mc->szSessionCacheDataFile = NULL; } else if ((arglen > 4) && strcEQn(arg, "dbm:", 4)) { mc->nSessionCacheMode = SSL_SCMODE_DBM; mc->sesscache = &modssl_sesscache_dbm; - mc->szSessionCacheDataFile = ap_server_root_relative(mc->pPool, arg+4); - if (!mc->szSessionCacheDataFile) { - return apr_psprintf(cmd->pool, - "SSLSessionCache: Invalid cache file path %s", - arg+4); - } + err = mc->sesscache->create(&mc->sesscache_context, arg + 4, + cmd->pool, mc->pPool); } else if (((arglen > 4) && strcEQn(arg, "shm:", 4)) || ((arglen > 6) && strcEQn(arg, "shmht:", 6)) || @@ -992,74 +983,37 @@ const char *ssl_cmd_SSLSessionCache(cmd_parms *cmd, mc->nSessionCacheMode = SSL_SCMODE_SHMCB; mc->sesscache = &modssl_sesscache_shmcb; colon = ap_strchr_c(arg, ':'); - mc->szSessionCacheDataFile = - ap_server_root_relative(mc->pPool, colon+1); - if (!mc->szSessionCacheDataFile) { - return apr_psprintf(cmd->pool, - "SSLSessionCache: Invalid cache file path %s", - colon+1); - } - mc->nSessionCacheDataSize = 1024*512; /* 512KB */ - - if ((cp = strchr(mc->szSessionCacheDataFile, '('))) { - *cp++ = NUL; - - if (!(cp2 = strchr(cp, ')'))) { - return "SSLSessionCache: Invalid argument: " - "no closing parenthesis"; - } - - *cp2 = NUL; - - mc->nSessionCacheDataSize = atoi(cp); - - if (mc->nSessionCacheDataSize < 8192) { - return "SSLSessionCache: Invalid argument: " - "size has to be >= 8192 bytes"; - - } - - if (mc->nSessionCacheDataSize >= APR_SHM_MAXSIZE) { - return apr_psprintf(cmd->pool, - "SSLSessionCache: Invalid argument: " - "size has to be < %d bytes on this " - "platform", APR_SHM_MAXSIZE); - - } - } + err = mc->sesscache->create(&mc->sesscache_context, colon + 1, + cmd->pool, mc->pPool); } else if ((arglen > 3) && strcEQn(arg, "dc:", 3)) { #ifdef HAVE_DISTCACHE mc->nSessionCacheMode = SSL_SCMODE_DC; mc->sesscache = &modssl_sesscache_dc; - mc->szSessionCacheDataFile = apr_pstrdup(mc->pPool, arg+3); - if (!mc->szSessionCacheDataFile) { - return apr_pstrcat(cmd->pool, - "SSLSessionCache: Invalid cache file path: ", - arg+3, NULL); - } + err = mc->sesscache->create(&mc->sesscache_context, arg + 3, + cmd->pool, mc->pPool); #else - return "SSLSessionCache: distcache support disabled"; + err = "distcache support disabled"; #endif } else if ((arglen > 3) && strcEQn(arg, "memcache:", 9)) { #ifdef HAVE_SSL_CACHE_MEMCACHE mc->nSessionCacheMode = SSL_SCMODE_MC; mc->sesscache = &modssl_sesscache_mc; - mc->szSessionCacheDataFile = apr_pstrdup(mc->pPool, arg+9); - if (!mc->szSessionCacheDataFile) { - return apr_pstrcat(cmd->pool, - "SSLSessionCache: Invalid memcache config: ", - arg+9, NULL); - } + err = mc->sesscache->create(&mc->sesscache_context, arg + 9, + cmd->pool, mc->pPool); #else - return "SSLSessionCache: memcache support disabled"; + err = "memcache support disabled"; #endif } else { - return "SSLSessionCache: Invalid argument"; + err = "Invalid argument"; } + if (err) { + return apr_psprintf(cmd->pool, "SSLSessionCache: %s", err); + } + return NULL; } |