]> granicus.if.org Git - apache/commitdiff
Merge r1420184 from trunk:
authorJoe Orton <jorton@apache.org>
Sat, 23 May 2015 10:16:25 +0000 (10:16 +0000)
committerJoe Orton <jorton@apache.org>
Sat, 23 May 2015 10:16:25 +0000 (10:16 +0000)
* modules/aaa/mod_authz_owner.h: Add header file with optional hook
  declaration for "authz_owner_get_file_group".

* modules/aaa/mod_authz_dbm.c, modules/aaa/mod_authz_groupfile.c: Use
  the header to pick up the above declaration; retrieve the optional
  function in a hook; use a static variable to store the function
  pointer.

Submitted by: jorton
Reviewed by: jkaluza, wrowe, jorton

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1681311 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/aaa/mod_authz_dbm.c
modules/aaa/mod_authz_groupfile.c
modules/aaa/mod_authz_owner.c
modules/aaa/mod_authz_owner.h [new file with mode: 0644]

diff --git a/CHANGES b/CHANGES
index 3266a62377b9a9044e88e129c79291197506c3e6..7d39261e6caadbe20f55245b6b25a416094e88e6 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -12,6 +12,9 @@ Changes with Apache 2.4.13
      calls r:wsupgrade() can cause a child process crash. 
      [Edward Lu <Chaosed0 gmail.com>]
 
+  *) mod_authz_dbm: Fix crashes when "dbm-file-group" is used and
+     authz modules were loaded in the "wrong" order.  [Joe Orton]
+
   *) mod_authn_dbd, mod_authz_dbd, mod_session_dbd, mod_rewrite: Fix lifetime
      of DB lookup entries independently of the selected DB engine.  PR 46421.
      [Steven whitson <steven.whitson gmail com>, Jan Kaluza, Yann Ylavic].
index c329eacd340549d0122caacdfab1e1c952b0bd21..843d9a8e43f9c6cf68714541afdc1a9cf6c78aaf 100644 (file)
 #include "http_request.h"   /* for ap_hook_(check_user_id | auth_checker)*/
 
 #include "mod_auth.h"
+#include "mod_authz_owner.h"
 
 typedef struct {
     const char *grpfile;
     const char *dbmtype;
 } authz_dbm_config_rec;
 
-APR_DECLARE_OPTIONAL_FN(char*, authz_owner_get_file_group, (request_rec *r));
-
 
 /* This should go into APR; perhaps with some nice
  * caching/locking/flocking of the open dbm file.
@@ -212,7 +211,7 @@ static authz_status dbmgroup_check_authorization(request_rec *r,
     return AUTHZ_DENIED;
 }
 
-APR_OPTIONAL_FN_TYPE(authz_owner_get_file_group) *authz_owner_get_file_group;
+static APR_OPTIONAL_FN_TYPE(authz_owner_get_file_group) *authz_owner_get_file_group;
 
 static authz_status dbmfilegroup_check_authorization(request_rec *r,
                                                      const char *require_args,
@@ -307,11 +306,13 @@ static const authz_provider authz_dbmfilegroup_provider =
     NULL,
 };
 
-
-static void register_hooks(apr_pool_t *p)
+static void authz_dbm_getfns(void)
 {
     authz_owner_get_file_group = APR_RETRIEVE_OPTIONAL_FN(authz_owner_get_file_group);
+}
 
+static void register_hooks(apr_pool_t *p)
+{
     ap_register_auth_provider(p, AUTHZ_PROVIDER_GROUP, "dbm-group",
                               AUTHZ_PROVIDER_VERSION,
                               &authz_dbmgroup_provider,
@@ -320,6 +321,7 @@ static void register_hooks(apr_pool_t *p)
                               AUTHZ_PROVIDER_VERSION,
                               &authz_dbmfilegroup_provider,
                               AP_AUTH_INTERNAL_PER_CONF);
+    ap_hook_optional_fn_retrieve(authz_dbm_getfns, NULL, NULL, APR_HOOK_MIDDLE);
 }
 
 AP_DECLARE_MODULE(authz_dbm) =
index cd7d3f0e0a0bbc8a1c1928fed454e691fb4f8182..e1df12918a6d1a5d139b3345517d59cd12ab066c 100644 (file)
 #include "util_varbuf.h"
 
 #include "mod_auth.h"
+#include "mod_authz_owner.h"
 
 typedef struct {
     char *groupfile;
 } authz_groupfile_config_rec;
 
-APR_DECLARE_OPTIONAL_FN(char*, authz_owner_get_file_group, (request_rec *r));
-
 static void *create_authz_groupfile_dir_config(apr_pool_t *p, char *d)
 {
     authz_groupfile_config_rec *conf = apr_palloc(p, sizeof(*conf));
@@ -203,7 +202,7 @@ static authz_status group_check_authorization(request_rec *r,
     return AUTHZ_DENIED;
 }
 
-APR_OPTIONAL_FN_TYPE(authz_owner_get_file_group) *authz_owner_get_file_group;
+static APR_OPTIONAL_FN_TYPE(authz_owner_get_file_group) *authz_owner_get_file_group;
 
 static authz_status filegroup_check_authorization(request_rec *r,
                                                   const char *require_args,
@@ -301,10 +300,14 @@ static const authz_provider authz_filegroup_provider =
     NULL,
 };
 
-static void register_hooks(apr_pool_t *p)
+
+static void authz_groupfile_getfns(void)
 {
     authz_owner_get_file_group = APR_RETRIEVE_OPTIONAL_FN(authz_owner_get_file_group);
+}
 
+static void register_hooks(apr_pool_t *p)
+{
     ap_register_auth_provider(p, AUTHZ_PROVIDER_GROUP, "group",
                               AUTHZ_PROVIDER_VERSION,
                               &authz_group_provider,
@@ -313,6 +316,7 @@ static void register_hooks(apr_pool_t *p)
                               AUTHZ_PROVIDER_VERSION,
                               &authz_filegroup_provider,
                               AP_AUTH_INTERNAL_PER_CONF);
+    ap_hook_optional_fn_retrieve(authz_groupfile_getfns, NULL, NULL, APR_HOOK_MIDDLE);
 }
 
 AP_DECLARE_MODULE(authz_groupfile) =
index 66b31d6a502fa8ba58cbfb3122fda5306d3035cc..4fd0b2a015d460832cb3c1e245272db2be35db6d 100644 (file)
@@ -28,8 +28,7 @@
 #include "http_request.h"
 
 #include "mod_auth.h"
-
-APR_DECLARE_OPTIONAL_FN(char*, authz_owner_get_file_group, (request_rec *r));
+#include "mod_authz_owner.h"
 
 static const command_rec authz_owner_cmds[] =
 {
diff --git a/modules/aaa/mod_authz_owner.h b/modules/aaa/mod_authz_owner.h
new file mode 100644 (file)
index 0000000..799f336
--- /dev/null
@@ -0,0 +1,27 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MOD_AUTHZ_OWNER_H
+#define MOD_AUTHZ_OWNER_H
+
+#include "http_request.h"
+
+/* mod_authz_owner exports an optional function which retrieves the
+ * group name of the file identified by r->filename, if available, or
+ * else returns NULL. */
+APR_DECLARE_OPTIONAL_FN(char*, authz_owner_get_file_group, (request_rec *r));
+
+#endif /* MOD_AUTHZ_OWNER_H */