]> granicus.if.org Git - apache/commitdiff
Merge r1531961 from trunk:
authorJim Jagielski <jim@apache.org>
Sat, 9 Nov 2013 14:36:18 +0000 (14:36 +0000)
committerJim Jagielski <jim@apache.org>
Sat, 9 Nov 2013 14:36:18 +0000 (14:36 +0000)
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

CHANGES
STATUS
docs/manual/mod/mod_authn_socache.xml
modules/aaa/mod_authn_socache.c

diff --git a/CHANGES b/CHANGES
index 82d56dce0016cfd815883fbd31618e2d4dde3c23..c8801cb5781a1d65894b77c06106d92976f0027e 100644 (file)
--- 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 <alexey.v.varlamov gmail com>]
 
diff --git a/STATUS b/STATUS
index f1e38ba4d112f97db11f8d6eaa017b85b362b1c7..cc5e3952d2fcee2a7ec6014588fb8eb67d438e26 100644 (file)
--- 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
index 97cdeca380738ac569e0758131917bffa8d8e37b..93fdc8e1830b3d69987ab99b52dcbc1bc4795192 100644 (file)
@@ -113,16 +113,17 @@ the load on backends</description>
 <directivesynopsis>
 <name>AuthnCacheSOCache</name>
 <description>Select socache backend provider to use</description>
-<syntax>AuthnCacheSOCache <var>provider-name</var></syntax>
+<syntax>AuthnCacheSOCache <var>provider-name[:provider-args]</var></syntax>
 <contextlist><context>server config</context></contextlist>
 <override>None</override>
 
 <usage>
     <p>This is a server-wide setting to select a provider for the
-    <a href="../socache.html">shared object cache</a>.
-    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.</p>
+    <a href="../socache.html">shared object cache</a>, followed by
+    optional arguments for that provider.
+    Some possible values for <var>provider-name</var> are "dbm", "dc",
+    "memcache", or "shmcb", each subject to the appropriate module
+    being loaded.  If not set, your platform's default will be used.</p>
 </usage>
 </directivesynopsis>
 
index cccd076b0220e44560f978ee8ca1d1baba92b0e7..f36d49c8eddd421379640e7963a571a9ca6e5b9a 100644 (file)
@@ -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;
 }