1 /* aci.c - routines to parse and check acl's */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2006 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
16 /* Portions Copyright (c) 1995 Regents of the University of Michigan.
17 * All rights reserved.
19 * Redistribution and use in source and binary forms are permitted
20 * provided that this notice is preserved and that due credit is given
21 * to the University of Michigan at Ann Arbor. The name of the University
22 * may not be used to endorse or promote products derived from this
23 * software without specific prior written permission. This software
24 * is provided ``as is'' without express or implied warranty.
29 #ifdef SLAPD_ACI_ENABLED
35 #include <ac/socket.h>
36 #include <ac/string.h>
37 #include <ac/unistd.h>
43 /* use most appropriate size */
44 #define ACI_BUF_SIZE 1024
46 /* move to "stable" when no longer experimental */
47 #define SLAPD_ACI_SYNTAX "1.3.6.1.4.1.4203.666.2.1"
49 /* change this to "OpenLDAPset" */
50 #define SLAPD_ACI_SET_ATTR "template"
52 typedef enum slap_aci_scope_t {
53 SLAP_ACI_SCOPE_ENTRY = 0x1,
54 SLAP_ACI_SCOPE_CHILDREN = 0x2,
55 SLAP_ACI_SCOPE_SUBTREE = ( SLAP_ACI_SCOPE_ENTRY | SLAP_ACI_SCOPE_CHILDREN )
91 static const struct berval aci_bv[] = {
100 BER_BVC("[children]"),
104 BER_BVC("access-id"),
119 BER_BVC(SLAPD_GROUP_CLASS),
120 BER_BVC(SLAPD_GROUP_ATTR),
121 BER_BVC(SLAPD_ROLE_CLASS),
122 BER_BVC(SLAPD_ROLE_ATTR),
124 BER_BVC(SLAPD_ACI_SET_ATTR),
129 static AttributeDescription *slap_ad_aci;
134 struct berval *val );
144 OpenLDAPaciNormalize(
152 #define OpenLDAPaciMatch octetStringMatch
156 struct berval *list )
163 for ( i = 0; acl_get_part( list, i, ',', &bv ) >= 0; i++ ) {
164 if ( bv.bv_len <= 0 ) {
168 switch ( *bv.bv_val ) {
170 /* **** NOTE: draft-ietf-ldapext-aci-model-0.3.txt does not
171 * define any equivalent to the AUTH right, so I've just used
174 ACL_PRIV_SET(mask, ACL_PRIV_AUTH);
177 /* **** NOTE: draft-ietf-ldapext-aci-model-0.3.txt defines
178 * the right 'd' to mean "delete"; we hijack it to mean
179 * "disclose" for consistency wuith the rest of slapd.
181 ACL_PRIV_SET(mask, ACL_PRIV_DISCLOSE);
184 ACL_PRIV_SET(mask, ACL_PRIV_COMPARE);
187 /* **** NOTE: draft-ietf-ldapext-aci-model-0.3.txt defines
188 * the right 's' to mean "set", but in the examples states
189 * that the right 's' means "search". The latter definition
192 ACL_PRIV_SET(mask, ACL_PRIV_SEARCH);
195 ACL_PRIV_SET(mask, ACL_PRIV_READ);
198 ACL_PRIV_SET(mask, ACL_PRIV_WRITE);
212 const struct berval *attr,
215 struct berval bv, left, right;
218 for ( i = 0; acl_get_part( list, i, ',', &bv ) >= 0; i++ ) {
219 if ( acl_get_part(&bv, 0, '=', &left ) < 0
220 || acl_get_part( &bv, 1, '=', &right ) < 0 )
222 if ( ber_bvstrcasecmp( attr, &bv ) == 0 ) {
226 } else if ( val == NULL ) {
227 if ( ber_bvstrcasecmp( attr, &left ) == 0 ) {
232 if ( ber_bvstrcasecmp( attr, &left ) == 0 ) {
233 /* FIXME: this is also totally undocumented! */
234 /* this is experimental code that implements a
235 * simple (prefix) match of the attribute value.
236 * the ACI draft does not provide for aci's that
237 * apply to specific values, but it would be
238 * nice to have. If the <attr> part of an aci's
239 * rights list is of the form <attr>=<value>,
240 * that means the aci applies only to attrs with
241 * the given value. Furthermore, if the attr is
242 * of the form <attr>=<value>*, then <value> is
243 * treated as a prefix, and the aci applies to
244 * any value with that prefix.
246 * Ideally, this would allow r.e. matches.
248 if ( acl_get_part( &right, 0, '*', &left ) < 0
249 || right.bv_len <= left.bv_len )
251 if ( ber_bvstrcasecmp( val, &right ) == 0 ) {
255 } else if ( val->bv_len >= left.bv_len ) {
256 if ( strncasecmp( val->bv_val, left.bv_val, left.bv_len ) == 0 ) {
268 aci_list_get_attr_rights(
270 const struct berval *attr,
277 /* loop through each rights/attr pair, skip first part (action) */
279 for ( i = 1; acl_get_part( list, i + 1, ';', &bv ) >= 0; i += 2 ) {
280 if ( aci_list_has_attr( &bv, attr, val ) == 0 ) {
281 Debug( LDAP_DEBUG_ACL, " <= aci_list_get_attr_rights test %s for %s -> failed\n", bv.bv_val, attr->bv_val, 0 );
284 Debug( LDAP_DEBUG_ACL, " <= aci_list_get_attr_rights test %s for %s -> ok\n", bv.bv_val, attr->bv_val, 0 );
286 if ( acl_get_part( list, i, ';', &bv ) < 0 ) {
287 Debug( LDAP_DEBUG_ACL, " <= aci_list_get_attr_rights test no rightsk\n", 0, 0, 0 );
291 mask |= aci_list_map_rights( &bv );
292 Debug( LDAP_DEBUG_ACL, " <= aci_list_get_attr_rights rights %s to mask 0x%x\n", bv.bv_val, mask, 0 );
303 slap_access_t *grant,
304 slap_access_t *deny )
306 struct berval perm, actn, baseattr;
310 if ( attr == NULL || BER_BVISEMPTY( attr ) ) {
311 attr = (struct berval *)&aci_bv[ ACI_BV_ENTRY ];
313 } else if ( acl_get_part( attr, 0, ';', &baseattr ) > 0 ) {
319 /* loop through each permissions clause */
320 for ( i = 0; acl_get_part( list, i, '$', &perm ) >= 0; i++ ) {
321 if ( acl_get_part( &perm, 0, ';', &actn ) < 0 ) {
325 if ( ber_bvstrcasecmp( &aci_bv[ ACI_BV_GRANT ], &actn ) == 0 ) {
328 } else if ( ber_bvstrcasecmp( &aci_bv[ ACI_BV_DENY ], &actn ) == 0 ) {
336 *mask |= aci_list_get_attr_rights( &perm, attr, val );
337 *mask |= aci_list_get_attr_rights( &perm, &aci_bv[ ACI_BV_BR_ALL ], NULL );
346 const struct berval *defgrpoc,
347 const struct berval *defgrpat,
354 struct berval subjdn;
357 ObjectClass *grp_oc = NULL;
358 AttributeDescription *grp_ad = NULL;
362 /* format of string is "{group|role}/objectClassValue/groupAttrName" */
363 if ( acl_get_part( subj, 0, '/', &subjdn ) < 0 ) {
367 if ( acl_get_part( subj, 1, '/', &grpoc ) < 0 ) {
371 if ( acl_get_part( subj, 2, '/', &grpat ) < 0 ) {
375 rc = slap_bv2ad( &grpat, &grp_ad, &text );
376 if ( rc != LDAP_SUCCESS ) {
382 grp_oc = oc_bvfind( &grpoc );
384 if ( grp_oc != NULL && grp_ad != NULL ) {
385 char buf[ ACI_BUF_SIZE ];
386 struct berval bv, ndn;
388 bv.bv_len = sizeof( buf ) - 1;
389 bv.bv_val = (char *)&buf;
390 if ( acl_string_expand( &bv, &subjdn,
391 e->e_ndn, nmatch, matches ) )
397 if ( dnNormalize( 0, NULL, NULL, &bv, &ndn, op->o_tmpmemctx ) == LDAP_SUCCESS )
399 rc = ( backend_group( op, e, &ndn, &op->o_ndn,
400 grp_oc, grp_ad ) == 0 );
401 slap_sl_free( ndn.bv_val, op->o_tmpmemctx );
413 AttributeDescription *desc,
418 slap_access_t *grant,
420 slap_aci_scope_t asserted_scope )
431 assert( !BER_BVISNULL( &desc->ad_cname ) );
433 /* parse an aci of the form:
434 oid # scope # action;rights;attr;rights;attr
435 $ action;rights;attr;rights;attr # type # subject
437 [NOTE: the following comment is very outdated,
438 as the draft version it refers to (Ando, 2004-11-20)].
440 See draft-ietf-ldapext-aci-model-04.txt section 9.1 for
441 a full description of the format for this attribute.
442 Differences: "this" in the draft is "self" here, and
443 "self" and "public" is in the position of type.
445 <scope> = {entry|children|subtree}
446 <type> = {public|users|access-id|subtree|onelevel|children|
447 self|dnattr|group|role|set|set-ref}
449 This routine now supports scope={ENTRY,CHILDREN}
451 - ENTRY applies to "entry" and "subtree";
452 - CHILDREN aplies to "children" and "subtree"
455 /* check that the aci has all 5 components */
456 if ( acl_get_part( aci, 4, '#', NULL ) < 0 ) {
460 /* check that the aci family is supported */
461 /* FIXME: the OID is ignored? */
462 if ( acl_get_part( aci, 0, '#', &bv ) < 0 ) {
466 /* check that the scope matches */
467 if ( acl_get_part( aci, 1, '#', &scope ) < 0 ) {
471 /* note: scope can be either ENTRY or CHILDREN;
472 * they respectively match "entry" and "children" in bv
473 * both match "subtree" */
474 switch ( asserted_scope ) {
475 case SLAP_ACI_SCOPE_ENTRY:
476 if ( ber_bvcmp( &scope, &aci_bv[ ACI_BV_ENTRY ] ) != 0
477 && ber_bvstrcasecmp( &scope, &aci_bv[ ACI_BV_SUBTREE ] ) != 0 )
483 case SLAP_ACI_SCOPE_CHILDREN:
484 if ( ber_bvcmp( &scope, &aci_bv[ ACI_BV_CHILDREN ] ) != 0
485 && ber_bvstrcasecmp( &scope, &aci_bv[ ACI_BV_SUBTREE ] ) != 0 )
491 case SLAP_ACI_SCOPE_SUBTREE:
492 /* TODO: add assertion? */
496 /* get the list of permissions clauses, bail if empty */
497 if ( acl_get_part( aci, 2, '#', &perms ) <= 0 ) {
502 /* check if any permissions allow desired access */
503 if ( aci_list_get_rights( &perms, &desc->ad_cname, val, grant, deny ) == 0 ) {
507 /* see if we have a DN match */
508 if ( acl_get_part( aci, 3, '#', &type ) < 0 ) {
513 /* see if we have a public (i.e. anonymous) access */
514 if ( ber_bvcmp( &aci_bv[ ACI_BV_PUBLIC ], &type ) == 0 ) {
518 /* otherwise require an identity */
519 if ( BER_BVISNULL( &op->o_ndn ) || BER_BVISEMPTY( &op->o_ndn ) ) {
523 /* see if we have a users access */
524 if ( ber_bvcmp( &aci_bv[ ACI_BV_USERS ], &type ) == 0 ) {
528 /* NOTE: this may fail if a DN contains a valid '#' (unescaped);
529 * just grab all the berval up to its end (ITS#3303).
530 * NOTE: the problem could be solved by providing the DN with
531 * the embedded '#' encoded as hexpairs: "cn=Foo#Bar" would
532 * become "cn=Foo\23Bar" and be safely used by aci_mask(). */
534 if ( acl_get_part( aci, 4, '#', &sdn ) < 0 ) {
538 sdn.bv_val = type.bv_val + type.bv_len + STRLENOF( "#" );
539 sdn.bv_len = aci->bv_len - ( sdn.bv_val - aci->bv_val );
541 /* get the type options, if any */
542 if ( acl_get_part( &type, 1, '/', &opts ) > 0 ) {
543 opts.bv_len = type.bv_len - ( opts.bv_val - type.bv_val );
544 type.bv_len = opts.bv_val - type.bv_val - 1;
550 if ( ber_bvcmp( &aci_bv[ ACI_BV_ACCESS_ID ], &type ) == 0 ) {
551 return dn_match( &op->o_ndn, &sdn );
553 } else if ( ber_bvcmp( &aci_bv[ ACI_BV_SUBTREE ], &type ) == 0 ) {
554 return dnIsSuffix( &op->o_ndn, &sdn );
556 } else if ( ber_bvcmp( &aci_bv[ ACI_BV_ONELEVEL ], &type ) == 0 ) {
559 dnParent( &sdn, &pdn );
561 return dn_match( &op->o_ndn, &pdn );
563 } else if ( ber_bvcmp( &aci_bv[ ACI_BV_CHILDREN ], &type ) == 0 ) {
564 return ( !dn_match( &op->o_ndn, &sdn ) && dnIsSuffix( &op->o_ndn, &sdn ) );
566 } else if ( ber_bvcmp( &aci_bv[ ACI_BV_SELF ], &type ) == 0 ) {
567 return dn_match( &op->o_ndn, &e->e_nname );
569 } else if ( ber_bvcmp( &aci_bv[ ACI_BV_DNATTR ], &type ) == 0 ) {
571 AttributeDescription *ad = NULL;
574 rc = slap_bv2ad( &sdn, &ad, &text );
575 assert( rc == LDAP_SUCCESS );
578 for ( at = attrs_find( e->e_attrs, ad );
580 at = attrs_find( at->a_next, ad ) )
582 if ( value_find_ex( ad,
583 SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
584 SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
586 &op->o_ndn, op->o_tmpmemctx ) == 0 )
595 } else if ( ber_bvcmp( &aci_bv[ ACI_BV_GROUP ], &type ) == 0 ) {
599 if ( BER_BVISNULL( &opts ) ) {
600 oc = aci_bv[ ACI_BV_GROUP_CLASS ];
601 at = aci_bv[ ACI_BV_GROUP_ATTR ];
604 if ( acl_get_part( &opts, 0, '/', &oc ) < 0 ) {
608 if ( acl_get_part( &opts, 1, '/', &at ) < 0 ) {
609 at = aci_bv[ ACI_BV_GROUP_ATTR ];
613 if ( aci_group_member( &sdn, &oc, &at, op, e, nmatch, matches ) )
618 } else if ( ber_bvcmp( &aci_bv[ ACI_BV_ROLE ], &type ) == 0 ) {
622 if ( BER_BVISNULL( &opts ) ) {
623 oc = aci_bv[ ACI_BV_ROLE_CLASS ];
624 at = aci_bv[ ACI_BV_ROLE_ATTR ];
627 if ( acl_get_part( &opts, 0, '/', &oc ) < 0 ) {
631 if ( acl_get_part( &opts, 1, '/', &at ) < 0 ) {
632 at = aci_bv[ ACI_BV_ROLE_ATTR ];
636 if ( aci_group_member( &sdn, &oc, &at, op, e, nmatch, matches ) )
641 } else if ( ber_bvcmp( &aci_bv[ ACI_BV_SET ], &type ) == 0 ) {
642 if ( acl_match_set( &sdn, op, e, NULL ) ) {
646 } else if ( ber_bvcmp( &aci_bv[ ACI_BV_SET_REF ], &type ) == 0 ) {
647 if ( acl_match_set( &sdn, op, e, (struct berval *)&aci_bv[ ACI_BV_SET_ATTR ] ) ) {
652 /* it passed normalization! */
662 /* OpenLDAP eXperimental Syntax */
663 static slap_syntax_defs_rec aci_syntax_def = {
664 "( 1.3.6.1.4.1.4203.666.2.1 DESC 'OpenLDAP Experimental ACI' )",
669 static slap_mrule_defs_rec aci_mr_def = {
670 "( 1.3.6.1.4.1.4203.666.4.2 NAME 'OpenLDAPaciMatch' "
671 "SYNTAX 1.3.6.1.4.1.4203.666.2.1 )",
672 SLAP_MR_HIDE | SLAP_MR_EQUALITY, NULL,
673 NULL, OpenLDAPaciNormalize, OpenLDAPaciMatch,
681 AttributeDescription **ad;
683 "OpenLDAPaci", "( 1.3.6.1.4.1.4203.666.1.5 "
684 "NAME 'OpenLDAPaci' "
685 "DESC 'OpenLDAP access control information (experimental)' "
686 "EQUALITY OpenLDAPaciMatch "
687 "SYNTAX 1.3.6.1.4.1.4203.666.2.1 "
688 "USAGE directoryOperation )",
696 rc = register_syntax( &aci_syntax_def );
701 /* ACI equality rule */
702 rc = register_matching_rule( &aci_mr_def );
708 rc = register_at( aci_at.desc, aci_at.ad, 0 );
709 if ( rc != LDAP_SUCCESS ) {
710 Debug( LDAP_DEBUG_ANY,
711 "aci_init: at_register failed\n", 0, 0, 0 );
716 (*aci_at.ad)->ad_type->sat_flags |= aci_at.flags;
730 AttributeDescription *ad = NULL;
731 const char *text = NULL;
733 if ( sty != ACL_STYLE_REGEX && sty != ACL_STYLE_BASE ) {
734 fprintf( stderr, "%s: line %d: "
735 "inappropriate style \"%s\" in \"aci\" by clause\n",
736 fname, lineno, style_strings[sty] );
740 if ( right != NULL && *right != '\0' ) {
741 if ( slap_str2ad( right, &ad, &text ) != LDAP_SUCCESS ) {
743 "%s: line %d: aci \"%s\": %s\n",
744 fname, lineno, right, text );
752 if ( !is_at_syntax( ad->ad_type, SLAPD_ACI_SYNTAX) ) {
753 fprintf( stderr, "%s: line %d: "
754 "aci \"%s\": inappropriate syntax: %s\n",
755 fname, lineno, right,
756 ad->ad_type->sat_syntax_oid );
766 dynacl_aci_unparse( void *priv, struct berval *bv )
768 AttributeDescription *ad = ( AttributeDescription * )priv;
771 assert( ad != NULL );
773 bv->bv_val = ch_malloc( STRLENOF(" aci=") + ad->ad_cname.bv_len + 1 );
774 ptr = lutil_strcopy( bv->bv_val, " aci=" );
775 ptr = lutil_strcopy( ptr, ad->ad_cname.bv_val );
776 bv->bv_len = ptr - bv->bv_val;
786 AttributeDescription *desc,
790 slap_access_t *grantp,
791 slap_access_t *denyp )
793 AttributeDescription *ad = ( AttributeDescription * )priv;
795 slap_access_t tgrant, tdeny, grant, deny;
797 char accessmaskbuf[ACCESSMASK_MAXLEN];
798 char accessmaskbuf1[ACCESSMASK_MAXLEN];
799 #endif /* LDAP_DEBUG */
801 if ( BER_BVISEMPTY( &e->e_nname ) ) {
802 /* no ACIs in the root DSE */
806 /* start out with nothing granted, nothing denied */
810 /* get the aci attribute */
811 at = attr_find( e->e_attrs, ad );
815 /* the aci is an multi-valued attribute. The
816 * rights are determined by OR'ing the individual
817 * rights given by the acis.
819 for ( i = 0; !BER_BVISNULL( &at->a_nvals[i] ); i++ ) {
820 if ( aci_mask( op, e, desc, val, &at->a_nvals[i],
821 nmatch, matches, &grant, &deny,
822 SLAP_ACI_SCOPE_ENTRY ) != 0 )
829 Debug( LDAP_DEBUG_ACL, " <= aci_mask grant %s deny %s\n",
830 accessmask2str( tgrant, accessmaskbuf, 1 ),
831 accessmask2str( tdeny, accessmaskbuf1, 1 ), 0 );
834 /* If the entry level aci didn't contain anything valid for the
835 * current operation, climb up the tree and evaluate the
836 * acis with scope set to subtree
838 if ( tgrant == ACL_PRIV_NONE && tdeny == ACL_PRIV_NONE ) {
839 struct berval parent_ndn;
841 dnParent( &e->e_nname, &parent_ndn );
842 while ( !BER_BVISEMPTY( &parent_ndn ) ){
844 BerVarray bvals = NULL;
847 /* to solve the chicken'n'egg problem of accessing
848 * the OpenLDAPaci attribute, the direct access
849 * to the entry's attribute is unchecked; however,
850 * further accesses to OpenLDAPaci values in the
851 * ancestors occur through backend_attribute(), i.e.
852 * with the identity of the operation, requiring
853 * further access checking. For uniformity, this
854 * makes further requests occur as the rootdn, if
855 * any, i.e. searching for the OpenLDAPaci attribute
856 * is considered an internal search. If this is not
857 * acceptable, then the same check needs be performed
858 * when accessing the entry's attribute. */
859 struct berval save_o_dn, save_o_ndn;
861 if ( !BER_BVISNULL( &op->o_bd->be_rootndn ) ) {
862 save_o_dn = op->o_dn;
863 save_o_ndn = op->o_ndn;
865 op->o_dn = op->o_bd->be_rootdn;
866 op->o_ndn = op->o_bd->be_rootndn;
869 Debug( LDAP_DEBUG_ACL, " checking ACI of \"%s\"\n", parent_ndn.bv_val, 0, 0 );
870 ret = backend_attribute( op, NULL, &parent_ndn, ad, &bvals, ACL_AUTH );
872 if ( !BER_BVISNULL( &op->o_bd->be_rootndn ) ) {
873 op->o_dn = save_o_dn;
874 op->o_ndn = save_o_ndn;
884 for ( i = 0; !BER_BVISNULL( &bvals[i] ); i++ ) {
885 if ( aci_mask( op, e, desc, val,
889 SLAP_ACI_SCOPE_CHILDREN ) != 0 )
893 /* evaluation stops as soon as either a "deny" or a
894 * "grant" directive matches.
896 if ( tgrant != ACL_PRIV_NONE || tdeny != ACL_PRIV_NONE ) {
900 Debug( LDAP_DEBUG_ACL, "<= aci_mask grant %s deny %s\n",
901 accessmask2str( tgrant, accessmaskbuf, 1 ),
902 accessmask2str( tdeny, accessmaskbuf1, 1 ), 0 );
906 case LDAP_NO_SUCH_ATTRIBUTE:
907 /* just go on if the aci-Attribute is not present in
910 Debug( LDAP_DEBUG_ACL, "no such attribute\n", 0, 0, 0 );
914 case LDAP_NO_SUCH_OBJECT:
915 /* We have reached the base object */
916 Debug( LDAP_DEBUG_ACL, "no such object\n", 0, 0, 0 );
928 dnParent( &parent_ndn, &parent_ndn );
938 /* need to register this at some point */
939 static slap_dynacl_t dynacl_aci = {
950 dynacl_aci_init( void )
957 rc = slap_dynacl_register( &dynacl_aci );
964 /* ACI syntax validation */
967 * Matches given berval to array of bervals
969 * >=0 if one if the array elements equals to this berval
970 * -1 if string was not found in array
975 const struct berval *arr[] )
979 if ( BER_BVISEMPTY( bv ) ) {
983 for ( i = 0; arr[ i ] != NULL ; i++ ) {
984 if ( ber_bvstrcasecmp( bv, arr[ i ] ) == 0 ) {
993 /* Returns what have left in input berval after current sub */
998 struct berval *tail )
1002 tail->bv_val = sub->bv_val + sub->bv_len;
1003 head_len = (unsigned long) tail->bv_val - (unsigned long) val->bv_val;
1004 tail->bv_len = val->bv_len - head_len;
1009 * aci is accepted in following form:
1010 * oid#scope#rights#type#subject
1012 * oid := numeric OID (currently ignored)
1013 * scope := entry|children|subtree
1014 * rights := right[[$right]...]
1015 * right := (grant|deny);action
1016 * action := perms;attrs[[;perms;attrs]...]
1017 * perms := perm[[,perm]...]
1019 * attrs := attribute[[,attribute]..]|[all]
1020 * attribute := attributeType|attributeType=attributeValue|attributeType=attributeValuePrefix*
1021 * type := public|users|self|dnattr|group|role|set|set-ref|
1022 * access_id|subtree|onelevel|children
1025 OpenLDAPaciValidatePerms(
1026 struct berval *perms )
1030 for ( i = 0; i < perms->bv_len; ) {
1031 switch ( perms->bv_val[ i ] ) {
1041 Debug( LDAP_DEBUG_ACL, "aciValidatePerms: perms needs to be one of x,d,c,s,r,w in '%s'\n", perms->bv_val, 0, 0 );
1042 return LDAP_INVALID_SYNTAX;
1045 if ( ++i == perms->bv_len ) {
1046 return LDAP_SUCCESS;
1049 while ( i < perms->bv_len && perms->bv_val[ i ] == ' ' )
1052 assert( i != perms->bv_len );
1054 if ( perms->bv_val[ i ] != ',' ) {
1055 Debug( LDAP_DEBUG_ACL, "aciValidatePerms: missing comma in '%s'\n", perms->bv_val, 0, 0 );
1056 return LDAP_INVALID_SYNTAX;
1061 } while ( perms->bv_val[ i ] == ' ' );
1064 return LDAP_SUCCESS;
1067 static const struct berval *ACIgrantdeny[] = {
1068 &aci_bv[ ACI_BV_GRANT ],
1069 &aci_bv[ ACI_BV_DENY ],
1074 OpenLDAPaciValidateRight(
1075 struct berval *action )
1077 struct berval bv = BER_BVNULL;
1081 if ( acl_get_part( action, 0, ';', &bv ) < 0 ||
1082 bv_getcaseidx( &bv, ACIgrantdeny ) == -1 )
1084 Debug( LDAP_DEBUG_ACL, "aciValidateRight: '%s' must be either 'grant' or 'deny'\n", bv.bv_val, 0, 0 );
1085 return LDAP_INVALID_SYNTAX;
1088 for ( i = 0; acl_get_part( action, i + 1, ';', &bv ) >= 0; i++ ) {
1091 if ( OpenLDAPaciValidatePerms( &bv ) != LDAP_SUCCESS )
1093 return LDAP_INVALID_SYNTAX;
1098 AttributeDescription *ad;
1100 struct berval attr, left, right;
1103 /* could be "[all]" or an attribute description */
1104 if ( ber_bvstrcasecmp( &bv, &aci_bv[ ACI_BV_BR_ALL ] ) == 0 ) {
1109 for ( j = 0; acl_get_part( &bv, j, ',', &attr ) >= 0; j++ )
1113 if ( acl_get_part( &attr, 0, '=', &left ) < 0
1114 || acl_get_part( &attr, 1, '=', &right ) < 0 )
1116 if ( slap_bv2ad( &attr, &ad, &text ) != LDAP_SUCCESS )
1118 Debug( LDAP_DEBUG_ACL, "aciValidateRight: unknown attribute: '%s'\n", attr.bv_val, 0, 0 );
1119 return LDAP_INVALID_SYNTAX;
1122 if ( slap_bv2ad( &left, &ad, &text ) != LDAP_SUCCESS )
1124 Debug( LDAP_DEBUG_ACL, "aciValidateRight: unknown attribute: '%s'\n", left.bv_val, 0, 0 );
1125 return LDAP_INVALID_SYNTAX;
1132 /* "perms;attr" go in pairs */
1133 if ( i > 0 && ( i & 1 ) == 0 ) {
1134 return LDAP_SUCCESS;
1137 Debug( LDAP_DEBUG_ACL, "aciValidateRight: perms:attr need to be pairs in '%s'\n", action->bv_val, 0, 0 );
1138 return LDAP_INVALID_SYNTAX;
1141 return LDAP_SUCCESS;
1145 OpenLDAPaciNormalizeRight(
1146 struct berval *action,
1147 struct berval *naction,
1150 struct berval grantdeny,
1157 if ( acl_get_part( action, 0, ';', &grantdeny ) < 0 ) {
1158 Debug( LDAP_DEBUG_ACL, "aciNormalizeRight: missing ';' in '%s'\n", action->bv_val, 0, 0 );
1159 return LDAP_INVALID_SYNTAX;
1161 idx = bv_getcaseidx( &grantdeny, ACIgrantdeny );
1163 Debug( LDAP_DEBUG_ACL, "aciNormalizeRight: '%s' must be grant or deny\n", grantdeny.bv_val, 0, 0 );
1164 return LDAP_INVALID_SYNTAX;
1167 ber_dupbv_x( naction, (struct berval *)ACIgrantdeny[ idx ], ctx );
1169 for ( i = 1; acl_get_part( action, i, ';', &bv ) >= 0; i++ ) {
1170 struct berval nattrs = BER_BVNULL;
1174 if ( OpenLDAPaciValidatePerms( &bv ) != LDAP_SUCCESS )
1176 return LDAP_INVALID_SYNTAX;
1184 /* could be "[all]" or an attribute description */
1185 if ( ber_bvstrcasecmp( &bv, &aci_bv[ ACI_BV_BR_ALL ] ) == 0 ) {
1186 nattrs = aci_bv[ ACI_BV_BR_ALL ];
1190 AttributeDescription *ad = NULL;
1191 AttributeDescription adstatic= { 0 };
1192 const char *text = NULL;
1193 struct berval attr, left, right;
1197 for ( j = 0; acl_get_part( &bv, j, ',', &attr ) >= 0; j++ )
1201 /* openldap 2.1 aci compabitibility [entry] -> entry */
1202 if ( ber_bvstrcasecmp( &attr, &aci_bv[ ACI_BV_BR_ENTRY ] ) == 0 ) {
1204 adstatic.ad_cname = aci_bv[ ACI_BV_ENTRY ];
1206 /* openldap 2.1 aci compabitibility [children] -> children */
1207 } else if ( ber_bvstrcasecmp( &attr, &aci_bv[ ACI_BV_BR_CHILDREN ] ) == 0 ) {
1209 adstatic.ad_cname = aci_bv[ ACI_BV_CHILDREN ];
1211 /* openldap 2.1 aci compabitibility [all] -> only [all] */
1212 } else if ( ber_bvstrcasecmp( &attr, &aci_bv[ ACI_BV_BR_ALL ] ) == 0 ) {
1213 ber_memfree_x( nattrs.bv_val, ctx );
1214 nattrs = aci_bv[ ACI_BV_BR_ALL ];
1218 } else if ( acl_get_part( &attr, 0, '=', &left ) < 0
1219 || acl_get_part( &attr, 1, '=', &right ) < 0 )
1221 if ( slap_bv2ad( &attr, &ad, &text ) != LDAP_SUCCESS )
1223 ber_memfree_x( nattrs.bv_val, ctx );
1224 Debug( LDAP_DEBUG_ACL, "aciNormalizeRight: unknown attribute: '%s'\n", attr.bv_val, 0, 0 );
1225 return LDAP_INVALID_SYNTAX;
1229 if ( slap_bv2ad( &left, &ad, &text ) != LDAP_SUCCESS )
1231 ber_memfree_x( nattrs.bv_val, ctx );
1232 Debug( LDAP_DEBUG_ACL, "aciNormalizeRight: unknown attribute: '%s'\n", left.bv_val, 0, 0 );
1233 return LDAP_INVALID_SYNTAX;
1238 len = nattrs.bv_len + ( !BER_BVISEMPTY( &nattrs ) ? STRLENOF( "," ) : 0 )
1239 + ad->ad_cname.bv_len;
1240 nattrs.bv_val = ber_memrealloc_x( nattrs.bv_val, len + 1, ctx );
1241 ptr = &nattrs.bv_val[ nattrs.bv_len ];
1242 if ( !BER_BVISEMPTY( &nattrs ) ) {
1245 ptr = lutil_strncopy( ptr, ad->ad_cname.bv_val, ad->ad_cname.bv_len );
1247 nattrs.bv_len = len;
1252 naction->bv_val = ber_memrealloc_x( naction->bv_val,
1253 naction->bv_len + STRLENOF( ";" )
1254 + perms.bv_len + STRLENOF( ";" )
1255 + nattrs.bv_len + 1,
1258 ptr = &naction->bv_val[ naction->bv_len ];
1261 ptr = lutil_strncopy( ptr, perms.bv_val, perms.bv_len );
1264 ptr = lutil_strncopy( ptr, nattrs.bv_val, nattrs.bv_len );
1266 naction->bv_len += STRLENOF( ";" ) + perms.bv_len
1267 + STRLENOF( ";" ) + nattrs.bv_len;
1269 ber_memfree_x( nattrs.bv_val, ctx );
1274 /* perms;attr go in pairs */
1275 if ( i > 1 && ( i & 1 ) ) {
1276 return LDAP_SUCCESS;
1279 Debug( LDAP_DEBUG_ACL, "aciNormalizeRight: perms:attr need to be pairs in '%s'\n", action->bv_val, 0, 0 );
1280 return LDAP_INVALID_SYNTAX;
1285 OpenLDAPaciValidateRights(
1286 struct berval *actions )
1289 struct berval bv = BER_BVNULL;
1292 for ( i = 0; acl_get_part( actions, i, '$', &bv ) >= 0; i++ ) {
1293 if ( OpenLDAPaciValidateRight( &bv ) != LDAP_SUCCESS ) {
1294 return LDAP_INVALID_SYNTAX;
1298 return LDAP_SUCCESS;
1302 OpenLDAPaciNormalizeRights(
1303 struct berval *actions,
1304 struct berval *nactions,
1308 struct berval bv = BER_BVNULL;
1311 BER_BVZERO( nactions );
1312 for ( i = 0; acl_get_part( actions, i, '$', &bv ) >= 0; i++ ) {
1316 rc = OpenLDAPaciNormalizeRight( &bv, &nbv, ctx );
1317 if ( rc != LDAP_SUCCESS ) {
1318 ber_memfree_x( nactions->bv_val, ctx );
1319 BER_BVZERO( nactions );
1320 return LDAP_INVALID_SYNTAX;
1327 nactions->bv_val = ber_memrealloc_x( nactions->bv_val,
1328 nactions->bv_len + STRLENOF( "$" )
1331 nactions->bv_val[ nactions->bv_len ] = '$';
1332 AC_MEMCPY( &nactions->bv_val[ nactions->bv_len + 1 ],
1333 nbv.bv_val, nbv.bv_len + 1 );
1334 ber_memfree_x( nbv.bv_val, ctx );
1335 nactions->bv_len += STRLENOF( "$" ) + nbv.bv_len;
1340 return LDAP_SUCCESS;
1343 static const struct berval *OpenLDAPaciscopes[] = {
1344 &aci_bv[ ACI_BV_ENTRY ],
1345 &aci_bv[ ACI_BV_CHILDREN ],
1346 &aci_bv[ ACI_BV_SUBTREE ],
1351 static const struct berval *OpenLDAPacitypes[] = {
1353 &aci_bv[ ACI_BV_GROUP ],
1354 &aci_bv[ ACI_BV_ROLE ],
1356 /* set to one past the last DN-valued type with options (/) */
1357 #define LAST_OPTIONAL 2
1359 &aci_bv[ ACI_BV_ACCESS_ID ],
1360 &aci_bv[ ACI_BV_SUBTREE ],
1361 &aci_bv[ ACI_BV_ONELEVEL ],
1362 &aci_bv[ ACI_BV_CHILDREN ],
1364 /* set to one past the last DN-valued type */
1365 #define LAST_DNVALUED 6
1368 &aci_bv[ ACI_BV_DNATTR ],
1369 &aci_bv[ ACI_BV_PUBLIC ],
1370 &aci_bv[ ACI_BV_USERS ],
1371 &aci_bv[ ACI_BV_SELF ],
1372 &aci_bv[ ACI_BV_SET ],
1373 &aci_bv[ ACI_BV_SET_REF ],
1379 OpenLDAPaciValidate(
1381 struct berval *val )
1383 struct berval oid = BER_BVNULL,
1385 rights = BER_BVNULL,
1387 subject = BER_BVNULL;
1391 if ( BER_BVISEMPTY( val ) ) {
1392 Debug( LDAP_DEBUG_ACL, "aciValidatet: value is empty\n", 0, 0, 0 );
1393 return LDAP_INVALID_SYNTAX;
1397 if ( acl_get_part( val, 0, '#', &oid ) < 0 ||
1398 numericoidValidate( NULL, &oid ) != LDAP_SUCCESS )
1400 /* NOTE: the numericoidValidate() is rather pedantic;
1401 * I'd replace it with X-ORDERED VALUES so that
1402 * it's guaranteed values are maintained and used
1403 * in the desired order */
1404 Debug( LDAP_DEBUG_ACL, "aciValidate: invalid oid '%s'\n", oid.bv_val, 0, 0 );
1405 return LDAP_INVALID_SYNTAX;
1409 if ( acl_get_part( val, 1, '#', &scope ) < 0 ||
1410 bv_getcaseidx( &scope, OpenLDAPaciscopes ) == -1 )
1412 Debug( LDAP_DEBUG_ACL, "aciValidate: invalid scope '%s'\n", scope.bv_val, 0, 0 );
1413 return LDAP_INVALID_SYNTAX;
1417 if ( acl_get_part( val, 2, '#', &rights ) < 0 ||
1418 OpenLDAPaciValidateRights( &rights ) != LDAP_SUCCESS )
1420 return LDAP_INVALID_SYNTAX;
1424 if ( acl_get_part( val, 3, '#', &type ) < 0 ) {
1425 Debug( LDAP_DEBUG_ACL, "aciValidate: missing type in '%s'\n", val->bv_val, 0, 0 );
1426 return LDAP_INVALID_SYNTAX;
1428 idx = bv_getcaseidx( &type, OpenLDAPacitypes );
1432 if ( acl_get_part( &type, 0, '/', &isgr ) < 0 ) {
1433 Debug( LDAP_DEBUG_ACL, "aciValidate: invalid type '%s'\n", type.bv_val, 0, 0 );
1434 return LDAP_INVALID_SYNTAX;
1437 idx = bv_getcaseidx( &isgr, OpenLDAPacitypes );
1438 if ( idx == -1 || idx >= LAST_OPTIONAL ) {
1439 Debug( LDAP_DEBUG_ACL, "aciValidate: invalid type '%s'\n", isgr.bv_val, 0, 0 );
1440 return LDAP_INVALID_SYNTAX;
1445 bv_get_tail( val, &type, &subject );
1446 if ( subject.bv_val[ 0 ] != '#' ) {
1447 Debug( LDAP_DEBUG_ACL, "aciValidate: missing subject in '%s'\n", val->bv_val, 0, 0 );
1448 return LDAP_INVALID_SYNTAX;
1451 if ( idx >= LAST_DNVALUED ) {
1452 if ( OpenLDAPacitypes[ idx ] == &aci_bv[ ACI_BV_DNATTR ] ) {
1453 AttributeDescription *ad = NULL;
1454 const char *text = NULL;
1456 rc = slap_bv2ad( &subject, &ad, &text );
1457 if ( rc != LDAP_SUCCESS ) {
1458 Debug( LDAP_DEBUG_ACL, "aciValidate: unknown dn attribute '%s'\n", subject.bv_val, 0, 0 );
1459 return LDAP_INVALID_SYNTAX;
1462 if ( ad->ad_type->sat_syntax != slap_schema.si_syn_distinguishedName ) {
1463 /* FIXME: allow nameAndOptionalUID? */
1464 Debug( LDAP_DEBUG_ACL, "aciValidate: wrong syntax for dn attribute '%s'\n", subject.bv_val, 0, 0 );
1465 return LDAP_INVALID_SYNTAX;
1470 return LDAP_SUCCESS;
1472 } else if ( OpenLDAPacitypes[ idx ] == &aci_bv[ ACI_BV_GROUP ]
1473 || OpenLDAPacitypes[ idx ] == &aci_bv[ ACI_BV_ROLE ] )
1475 /* do {group|role}/oc/at check */
1476 struct berval ocbv = BER_BVNULL,
1479 ocbv.bv_val = ber_bvchr( &type, '/' );
1480 if ( ocbv.bv_val != NULL ) {
1482 ocbv.bv_len = type.bv_len
1483 - ( ocbv.bv_val - type.bv_val );
1485 atbv.bv_val = ber_bvchr( &ocbv, '/' );
1486 if ( atbv.bv_val != NULL ) {
1487 AttributeDescription *ad = NULL;
1488 const char *text = NULL;
1492 atbv.bv_len = type.bv_len
1493 - ( atbv.bv_val - type.bv_val );
1494 ocbv.bv_len = atbv.bv_val - ocbv.bv_val - 1;
1496 rc = slap_bv2ad( &atbv, &ad, &text );
1497 if ( rc != LDAP_SUCCESS ) {
1498 Debug( LDAP_DEBUG_ACL, "aciValidate: unknown group attribute '%s'\n", atbv.bv_val, 0, 0 );
1499 return LDAP_INVALID_SYNTAX;
1503 if ( oc_bvfind( &ocbv ) == NULL ) {
1504 Debug( LDAP_DEBUG_ACL, "aciValidate: unknown group '%s'\n", ocbv.bv_val, 0, 0 );
1505 return LDAP_INVALID_SYNTAX;
1510 if ( BER_BVISEMPTY( &subject ) ) {
1511 /* empty DN invalid */
1512 Debug( LDAP_DEBUG_ACL, "aciValidate: missing dn in '%s'\n", val->bv_val, 0, 0 );
1513 return LDAP_INVALID_SYNTAX;
1519 /* FIXME: pass DN syntax? */
1520 rc = dnValidate( NULL, &subject );
1521 if ( rc != LDAP_SUCCESS ) {
1522 Debug( LDAP_DEBUG_ACL, "aciValidate: invalid dn '%s'\n", subject.bv_val, 0, 0 );
1528 OpenLDAPaciPrettyNormal(
1534 struct berval oid = BER_BVNULL,
1536 rights = BER_BVNULL,
1537 nrights = BER_BVNULL,
1540 subject = BER_BVNULL,
1541 nsubject = BER_BVNULL;
1548 if ( BER_BVISEMPTY( val ) ) {
1549 Debug( LDAP_DEBUG_ACL, "aciPrettyNormal: value is empty\n", 0, 0, 0 );
1550 return LDAP_INVALID_SYNTAX;
1553 /* oid: if valid, it's already normalized */
1554 if ( acl_get_part( val, 0, '#', &oid ) < 0 ||
1555 numericoidValidate( NULL, &oid ) != LDAP_SUCCESS )
1557 Debug( LDAP_DEBUG_ACL, "aciPrettyNormal: invalid oid '%s'\n", oid.bv_val, 0, 0 );
1558 return LDAP_INVALID_SYNTAX;
1561 /* scope: normalize by replacing with OpenLDAPaciscopes */
1562 if ( acl_get_part( val, 1, '#', &scope ) < 0 ) {
1563 Debug( LDAP_DEBUG_ACL, "aciPrettyNormal: missing scope in '%s'\n", val->bv_val, 0, 0 );
1564 return LDAP_INVALID_SYNTAX;
1566 idx = bv_getcaseidx( &scope, OpenLDAPaciscopes );
1568 Debug( LDAP_DEBUG_ACL, "aciPrettyNormal: invalid scope '%s'\n", scope.bv_val, 0, 0 );
1569 return LDAP_INVALID_SYNTAX;
1571 scope = *OpenLDAPaciscopes[ idx ];
1574 if ( acl_get_part( val, 2, '#', &rights ) < 0 ) {
1575 Debug( LDAP_DEBUG_ACL, "aciPrettyNormal: missing rights in '%s'\n", val->bv_val, 0, 0 );
1576 return LDAP_INVALID_SYNTAX;
1578 if ( OpenLDAPaciNormalizeRights( &rights, &nrights, ctx )
1581 return LDAP_INVALID_SYNTAX;
1585 if ( acl_get_part( val, 3, '#', &type ) < 0 ) {
1586 Debug( LDAP_DEBUG_ACL, "aciPrettyNormal: missing type in '%s'\n", val->bv_val, 0, 0 );
1587 rc = LDAP_INVALID_SYNTAX;
1590 idx = bv_getcaseidx( &type, OpenLDAPacitypes );
1594 if ( acl_get_part( &type, 0, '/', &isgr ) < 0 ) {
1595 Debug( LDAP_DEBUG_ACL, "aciPrettyNormal: invalid type '%s'\n", type.bv_val, 0, 0 );
1596 rc = LDAP_INVALID_SYNTAX;
1600 idx = bv_getcaseidx( &isgr, OpenLDAPacitypes );
1601 if ( idx == -1 || idx >= LAST_OPTIONAL ) {
1602 Debug( LDAP_DEBUG_ACL, "aciPrettyNormal: invalid type '%s'\n", isgr.bv_val, 0, 0 );
1603 rc = LDAP_INVALID_SYNTAX;
1607 ntype = *OpenLDAPacitypes[ idx ];
1610 bv_get_tail( val, &type, &subject );
1612 if ( BER_BVISEMPTY( &subject ) || subject.bv_val[ 0 ] != '#' ) {
1613 Debug( LDAP_DEBUG_ACL, "aciPrettyNormal: missing subject in '%s'\n", val->bv_val, 0, 0 );
1614 rc = LDAP_INVALID_SYNTAX;
1621 if ( idx < LAST_DNVALUED ) {
1622 /* FIXME: pass DN syntax? */
1624 rc = dnNormalize( 0, NULL, NULL,
1625 &subject, &nsubject, ctx );
1627 rc = dnPretty( NULL, &subject, &nsubject, ctx );
1630 if ( rc == LDAP_SUCCESS ) {
1634 Debug( LDAP_DEBUG_ACL, "aciPrettyNormal: invalid subject dn '%s'\n", subject.bv_val, 0, 0 );
1638 if ( OpenLDAPacitypes[ idx ] == &aci_bv[ ACI_BV_GROUP ]
1639 || OpenLDAPacitypes[ idx ] == &aci_bv[ ACI_BV_ROLE ] )
1641 /* do {group|role}/oc/at check */
1642 struct berval ocbv = BER_BVNULL,
1645 ocbv.bv_val = ber_bvchr( &type, '/' );
1646 if ( ocbv.bv_val != NULL ) {
1647 ObjectClass *oc = NULL;
1648 AttributeDescription *ad = NULL;
1649 const char *text = NULL;
1653 bv.bv_len = ntype.bv_len;
1656 ocbv.bv_len = type.bv_len - ( ocbv.bv_val - type.bv_val );
1658 atbv.bv_val = ber_bvchr( &ocbv, '/' );
1659 if ( atbv.bv_val != NULL ) {
1661 atbv.bv_len = type.bv_len
1662 - ( atbv.bv_val - type.bv_val );
1663 ocbv.bv_len = atbv.bv_val - ocbv.bv_val - 1;
1665 rc = slap_bv2ad( &atbv, &ad, &text );
1666 if ( rc != LDAP_SUCCESS ) {
1667 Debug( LDAP_DEBUG_ACL, "aciPrettyNormal: unknown group attribute '%s'\n", atbv.bv_val, 0, 0 );
1668 rc = LDAP_INVALID_SYNTAX;
1672 bv.bv_len += STRLENOF( "/" ) + ad->ad_cname.bv_len;
1675 oc = oc_bvfind( &ocbv );
1677 Debug( LDAP_DEBUG_ACL, "aciPrettyNormal: invalid group '%s'\n", ocbv.bv_val, 0, 0 );
1678 rc = LDAP_INVALID_SYNTAX;
1682 bv.bv_len += STRLENOF( "/" ) + oc->soc_cname.bv_len;
1683 bv.bv_val = ber_memalloc_x( bv.bv_len + 1, ctx );
1686 ptr = lutil_strncopy( ptr, ntype.bv_val, ntype.bv_len );
1689 ptr = lutil_strncopy( ptr,
1690 oc->soc_cname.bv_val,
1691 oc->soc_cname.bv_len );
1695 ptr = lutil_strncopy( ptr,
1696 ad->ad_cname.bv_val,
1697 ad->ad_cname.bv_len );
1706 } else if ( OpenLDAPacitypes[ idx ] == &aci_bv[ ACI_BV_DNATTR ] ) {
1707 AttributeDescription *ad = NULL;
1708 const char *text = NULL;
1711 rc = slap_bv2ad( &subject, &ad, &text );
1712 if ( rc != LDAP_SUCCESS ) {
1713 Debug( LDAP_DEBUG_ACL, "aciPrettyNormal: unknown dn attribute '%s'\n", subject.bv_val, 0, 0 );
1714 rc = LDAP_INVALID_SYNTAX;
1718 if ( ad->ad_type->sat_syntax != slap_schema.si_syn_distinguishedName ) {
1719 /* FIXME: allow nameAndOptionalUID? */
1720 Debug( LDAP_DEBUG_ACL, "aciPrettyNormal: wrong syntax for dn attribute '%s'\n", subject.bv_val, 0, 0 );
1721 rc = LDAP_INVALID_SYNTAX;
1725 nsubject = ad->ad_cname;
1730 oid.bv_len + STRLENOF( "#" )
1731 + scope.bv_len + STRLENOF( "#" )
1732 + nrights.bv_len + STRLENOF( "#" )
1733 + ntype.bv_len + STRLENOF( "#" )
1736 out->bv_val = ber_memalloc_x( out->bv_len + 1, ctx );
1737 ptr = lutil_strncopy( out->bv_val, oid.bv_val, oid.bv_len );
1740 ptr = lutil_strncopy( ptr, scope.bv_val, scope.bv_len );
1743 ptr = lutil_strncopy( ptr, nrights.bv_val, nrights.bv_len );
1746 ptr = lutil_strncopy( ptr, ntype.bv_val, ntype.bv_len );
1749 if ( !BER_BVISNULL( &nsubject ) ) {
1750 ptr = lutil_strncopy( ptr, nsubject.bv_val, nsubject.bv_len );
1755 if ( freesubject ) {
1756 ber_memfree_x( nsubject.bv_val, ctx );
1760 ber_memfree_x( ntype.bv_val, ctx );
1763 if ( !BER_BVISNULL( &nrights ) ) {
1764 ber_memfree_x( nrights.bv_val, ctx );
1777 return OpenLDAPaciPrettyNormal( val, out, ctx, 0 );
1781 OpenLDAPaciNormalize(
1789 return OpenLDAPaciPrettyNormal( val, out, ctx, 1 );
1792 #if SLAPD_ACI_ENABLED == SLAPD_MOD_DYNAMIC
1794 * FIXME: need config and Makefile.am code to ease building
1798 init_module( int argc, char *argv[] )
1800 return dynacl_aci_init();
1802 #endif /* SLAPD_ACI_ENABLED == SLAPD_MOD_DYNAMIC */
1804 #endif /* SLAPD_ACI_ENABLED */