]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/acl.c
Fix previous commit
[openldap] / servers / slapd / acl.c
index 3ea0297873420ebfa0658b5a9b17cd0a30db6080..6feaa84a493c2ec97ff3f9ca27de0c48fd703b61 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "slap.h"
 #include "sets.h"
+#include "lber_pvt.h"
 
 
 /*
@@ -378,7 +379,7 @@ acl_get(
                                        if ( dnlen <= patlen )
                                                continue;
 
-                                       if ( !DN_SEPARATOR( e->e_ndn[dnlen - patlen - 1] ) || DN_ESCAPE( e->e_ndn[dnlen - patlen - 2] ) )
+                                       if ( !DN_SEPARATOR( e->e_ndn[dnlen - patlen - 1] ) )
                                                continue;
 
                                        rdnlen = dn_rdnlen( NULL, &e->e_nname );
@@ -386,13 +387,13 @@ acl_get(
                                                continue;
 
                                } else if ( a->acl_dn_style == ACL_STYLE_SUBTREE ) {
-                                       if ( dnlen > patlen && ( !DN_SEPARATOR( e->e_ndn[dnlen - patlen - 1] ) || DN_ESCAPE( e->e_ndn[dnlen - patlen - 2] ) ) )
+                                       if ( dnlen > patlen && !DN_SEPARATOR( e->e_ndn[dnlen - patlen - 1] ) )
                                                continue;
 
                                } else if ( a->acl_dn_style == ACL_STYLE_CHILDREN ) {
                                        if ( dnlen <= patlen )
                                                continue;
-                                       if ( !DN_SEPARATOR( e->e_ndn[dnlen - patlen - 1] ) || DN_ESCAPE( e->e_ndn[dnlen - patlen - 2] ) )
+                                       if ( !DN_SEPARATOR( e->e_ndn[dnlen - patlen - 1] ) )
                                                continue;
                                }
 
@@ -531,17 +532,17 @@ acl_mask(
                         * user is bound as somebody in the same namespace as
                         * the entry, OR the given dn matches the dn pattern
                         */
-                       if ( ber_cmp( &b->a_dn_pat, &aci_bv_anonymous ) == 0 ) {
+                       if ( ber_bvcmp( &b->a_dn_pat, &aci_bv_anonymous ) == 0 ) {
                                if ( op->o_ndn.bv_len != 0 ) {
                                        continue;
                                }
 
-                       } else if ( ber_cmp( &b->a_dn_pat, &aci_bv_users ) == 0 ) {
+                       } else if ( ber_bvcmp( &b->a_dn_pat, &aci_bv_users ) == 0 ) {
                                if ( op->o_ndn.bv_len == 0 ) {
                                        continue;
                                }
 
-                       } else if ( ber_cmp( &b->a_dn_pat, &aci_bv_self ) == 0 ) {
+                       } else if ( ber_bvcmp( &b->a_dn_pat, &aci_bv_self ) == 0 ) {
                                if ( op->o_ndn.bv_len == 0 ) {
                                        continue;
                                }
@@ -551,8 +552,7 @@ acl_mask(
                                }
 
                        } else if ( b->a_dn_style == ACL_STYLE_REGEX ) {
-                               if ( b->a_dn_pat.bv_len != 1 || 
-                                   ber_charcmp( &b->a_dn_pat, '*' ) != 0 ) {
+                               if ( ber_bvccmp( &b->a_dn_pat, '*' ) == 0 ) {
                                        int ret = regex_matches( b->a_dn_pat.bv_val,
                                                op->o_ndn.bv_val, e->e_ndn, matches );
 
@@ -581,7 +581,7 @@ acl_mask(
                                        if ( odnlen <= patlen )
                                                continue;
 
-                                       if ( !DN_SEPARATOR( op->o_ndn.bv_val[odnlen - patlen - 1] ) || DN_ESCAPE( op->o_ndn.bv_val[odnlen - patlen - 2] ) )
+                                       if ( !DN_SEPARATOR( op->o_ndn.bv_val[odnlen - patlen - 1] ) )
                                                continue;
 
                                        rdnlen = dn_rdnlen( NULL, &op->o_ndn );
@@ -589,19 +589,18 @@ acl_mask(
                                                continue;
 
                                } else if ( b->a_dn_style == ACL_STYLE_SUBTREE ) {
-                                       if ( odnlen > patlen && ( !DN_SEPARATOR( op->o_ndn.bv_val[odnlen - patlen - 1] ) || DN_ESCAPE( op->o_ndn.bv_val[odnlen - patlen - 2] ) ) )
+                                       if ( odnlen > patlen && !DN_SEPARATOR( op->o_ndn.bv_val[odnlen - patlen - 1] ) )
                                                continue;
 
                                } else if ( b->a_dn_style == ACL_STYLE_CHILDREN ) {
                                        if ( odnlen <= patlen )
                                                continue;
-                                       if ( !DN_SEPARATOR( op->o_ndn.bv_val[odnlen - patlen - 1] ) || DN_ESCAPE( op->o_ndn.bv_val[odnlen - patlen - 2] ) )
+                                       if ( !DN_SEPARATOR( op->o_ndn.bv_val[odnlen - patlen - 1] ) )
                                                continue;
                                }
 
                                if ( strcmp( b->a_dn_pat.bv_val, op->o_ndn.bv_val + odnlen - patlen ) != 0 )
                                        continue;
-
                        }
                }
 
@@ -615,7 +614,7 @@ acl_mask(
                                b->a_sockurl_pat, 0, 0 );
 #endif
 
-                       if ( strcmp( b->a_sockurl_pat, "*" ) != 0) {
+                       if ( ber_strccmp( b->a_sockurl_pat, '*' ) != 0) {
                                if ( b->a_sockurl_style == ACL_STYLE_REGEX) {
                                        if (!regex_matches( b->a_sockurl_pat, conn->c_listener_url,
                                                        e->e_ndn, matches ) ) 
@@ -638,7 +637,7 @@ acl_mask(
                        Debug( LDAP_DEBUG_ACL, "<= check a_domain_pat: %s\n",
                                b->a_domain_pat, 0, 0 );
 #endif
-                       if ( strcmp( b->a_domain_pat, "*" ) != 0) {
+                       if ( ber_strccmp( b->a_domain_pat, '*' ) != 0) {
                                if ( b->a_domain_style == ACL_STYLE_REGEX) {
                                        if (!regex_matches( b->a_domain_pat, conn->c_peer_domain,
                                                        e->e_ndn, matches ) ) 
@@ -661,7 +660,7 @@ acl_mask(
                        Debug( LDAP_DEBUG_ACL, "<= check a_peername_path: %s\n",
                                b->a_peername_pat, 0, 0 );
 #endif
-                       if ( strcmp( b->a_peername_pat, "*" ) != 0) {
+                       if ( ber_strccmp( b->a_peername_pat, '*' ) != 0) {
                                if ( b->a_peername_style == ACL_STYLE_REGEX) {
                                        if (!regex_matches( b->a_peername_pat, conn->c_peer_name,
                                                        e->e_ndn, matches ) ) 
@@ -684,7 +683,7 @@ acl_mask(
                        Debug( LDAP_DEBUG_ACL, "<= check a_sockname_path: %s\n",
                                b->a_sockname_pat, 0, 0 );
 #endif
-                       if ( strcmp( b->a_sockname_pat, "*" ) != 0) {
+                       if ( ber_strccmp( b->a_sockname_pat, '*' ) != 0) {
                                if ( b->a_sockname_style == ACL_STYLE_REGEX) {
                                        if (!regex_matches( b->a_sockname_pat, conn->c_sock_name,
                                                        e->e_ndn, matches ) ) 
@@ -795,8 +794,7 @@ acl_mask(
                                b->a_group_oc, b->a_group_at);
                        if ( ndn.bv_val )
                                free( ndn.bv_val );
-                       if ( rc != 0 )
-                       {
+                       if ( rc != 0 ) {
                                continue;
                        }
                }
@@ -1396,13 +1394,13 @@ aci_list_has_attr(
                if (aci_get_part(&bv, 0, '=', &left) < 0
                        || aci_get_part(&bv, 1, '=', &right) < 0)
                {
-                       if (ber_casecmp(attr, &bv) == 0)
+                       if (ber_bvstrcasecmp(attr, &bv) == 0)
                                return(1);
                } else if (val == NULL) {
-                       if (ber_casecmp(attr, &left) == 0)
+                       if (ber_bvstrcasecmp(attr, &left) == 0)
                                return(1);
                } else {
-                       if (ber_casecmp(attr, &left) == 0) {
+                       if (ber_bvstrcasecmp(attr, &left) == 0) {
                                /* this is experimental code that implements a
                                 * simple (prefix) match of the attribute value.
                                 * the ACI draft does not provide for aci's that
@@ -1420,7 +1418,7 @@ aci_list_has_attr(
                                if (aci_get_part(&right, 0, '*', &left) < 0
                                        || right.bv_len <= left.bv_len)
                                {
-                                       if (ber_casecmp(val, &right) == 0)
+                                       if (ber_bvstrcasecmp(val, &right) == 0)
                                                return(1);
                                } else if (val->bv_len >= left.bv_len) {
                                        if (strncasecmp( val->bv_val, left.bv_val, left.bv_len ) == 0)
@@ -1467,7 +1465,7 @@ aci_list_get_rights(
     int i, found;
 
        if (attr == NULL || attr->bv_len == 0 
-                       || ber_casecmp( attr, &aci_bv_entry ) == 0) {
+                       || ber_bvstrcasecmp( attr, &aci_bv_entry ) == 0) {
                attr = &aci_bv_br_entry;
        }
 
@@ -1478,9 +1476,9 @@ aci_list_get_rights(
        for (i = 0; aci_get_part(list, i, '$', &perm) >= 0; i++) {
                if (aci_get_part(&perm, 0, ';', &actn) < 0)
                        continue;
-               if (ber_casecmp( &aci_bv_grant, &actn ) == 0) {
+               if (ber_bvstrcasecmp( &aci_bv_grant, &actn ) == 0) {
                        mask = grant;
-               } else if (ber_casecmp( &aci_bv_deny, &actn ) == 0) {
+               } else if (ber_bvstrcasecmp( &aci_bv_deny, &actn ) == 0) {
                        mask = deny;
                } else {
                        continue;
@@ -1606,7 +1604,7 @@ aci_mask(
 
        /* check that the scope is "entry" */
        if (aci_get_part(aci, 1, '#', &bv) < 0
-               || ber_casecmp( &aci_bv_entry, &bv ) != 0)
+               || ber_bvstrcasecmp( &aci_bv_entry, &bv ) != 0)
        {
                return(0);
        }
@@ -1626,7 +1624,7 @@ aci_mask(
        if (aci_get_part(aci, 4, '#', &sdn) < 0)
                return(0);
 
-       if (ber_casecmp( &aci_bv_access_id, &bv ) == 0) {
+       if (ber_bvstrcasecmp( &aci_bv_access_id, &bv ) == 0) {
                struct berval ndn;
                rc = 1;
                if ( dnNormalize2(NULL, &sdn, &ndn) == LDAP_SUCCESS ) {
@@ -1637,11 +1635,11 @@ aci_mask(
                return(rc);
        }
 
-       if (ber_casecmp( &aci_bv_self, &bv ) == 0) {
+       if (ber_bvstrcasecmp( &aci_bv_self, &bv ) == 0) {
                if (dn_match(&op->o_ndn, &e->e_nname))
                        return(1);
 
-       } else if (ber_casecmp( &aci_bv_dnattr, &bv ) == 0) {
+       } else if (ber_bvstrcasecmp( &aci_bv_dnattr, &bv ) == 0) {
                Attribute *at;
                AttributeDescription *ad = NULL;
                const char *text;
@@ -1669,19 +1667,19 @@ aci_mask(
                return rc;
 
 
-       } else if (ber_casecmp( &aci_bv_group, &bv ) == 0) {
+       } else if (ber_bvstrcasecmp( &aci_bv_group, &bv ) == 0) {
                if (aci_group_member(&sdn, &GroupClass, &GroupAttr, be, e, conn, op, matches))
                        return(1);
 
-       } else if (ber_casecmp( &aci_bv_role, &bv ) == 0) {
+       } else if (ber_bvstrcasecmp( &aci_bv_role, &bv ) == 0) {
                if (aci_group_member(&sdn, &RoleClass, &RoleAttr, be, e, conn, op, matches))
                        return(1);
 
-       } else if (ber_casecmp( &aci_bv_set, &bv ) == 0) {
+       } else if (ber_bvstrcasecmp( &aci_bv_set, &bv ) == 0) {
                if (aci_match_set(&sdn, be, e, conn, op, 0))
                        return(1);
 
-       } else if (ber_casecmp( &aci_bv_set_ref, &bv ) == 0) {
+       } else if (ber_bvstrcasecmp( &aci_bv_set_ref, &bv ) == 0) {
                if (aci_match_set(&sdn, be, e, conn, op, 1))
                        return(1);