httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chr...@apache.org
Subject svn commit: r709751 - /httpd/httpd/trunk/modules/aaa/mod_authz_core.c
Date Sat, 01 Nov 2008 18:58:50 GMT
Author: chrisd
Date: Sat Nov  1 11:58:49 2008
New Revision: 709751

URL: http://svn.apache.org/viewvc?rev=709751&view=rev
Log:
remove unused variables, rename some variables, move and change
variable initializations, etc., prior to larger changes

Modified:
    httpd/httpd/trunk/modules/aaa/mod_authz_core.c

Modified: httpd/httpd/trunk/modules/aaa/mod_authz_core.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/aaa/mod_authz_core.c?rev=709751&r1=709750&r2=709751&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/aaa/mod_authz_core.c (original)
+++ httpd/httpd/trunk/modules/aaa/mod_authz_core.c Sat Nov  1 11:58:49 2008
@@ -116,8 +116,7 @@
 
 static void *create_authz_core_dir_config(apr_pool_t *p, char *dummy)
 {
-    authz_core_dir_conf *conf =
-            (authz_core_dir_conf *)apr_pcalloc(p, sizeof(authz_core_dir_conf));
+    authz_core_dir_conf *conf = apr_pcalloc(p, sizeof(*conf));
 
     conf->req_state = BASE_REQ_STATE;
     conf->req_state_level = BASE_REQ_LEVEL;
@@ -125,7 +124,7 @@
     return (void *)conf;
 }
 
-static void *merge_authz_core_dir_config(apr_pool_t *a,
+static void *merge_authz_core_dir_config(apr_pool_t *p,
                                          void *basev, void *newv)
 {
     authz_core_dir_conf *base = (authz_core_dir_conf *)basev;
@@ -135,7 +134,7 @@
     /* Create this conf by duplicating the base, replacing elements
     * (or creating copies for merging) where new-> values exist.
     */
-    conf = (authz_core_dir_conf *)apr_pmemdup(a, base, sizeof(authz_core_dir_conf));
+    conf = (authz_core_dir_conf *)apr_pmemdup(p, base, sizeof(authz_core_dir_conf));
 
     /* Wipe out the providers and rejects lists so that
         they can be recreated by the merge process. */
@@ -144,10 +143,10 @@
     /* Only merge the base providers in if the merge_rules
         directive has been set. */
     if (base->providers && new->merge_rules) {
-        walk_merge_provider_list (a, conf, base->providers);
+        walk_merge_provider_list (p, conf, base->providers);
     }
     if (new->providers) {
-        walk_merge_provider_list (a, conf, new->providers);
+        walk_merge_provider_list (p, conf, new->providers);
     }
 
     return (void*)conf;
@@ -158,7 +157,7 @@
 
     authz_core_srv_conf *authcfg;
 
-    authcfg = (authz_core_srv_conf *) apr_pcalloc(p, sizeof(authz_core_srv_conf));
+    authcfg = apr_pcalloc(p, sizeof(*authcfg));
     authcfg->alias_rec = apr_hash_make(p);
 
     return (void *)authcfg;
@@ -170,7 +169,7 @@
 static authz_status authz_alias_check_authorization(request_rec *r,
                                                     const char *require_args)
 {
-    const char *provider_name = apr_table_get(r->notes, AUTHZ_PROVIDER_NAME_NOTE);
+    const char *provider_name;
     authz_status ret = AUTHZ_DENIED;
 
     /* Look up the provider alias in the alias list.
@@ -179,6 +178,8 @@
      * return the result of the above function call
      */
 
+    provider_name = apr_table_get(r->notes, AUTHZ_PROVIDER_NAME_NOTE);
+
     if (provider_name) {
         authz_core_srv_conf *authcfg;
         provider_alias_rec *prvdraliasrec;
@@ -214,14 +215,13 @@
 };
 
 static const char *authz_require_alias_section(cmd_parms *cmd, void *mconfig,
-                                               const char *arg)
+                                               const char *args)
 {
-    const char *endp = ap_strrchr_c(arg, '>');
-    const char *args;
+    const char *endp = ap_strrchr_c(args, '>');
     char *provider_name;
     char *provider_alias;
     char *provider_args;
-    ap_conf_vector_t *new_authz_config = ap_create_per_dir_config(cmd->pool);
+    ap_conf_vector_t *new_authz_config;
     int old_overrides = cmd->override;
     const char *errmsg;
 
@@ -235,7 +235,7 @@
                            "> directive missing closing '>'", NULL);
     }
 
-    args = apr_pstrndup(cmd->pool, arg, endp - arg);
+    args = apr_pstrndup(cmd->pool, args, endp - args);
 
     if (!args[0]) {
         return apr_pstrcat(cmd->pool, cmd->cmd->name,
@@ -252,24 +252,28 @@
                            "> directive requires additional arguments", NULL);
     }
 
+    new_authz_config = ap_create_per_dir_config(cmd->pool);
+
     /* Walk the subsection configuration to get the per_dir config that we will
      * merge just before the real provider is called.
      */
     cmd->override = OR_ALL|ACCESS_CONF;
     errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_authz_config);
+    cmd->override = old_overrides;
 
     if (!errmsg) {
-        provider_alias_rec *prvdraliasrec = apr_pcalloc(cmd->pool,
-                                                        sizeof(provider_alias_rec));
+        provider_alias_rec *prvdraliasrec;
         authz_core_srv_conf *authcfg;
 
+        prvdraliasrec = apr_pcalloc(cmd->pool, sizeof(*prvdraliasrec));
+
         /* Save off the new directory config along with the original
          * provider name and function pointer data
          */
-        prvdraliasrec->sec_auth = new_authz_config;
         prvdraliasrec->provider_name = provider_name;
         prvdraliasrec->provider_alias = provider_alias;
         prvdraliasrec->provider_args = provider_args;
+        prvdraliasrec->sec_auth = new_authz_config;
         prvdraliasrec->provider =
             ap_lookup_provider(AUTHZ_PROVIDER_GROUP, provider_name,
                                AUTHZ_PROVIDER_VERSION);
@@ -296,8 +300,6 @@
                                   AP_AUTH_INTERNAL_PER_CONF);
     }
 
-    cmd->override = old_overrides;
-
     return errmsg;
 }
 
@@ -490,7 +492,7 @@
 }
 
 static const char *add_authz_provider(cmd_parms *cmd, void *config,
-                                      const char *arg)
+                                      const char *args)
 {
     authz_core_dir_conf *conf = (authz_core_dir_conf*)config;
     authz_provider_list *newp;
@@ -498,7 +500,7 @@
 
     newp = apr_pcalloc(cmd->pool, sizeof(authz_provider_list));
 
-    t = arg;
+    t = args;
     w = ap_getword_white(cmd->pool, &t);
 
     if (w)
@@ -536,12 +538,11 @@
     return merge_authz_provider(conf, newp);
 }
 
-static const char *authz_require_section(cmd_parms *cmd,
-                                         void *mconfig, const char *arg)
+static const char *add_authz_section(cmd_parms *cmd, void *mconfig,
+                                     const char *args)
 {
-    authz_core_dir_conf *conf = (authz_core_dir_conf*)mconfig;
-    const char *endp = ap_strrchr_c(arg, '>');
-    const char *args;
+    authz_core_dir_conf *conf = mconfig;
+    const char *endp = ap_strrchr_c(args, '>');
     authz_request_state old_reqstate;
     int old_overrides = cmd->override;
     const char *errmsg;
@@ -551,7 +552,7 @@
                            "> directive missing closing '>'", NULL);
     }
 
-    args = apr_pstrndup(cmd->pool, arg, endp - arg);
+    args = apr_pstrndup(cmd->pool, args, endp - args);
 
     if (args[0]) {
         return apr_pstrcat(cmd->pool, cmd->cmd->name,
@@ -598,10 +599,10 @@
     AP_INIT_RAW_ARGS("<RequireAlias", authz_require_alias_section, NULL, RSRC_CONF,
                      "Container for authorization directives grouped under "
                      "an authz provider alias"),
-    AP_INIT_RAW_ARGS("<SatisfyAll", authz_require_section, NULL, OR_AUTHCFG,
+    AP_INIT_RAW_ARGS("<SatisfyAll", add_authz_section, NULL, OR_AUTHCFG,
                      "Container for grouping require statements that must all "
                      "succeed for authorization to be granted"),
-    AP_INIT_RAW_ARGS("<SatisfyOne", authz_require_section, NULL, OR_AUTHCFG,
+    AP_INIT_RAW_ARGS("<SatisfyOne", add_authz_section, NULL, OR_AUTHCFG,
                      "Container for grouping require statements of which one "
                      "must succeed for authorization to be granted"),
     AP_INIT_FLAG("AuthzMergeRules", ap_set_flag_slot,
@@ -828,7 +829,6 @@
 {
     authz_core_dir_conf *conf;
     authz_provider_list *current_provider;
-    int req_authz = 0;
 
     conf = ap_get_module_config(r->per_dir_config, &authz_core_module);
 
@@ -839,14 +839,13 @@
         /* Does this provider config apply for this method */
         if (current_provider->method_mask &
                 (AP_METHOD_BIT << r->method_number)) {
-            req_authz = 1;
-            break;
+            return 1;
         }
 
         current_provider = current_provider->one_next;
     }
 
-    return req_authz;
+    return 0;
 }
 
 static void register_hooks(apr_pool_t *p)



Mime
View raw message