]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/acl.c
remove dbenv->lock_put() call from transaction-protected operations
[openldap] / servers / slapd / acl.c
index 763a7e3f21e863ee8e38fae9308120465a9c6542..3b73c8d9d9a37b6b430e8172968d6063a8c46178 100644 (file)
 #include "sets.h"
 #include "lber_pvt.h"
 
+#define ACL_BUF_SIZE   1024    /* use most appropriate size */
+
 
 /*
  * speed up compares
  */
 static struct berval 
-       aci_bv_entry            = { sizeof("entry") - 1,        "entry" },
-       aci_bv_br_entry         = { sizeof("[entry]") - 1,      "[entry]" },
-       aci_bv_br_all           = { sizeof("[all]") - 1,        "[all]" },
-       aci_bv_access_id        = { sizeof("access-id") - 1,    "access-id" },
-       aci_bv_anonymous        = { sizeof("anonymous") - 1,    "anonymous" },
-       aci_bv_users            = { sizeof("users") - 1,        "users" },
-       aci_bv_self             = { sizeof("self") - 1,         "self" },
-       aci_bv_dnattr           = { sizeof("dnattr") - 1,       "dnattr" },
-       aci_bv_group            = { sizeof("group") - 1,        "group" },
-       aci_bv_role             = { sizeof("role") - 1,         "role" },
-       aci_bv_set              = { sizeof("set") - 1,          "set" },
-       aci_bv_set_ref          = { sizeof("set-ref") - 1,      "set-ref"},
-       aci_bv_grant            = { sizeof("grant") - 1,        "grant" },
-       aci_bv_deny             = { sizeof("deny") - 1,         "deny" };
+       aci_bv_entry            = BER_BVC("entry"),
+       aci_bv_br_entry         = BER_BVC("[entry]"),
+       aci_bv_br_all           = BER_BVC("[all]"),
+       aci_bv_access_id        = BER_BVC("access-id"),
+       aci_bv_anonymous        = BER_BVC("anonymous"),
+       aci_bv_users            = BER_BVC("users"),
+       aci_bv_self             = BER_BVC("self"),
+       aci_bv_dnattr           = BER_BVC("dnattr"),
+       aci_bv_group            = BER_BVC("group"),
+       aci_bv_role             = BER_BVC("role"),
+       aci_bv_set              = BER_BVC("set"),
+       aci_bv_set_ref          = BER_BVC("set-ref"),
+       aci_bv_grant            = BER_BVC("grant"),
+       aci_bv_deny             = BER_BVC("deny");
 
 static AccessControl * acl_get(
        AccessControl *ac, int *count,
@@ -641,7 +643,7 @@ acl_mask(
 
                                if ( b->a_dn_expand ) {
                                        struct berval bv;
-                                       char buf[1024];
+                                       char buf[ACL_BUF_SIZE];
 
                                        bv.bv_len = sizeof( buf ) - 1;
                                        bv.bv_val = buf;
@@ -754,7 +756,7 @@ dn_match_cleanup:;
                                                continue;
                                        }
                                } else {
-                                       char buf[1024];
+                                       char buf[ACL_BUF_SIZE];
 
                                        struct berval   cmp = conn->c_peer_domain;
                                        struct berval   pat = b->a_domain_pat;
@@ -917,7 +919,7 @@ dn_match_cleanup:;
                }
 
                if ( b->a_group_pat.bv_len ) {
-                       char buf[1024];
+                       char buf[ACL_BUF_SIZE];
                        struct berval bv;
                        struct berval ndn = { 0, NULL };
                        int rc;
@@ -1644,7 +1646,6 @@ aci_group_member (
        regmatch_t      *matches
 )
 {
-       struct berval bv;
        struct berval subjdn;
        struct berval grpoc;
        struct berval grpat;
@@ -1676,15 +1677,15 @@ aci_group_member (
        grp_oc = oc_bvfind( &grpoc );
 
        if (grp_oc != NULL && grp_ad != NULL ) {
-               struct berval ndn;
-               bv.bv_val = (char *)ch_malloc(1024);
-               bv.bv_len = 1024;
+               char buf[ACL_BUF_SIZE];
+               struct berval bv, ndn;
+               bv.bv_len = sizeof( buf );
+               bv.bv_val = &buf;
                string_expand(&bv, &subjdn, e->e_ndn, matches);
                if ( dnNormalize2(NULL, &bv, &ndn) == LDAP_SUCCESS ) {
                        rc = (backend_group(be, conn, op, e, &ndn, &op->o_ndn, grp_oc, grp_ad) == 0);
                        free( ndn.bv_val );
                }
-               ch_free(bv.bv_val);
        }
 
 done: