From: Jim Jagielski Date: Sat, 9 Nov 2013 14:36:18 +0000 (+0000) Subject: Merge r1531961 from trunk: X-Git-Tag: 2.4.7~74 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=99e0e1330695eb3e3933e7641a5cf8bec01a104d;p=apache Merge r1531961 from trunk: Support optional initialization arguments for socache providers in mod_authn_socache. Submitted by: chrisd Reviewed/backported by: jim git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1540312 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 82d56dce00..c8801cb578 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.4.7 + *) mod_authn_socache: Support optional initialization arguments for + socache providers. [Chris Darroch] + *) mod_session: Reset the max-age on session save. PR 47476. [Alexey Varlamov ] diff --git a/STATUS b/STATUS index f1e38ba4d1..cc5e3952d2 100644 --- a/STATUS +++ b/STATUS @@ -97,11 +97,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * mod_authn_socache: Support optional arguments for socache provider. - trunk patch: http://svn.apache.org/r1531961 - 2.4.x patch: trunk patch works, modulo CHANGES and doc compatibility note - +1: chrisd, covener, jim - * mod_headers: Allow for format specifiers to be used in the base substitution string when using Header edit trunk patch: http://people.apache.org/~druggeri/patches/HeaderEditENV.trunk.patch diff --git a/docs/manual/mod/mod_authn_socache.xml b/docs/manual/mod/mod_authn_socache.xml index 97cdeca380..93fdc8e183 100644 --- a/docs/manual/mod/mod_authn_socache.xml +++ b/docs/manual/mod/mod_authn_socache.xml @@ -113,16 +113,17 @@ the load on backends AuthnCacheSOCache Select socache backend provider to use -AuthnCacheSOCache provider-name +AuthnCacheSOCache provider-name[:provider-args] server config None

This is a server-wide setting to select a provider for the - shared object cache. - Values are "dbm", "dc", "memcache", or "shmcb", each subject to the - appropriate module being loaded. If not set, your platform's - default will be used.

+ shared object cache, followed by + optional arguments for that provider. + Some possible values for provider-name are "dbm", "dc", + "memcache", or "shmcb", each subject to the appropriate module + being loaded. If not set, your platform's default will be used.

diff --git a/modules/aaa/mod_authn_socache.c b/modules/aaa/mod_authn_socache.c index cccd076b02..f36d49c8ed 100644 --- a/modules/aaa/mod_authn_socache.c +++ b/modules/aaa/mod_authn_socache.c @@ -40,7 +40,7 @@ typedef struct authn_cache_dircfg { const char *context; } authn_cache_dircfg; -/* FIXME: figure out usage of socache create vs init +/* FIXME: * I think the cache and mutex should be global */ static apr_global_mutex_t *authn_cache_mutex = NULL; @@ -86,7 +86,6 @@ static int authn_cache_post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptmp, server_rec *s) { apr_status_t rv; - const char *errmsg; static struct ap_socache_hints authn_cache_hints = {64, 32, 60000000}; if (!configured) { @@ -109,12 +108,6 @@ static int authn_cache_post_config(apr_pool_t *pconf, apr_pool_t *plog, } apr_pool_cleanup_register(pconf, NULL, remove_lock, apr_pool_cleanup_null); - errmsg = socache_provider->create(&socache_instance, NULL, ptmp, pconf); - if (errmsg) { - ap_log_perror(APLOG_MARK, APLOG_CRIT, rv, plog, APLOGNO(01676) "%s", errmsg); - return 500; /* An HTTP status would be a misnomer! */ - } - rv = socache_provider->init(socache_instance, authn_cache_id, &authn_cache_hints, s, pconf); if (rv != APR_SUCCESS) { @@ -144,9 +137,22 @@ static const char *authn_cache_socache(cmd_parms *cmd, void *CFG, const char *arg) { const char *errmsg = ap_check_cmd_context(cmd, GLOBAL_ONLY); + const char *sep, *name; + if (errmsg) return errmsg; - socache_provider = ap_lookup_provider(AP_SOCACHE_PROVIDER_GROUP, arg, + + /* Argument is of form 'name:args' or just 'name'. */ + sep = ap_strchr_c(arg, ':'); + if (sep) { + name = apr_pstrmemdup(cmd->pool, arg, sep - arg); + sep++; + } + else { + name = arg; + } + + socache_provider = ap_lookup_provider(AP_SOCACHE_PROVIDER_GROUP, name, AP_SOCACHE_PROVIDER_VERSION); if (socache_provider == NULL) { errmsg = apr_psprintf(cmd->pool, @@ -154,6 +160,14 @@ static const char *authn_cache_socache(cmd_parms *cmd, void *CFG, "to load the appropriate socache module " "(mod_socache_%s?)", arg, arg); } + else { + errmsg = socache_provider->create(&socache_instance, sep, + cmd->temp_pool, cmd->pool); + } + + if (errmsg) { + errmsg = apr_psprintf(cmd->pool, "AuthnCacheSOCache: %s", errmsg); + } return errmsg; }