You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jo...@apache.org on 2012/12/11 15:13:47 UTC

svn commit: r1420184 - in /httpd/httpd/trunk/modules/aaa: mod_authz_dbm.c mod_authz_groupfile.c mod_authz_owner.c mod_authz_owner.h

Author: jorton
Date: Tue Dec 11 14:13:44 2012
New Revision: 1420184

URL: http://svn.apache.org/viewvc?rev=1420184&view=rev
Log:
* 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.

Added:
    httpd/httpd/trunk/modules/aaa/mod_authz_owner.h
Modified:
    httpd/httpd/trunk/modules/aaa/mod_authz_dbm.c
    httpd/httpd/trunk/modules/aaa/mod_authz_groupfile.c
    httpd/httpd/trunk/modules/aaa/mod_authz_owner.c

Modified: httpd/httpd/trunk/modules/aaa/mod_authz_dbm.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/aaa/mod_authz_dbm.c?rev=1420184&r1=1420183&r2=1420184&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/aaa/mod_authz_dbm.c (original)
+++ httpd/httpd/trunk/modules/aaa/mod_authz_dbm.c Tue Dec 11 14:13:44 2012
@@ -29,14 +29,13 @@
 #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.
@@ -199,7 +198,7 @@ static authz_status dbmgroup_check_autho
     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,
@@ -279,11 +278,13 @@ static const authz_provider authz_dbmfil
     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,
@@ -292,6 +293,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) =

Modified: httpd/httpd/trunk/modules/aaa/mod_authz_groupfile.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/aaa/mod_authz_groupfile.c?rev=1420184&r1=1420183&r2=1420184&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/aaa/mod_authz_groupfile.c (original)
+++ httpd/httpd/trunk/modules/aaa/mod_authz_groupfile.c Tue Dec 11 14:13:44 2012
@@ -55,13 +55,12 @@
 #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));
@@ -200,7 +199,7 @@ static authz_status group_check_authoriz
     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,
@@ -279,10 +278,14 @@ static const authz_provider authz_filegr
     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,
@@ -291,6 +294,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) =

Modified: httpd/httpd/trunk/modules/aaa/mod_authz_owner.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/aaa/mod_authz_owner.c?rev=1420184&r1=1420183&r2=1420184&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/aaa/mod_authz_owner.c (original)
+++ httpd/httpd/trunk/modules/aaa/mod_authz_owner.c Tue Dec 11 14:13:44 2012
@@ -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[] =
 {

Added: httpd/httpd/trunk/modules/aaa/mod_authz_owner.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/aaa/mod_authz_owner.h?rev=1420184&view=auto
==============================================================================
--- httpd/httpd/trunk/modules/aaa/mod_authz_owner.h (added)
+++ httpd/httpd/trunk/modules/aaa/mod_authz_owner.h Tue Dec 11 14:13:44 2012
@@ -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 */