httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jaillet...@apache.org
Subject svn commit: r1733691 - /httpd/httpd/trunk/modules/aaa/mod_authz_dbd.c
Date Sat, 05 Mar 2016 07:15:56 GMT
Author: jailletc36
Date: Sat Mar  5 07:15:55 2016
New Revision: 1733691

URL: http://svn.apache.org/viewvc?rev=1733691&view=rev
Log:
Use ap_array_str_contains to simplify code
Remove a useless test (groups is always NULL)
Improve some style

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

Modified: httpd/httpd/trunk/modules/aaa/mod_authz_dbd.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/aaa/mod_authz_dbd.c?rev=1733691&r1=1733690&r2=1733691&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/aaa/mod_authz_dbd.c (original)
+++ httpd/httpd/trunk/modules/aaa/mod_authz_dbd.c Sat Mar  5 07:15:55 2016
@@ -61,6 +61,7 @@ static void *authz_dbd_cr_cfg(apr_pool_t
     ret->redirect = -1;
     return ret;
 }
+
 static void *authz_dbd_merge_cfg(apr_pool_t *pool, void *BASE, void *ADD)
 {
     authz_dbd_cfg *base = BASE;
@@ -73,6 +74,7 @@ static void *authz_dbd_merge_cfg(apr_poo
     ret->redirect = (add->redirect == -1) ? base->redirect : add->redirect;
     return ret;
 }
+
 static const char *authz_dbd_prepare(cmd_parms *cmd, void *cfg,
                                      const char *query)
 {
@@ -96,6 +98,7 @@ static const char *authz_dbd_prepare(cmd
     /* save the label here for our own use */
     return ap_set_string_slot(cmd, cfg, label);
 }
+
 static const command_rec authz_dbd_cmds[] = {
     AP_INIT_FLAG("AuthzDBDLoginToReferer", ap_set_flag_slot,
                  (void*)APR_OFFSETOF(authz_dbd_cfg, redirect), ACCESS_CONF,
@@ -265,9 +268,9 @@ static authz_status dbdgroup_check_autho
                                                  const char *require_args,
                                                  const void *parsed_require_args)
 {
-    int i, rv;
+    int rv;
     const char *w;
-    apr_array_header_t *groups = NULL;
+    apr_array_header_t *groups;
 
     const char *err = NULL;
     const ap_expr_info_t *expr = parsed_require_args;
@@ -281,12 +284,10 @@ static authz_status dbdgroup_check_autho
         return AUTHZ_DENIED_NO_USER;
     }
 
-    if (groups == NULL) {
-        groups = apr_array_make(r->pool, 4, sizeof(const char*));
-        rv = authz_dbd_group_query(r, cfg, groups);
-        if (rv != OK) {
-            return AUTHZ_GENERAL_ERROR;
-        }
+    groups = apr_array_make(r->pool, 4, sizeof(const char*));
+    rv = authz_dbd_group_query(r, cfg, groups);
+    if (rv != OK) {
+        return AUTHZ_GENERAL_ERROR;
     }
 
     require = ap_expr_str_exec(r, expr, &err);
@@ -300,10 +301,8 @@ static authz_status dbdgroup_check_autho
     t = require;
     while (t[0]) {
         w = ap_getword_white(r->pool, &t);
-        for (i=0; i < groups->nelts; ++i) {
-            if (!strcmp(w, ((const char**)groups->elts)[i])) {
-                return AUTHZ_GRANTED;
-            }
+        if (ap_array_str_contains(groups, w)) {
+            return AUTHZ_GRANTED;
         }
     }
 
@@ -339,18 +338,19 @@ static authz_status dbdlogout_check_auth
 }
 
 static const char *dbd_parse_config(cmd_parms *cmd, const char *require_line,
-                                     const void **parsed_require_line)
+                                    const void **parsed_require_line)
 {
     const char *expr_err = NULL;
     ap_expr_info_t *expr;
 
     expr = ap_expr_parse_cmd(cmd, require_line, AP_EXPR_FLAG_STRING_RESULT,
-            &expr_err, NULL);
+                             &expr_err, NULL);
 
-    if (expr_err)
+    if (expr_err) {
         return apr_pstrcat(cmd->temp_pool,
                            "Cannot parse expression in require line: ",
                            expr_err, NULL);
+    }
 
     *parsed_require_line = expr;
 
@@ -369,7 +369,6 @@ static const authz_provider authz_dbdlog
     NULL,
 };
 
-
 static const authz_provider authz_dbdlogout_provider =
 {
     &dbdlogout_check_authorization,
@@ -402,4 +401,3 @@ AP_DECLARE_MODULE(authz_dbd) =
     authz_dbd_cmds,
     authz_dbd_hooks
 };
-



Mime
View raw message