1 /* aclparse.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.
33 #include <ac/socket.h>
34 #include <ac/string.h>
35 #include <ac/unistd.h>
41 static const char style_base[] = "base";
42 char *style_strings[] = {
59 static void split(char *line, int splitchar, char **left, char **right);
60 static void access_append(Access **l, Access *a);
61 static int acl_usage(void);
63 static void acl_regex_normalized_dn(const char *src, struct berval *pat);
66 static void print_acl(Backend *be, AccessControl *a);
69 static int check_scope( BackendDB *be, AccessControl *a );
82 slap_dynacl_t *da, *tmp;
85 for ( da = b->a_dynacl; da; da = da->da_next ) {
86 if ( strcasecmp( da->da_name, name ) == 0 ) {
87 Debug( LDAP_DEBUG_ANY,
88 "%s: line %d: dynacl \"%s\" already specified.\n",
89 fname, lineno, name );
94 da = slap_dynacl_get( name );
99 tmp = ch_malloc( sizeof( slap_dynacl_t ) );
102 if ( tmp->da_parse ) {
103 rc = ( *tmp->da_parse )( fname, lineno, opts, sty, right, &tmp->da_private );
110 tmp->da_next = b->a_dynacl;
115 #endif /* SLAP_DYNACL */
118 regtest(const char *fname, int lineno, char *pat) {
122 char buf[ SLAP_TEXT_BUFLEN ];
134 for (size = 0, flag = 0; (size < sizeof(buf)) && *sp; sp++) {
136 if (*sp == '$'|| (*sp >= '0' && *sp <= '9')) {
153 if ( size >= (sizeof(buf) - 1) ) {
154 Debug( LDAP_DEBUG_ANY,
155 "%s: line %d: regular expression \"%s\" too large\n",
156 fname, lineno, pat );
158 exit( EXIT_FAILURE );
161 if ((e = regcomp(&re, buf, REG_EXTENDED|REG_ICASE))) {
162 char error[ SLAP_TEXT_BUFLEN ];
164 regerror(e, &re, error, sizeof(error));
166 snprintf( buf, sizeof( buf ),
167 "regular expression \"%s\" bad because of %s",
169 Debug( LDAP_DEBUG_ANY,
171 fname, lineno, buf );
173 exit( EXIT_FAILURE );
181 * Check if the pattern of an ACL, if any, matches the scope
182 * of the backend it is defined within.
184 #define ACL_SCOPE_UNKNOWN (-2)
185 #define ACL_SCOPE_ERR (-1)
186 #define ACL_SCOPE_OK (0)
187 #define ACL_SCOPE_PARTIAL (1)
188 #define ACL_SCOPE_WARN (2)
191 check_scope( BackendDB *be, AccessControl *a )
196 dn = be->be_nsuffix[0];
198 if ( BER_BVISEMPTY( &dn ) ) {
202 if ( !BER_BVISEMPTY( &a->acl_dn_pat ) ||
203 a->acl_dn_style != ACL_STYLE_REGEX )
205 slap_style_t style = a->acl_dn_style;
207 if ( style == ACL_STYLE_REGEX ) {
208 char dnbuf[SLAP_LDAPDN_MAXLEN + 2];
209 char rebuf[SLAP_LDAPDN_MAXLEN + 1];
214 /* add trailing '$' to database suffix to form
215 * a simple trial regex pattern "<suffix>$" */
216 AC_MEMCPY( dnbuf, be->be_nsuffix[0].bv_val,
217 be->be_nsuffix[0].bv_len );
218 dnbuf[be->be_nsuffix[0].bv_len] = '$';
219 dnbuf[be->be_nsuffix[0].bv_len + 1] = '\0';
221 if ( regcomp( &re, dnbuf, REG_EXTENDED|REG_ICASE ) ) {
222 return ACL_SCOPE_WARN;
225 /* remove trailing ')$', if any, from original
227 rebuflen = a->acl_dn_pat.bv_len;
228 AC_MEMCPY( rebuf, a->acl_dn_pat.bv_val, rebuflen + 1 );
229 if ( rebuf[rebuflen - 1] == '$' ) {
230 rebuf[--rebuflen] = '\0';
232 while ( rebuflen > be->be_nsuffix[0].bv_len && rebuf[rebuflen - 1] == ')' ) {
233 rebuf[--rebuflen] = '\0';
235 if ( rebuflen == be->be_nsuffix[0].bv_len ) {
240 /* not a clear indication of scoping error, though */
241 rc = regexec( &re, rebuf, 0, NULL, 0 )
242 ? ACL_SCOPE_WARN : ACL_SCOPE_OK;
249 patlen = a->acl_dn_pat.bv_len;
250 /* If backend suffix is longer than pattern,
251 * it is a potential mismatch (in the sense
252 * that a superior naming context could
254 if ( dn.bv_len > patlen ) {
255 /* base is blatantly wrong */
256 if ( style == ACL_STYLE_BASE ) return ACL_SCOPE_ERR;
258 /* a style of one can be wrong if there is
259 * more than one level between the suffix
261 if ( style == ACL_STYLE_ONE ) {
262 ber_len_t rdnlen = 0;
266 if ( !DN_SEPARATOR( dn.bv_val[dn.bv_len - patlen - 1] )) {
267 return ACL_SCOPE_ERR;
272 rdnlen = dn_rdnlen( NULL, &dn );
273 if ( rdnlen != dn.bv_len - patlen - sep )
274 return ACL_SCOPE_ERR;
277 /* if the trailing part doesn't match,
278 * then it's an error */
279 if ( strcmp( a->acl_dn_pat.bv_val,
280 &dn.bv_val[dn.bv_len - patlen] ) != 0 )
282 return ACL_SCOPE_ERR;
285 return ACL_SCOPE_PARTIAL;
291 case ACL_STYLE_CHILDREN:
292 case ACL_STYLE_SUBTREE:
300 if ( dn.bv_len < patlen &&
301 !DN_SEPARATOR( a->acl_dn_pat.bv_val[patlen - dn.bv_len - 1] ))
303 return ACL_SCOPE_ERR;
306 if ( strcmp( &a->acl_dn_pat.bv_val[patlen - dn.bv_len], dn.bv_val )
309 return ACL_SCOPE_ERR;
315 return ACL_SCOPE_UNKNOWN;
328 char *left, *right, *style;
336 for ( i = 1; i < argc; i++ ) {
337 /* to clause - select which entries are protected */
338 if ( strcasecmp( argv[i], "to" ) == 0 ) {
340 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
341 "only one to clause allowed in access line\n",
345 a = (AccessControl *) ch_calloc( 1, sizeof(AccessControl) );
346 for ( ++i; i < argc; i++ ) {
347 if ( strcasecmp( argv[i], "by" ) == 0 ) {
352 if ( strcasecmp( argv[i], "*" ) == 0 ) {
353 if ( !BER_BVISEMPTY( &a->acl_dn_pat ) ||
354 a->acl_dn_style != ACL_STYLE_REGEX )
356 Debug( LDAP_DEBUG_ANY,
357 "%s: line %d: dn pattern"
358 " already specified in to clause.\n",
363 ber_str2bv( "*", STRLENOF( "*" ), 1, &a->acl_dn_pat );
367 split( argv[i], '=', &left, &right );
368 split( left, '.', &left, &style );
370 if ( right == NULL ) {
371 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
372 "missing \"=\" in \"%s\" in to clause\n",
373 fname, lineno, left );
377 if ( strcasecmp( left, "dn" ) == 0 ) {
378 if ( !BER_BVISEMPTY( &a->acl_dn_pat ) ||
379 a->acl_dn_style != ACL_STYLE_REGEX )
381 Debug( LDAP_DEBUG_ANY,
382 "%s: line %d: dn pattern"
383 " already specified in to clause.\n",
388 if ( style == NULL || *style == '\0' ||
389 strcasecmp( style, "baseObject" ) == 0 ||
390 strcasecmp( style, "base" ) == 0 ||
391 strcasecmp( style, "exact" ) == 0 )
393 a->acl_dn_style = ACL_STYLE_BASE;
394 ber_str2bv( right, 0, 1, &a->acl_dn_pat );
396 } else if ( strcasecmp( style, "oneLevel" ) == 0 ||
397 strcasecmp( style, "one" ) == 0 )
399 a->acl_dn_style = ACL_STYLE_ONE;
400 ber_str2bv( right, 0, 1, &a->acl_dn_pat );
402 } else if ( strcasecmp( style, "subtree" ) == 0 ||
403 strcasecmp( style, "sub" ) == 0 )
405 if( *right == '\0' ) {
406 ber_str2bv( "*", STRLENOF( "*" ), 1, &a->acl_dn_pat );
409 a->acl_dn_style = ACL_STYLE_SUBTREE;
410 ber_str2bv( right, 0, 1, &a->acl_dn_pat );
413 } else if ( strcasecmp( style, "children" ) == 0 ) {
414 a->acl_dn_style = ACL_STYLE_CHILDREN;
415 ber_str2bv( right, 0, 1, &a->acl_dn_pat );
417 } else if ( strcasecmp( style, "regex" ) == 0 ) {
418 a->acl_dn_style = ACL_STYLE_REGEX;
420 if ( *right == '\0' ) {
421 /* empty regex should match empty DN */
422 a->acl_dn_style = ACL_STYLE_BASE;
423 ber_str2bv( right, 0, 1, &a->acl_dn_pat );
425 } else if ( strcmp(right, "*") == 0
426 || strcmp(right, ".*") == 0
427 || strcmp(right, ".*$") == 0
428 || strcmp(right, "^.*") == 0
429 || strcmp(right, "^.*$") == 0
430 || strcmp(right, ".*$$") == 0
431 || strcmp(right, "^.*$$") == 0 )
433 ber_str2bv( "*", STRLENOF("*"), 1, &a->acl_dn_pat );
436 acl_regex_normalized_dn( right, &a->acl_dn_pat );
440 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
441 "unknown dn style \"%s\" in to clause\n",
442 fname, lineno, style );
449 if ( strcasecmp( left, "filter" ) == 0 ) {
450 if ( (a->acl_filter = str2filter( right )) == NULL ) {
451 Debug( LDAP_DEBUG_ANY,
452 "%s: line %d: bad filter \"%s\" in to clause\n",
453 fname, lineno, right );
457 } else if ( strcasecmp( left, "attr" ) == 0 /* TOLERATED */
458 || strcasecmp( left, "attrs" ) == 0 ) /* DOCUMENTED */
460 if ( strcasecmp( left, "attr" ) == 0 ) {
461 Debug( LDAP_DEBUG_ANY,
462 "%s: line %d: \"attr\" "
463 "is deprecated (and undocumented); "
464 "use \"attrs\" instead.\n",
468 a->acl_attrs = str2anlist( a->acl_attrs,
470 if ( a->acl_attrs == NULL ) {
471 Debug( LDAP_DEBUG_ANY,
472 "%s: line %d: unknown attr \"%s\" in to clause\n",
473 fname, lineno, right );
477 } else if ( strncasecmp( left, "val", 3 ) == 0 ) {
481 if ( !BER_BVISEMPTY( &a->acl_attrval ) ) {
482 Debug( LDAP_DEBUG_ANY,
483 "%s: line %d: attr val already specified in to clause.\n",
487 if ( a->acl_attrs == NULL || !BER_BVISEMPTY( &a->acl_attrs[1].an_name ) )
489 Debug( LDAP_DEBUG_ANY,
490 "%s: line %d: attr val requires a single attribute.\n",
495 ber_str2bv( right, 0, 0, &bv );
496 a->acl_attrval_style = ACL_STYLE_BASE;
498 mr = strchr( left, '/' );
503 a->acl_attrval_mr = mr_find( mr );
504 if ( a->acl_attrval_mr == NULL ) {
505 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
506 "invalid matching rule \"%s\".\n",
511 if( !mr_usable_with_at( a->acl_attrval_mr, a->acl_attrs[ 0 ].an_desc->ad_type ) )
513 char buf[ SLAP_TEXT_BUFLEN ];
515 snprintf( buf, sizeof( buf ),
516 "matching rule \"%s\" use "
517 "with attr \"%s\" not appropriate.",
518 mr, a->acl_attrs[ 0 ].an_name.bv_val );
521 Debug( LDAP_DEBUG_ANY, "%s: line %d: %s\n",
522 fname, lineno, buf );
527 if ( style != NULL ) {
528 if ( strcasecmp( style, "regex" ) == 0 ) {
529 int e = regcomp( &a->acl_attrval_re, bv.bv_val,
530 REG_EXTENDED | REG_ICASE | REG_NOSUB );
532 char err[SLAP_TEXT_BUFLEN],
533 buf[ SLAP_TEXT_BUFLEN ];
535 regerror( e, &a->acl_attrval_re, err, sizeof( err ) );
537 snprintf( buf, sizeof( buf ),
538 "regular expression \"%s\" bad because of %s",
541 Debug( LDAP_DEBUG_ANY, "%s: line %d: %s\n",
542 fname, lineno, buf );
545 a->acl_attrval_style = ACL_STYLE_REGEX;
548 /* FIXME: if the attribute has DN syntax, we might
549 * allow one, subtree and children styles as well */
550 if ( !strcasecmp( style, "base" ) ||
551 !strcasecmp( style, "exact" ) ) {
552 a->acl_attrval_style = ACL_STYLE_BASE;
554 } else if ( a->acl_attrs[0].an_desc->ad_type->
555 sat_syntax == slap_schema.si_syn_distinguishedName )
557 if ( !strcasecmp( style, "baseObject" ) ||
558 !strcasecmp( style, "base" ) )
560 a->acl_attrval_style = ACL_STYLE_BASE;
561 } else if ( !strcasecmp( style, "onelevel" ) ||
562 !strcasecmp( style, "one" ) )
564 a->acl_attrval_style = ACL_STYLE_ONE;
565 } else if ( !strcasecmp( style, "subtree" ) ||
566 !strcasecmp( style, "sub" ) )
568 a->acl_attrval_style = ACL_STYLE_SUBTREE;
569 } else if ( !strcasecmp( style, "children" ) ) {
570 a->acl_attrval_style = ACL_STYLE_CHILDREN;
572 char buf[ SLAP_TEXT_BUFLEN ];
574 /* FIXME: should be an error */
576 snprintf( buf, sizeof( buf ),
577 "unknown val.<style> \"%s\" "
578 "for attributeType \"%s\" with DN syntax"
579 #ifndef SLAPD_CONF_UNKNOWN_BAILOUT
581 #endif /* ! SLAPD_CONF_UNKNOWN_BAILOUT */
582 SLAPD_CONF_UNKNOWN_IGNORED ".",
584 a->acl_attrs[0].an_desc->ad_cname.bv_val );
586 Debug( LDAP_DEBUG_CONFIG | LDAP_DEBUG_ACL,
588 fname, lineno, buf );
589 #ifdef SLAPD_CONF_UNKNOWN_BAILOUT
591 #endif /* SLAPD_CONF_UNKNOWN_BAILOUT */
592 a->acl_attrval_style = ACL_STYLE_BASE;
595 rc = dnNormalize( 0, NULL, NULL, &bv, &a->acl_attrval, NULL );
596 if ( rc != LDAP_SUCCESS ) {
597 char buf[ SLAP_TEXT_BUFLEN ];
599 snprintf( buf, sizeof( buf ),
600 "unable to normalize DN \"%s\" "
601 "for attributeType \"%s\" (%d).",
603 a->acl_attrs[0].an_desc->ad_cname.bv_val,
605 Debug( LDAP_DEBUG_ANY,
607 fname, lineno, buf );
612 char buf[ SLAP_TEXT_BUFLEN ];
614 /* FIXME: should be an error */
616 snprintf( buf, sizeof( buf ),
617 "unknown val.<style> \"%s\" "
618 "for attributeType \"%s\""
619 #ifndef SLAPD_CONF_UNKNOWN_BAILOUT
621 #endif /* ! SLAPD_CONF_UNKNOWN_BAILOUT */
622 SLAPD_CONF_UNKNOWN_IGNORED ".",
623 style, a->acl_attrs[0].an_desc->ad_cname.bv_val );
624 Debug( LDAP_DEBUG_CONFIG | LDAP_DEBUG_ACL,
626 fname, lineno, buf );
627 #ifdef SLAPD_CONF_UNKNOWN_BAILOUT
629 #endif /* SLAPD_CONF_UNKNOWN_BAILOUT */
630 a->acl_attrval_style = ACL_STYLE_BASE;
635 /* Check for appropriate matching rule */
636 if ( a->acl_attrval_style == ACL_STYLE_REGEX ) {
637 ber_dupbv( &a->acl_attrval, &bv );
639 } else if ( BER_BVISNULL( &a->acl_attrval ) ) {
643 if ( a->acl_attrval_mr == NULL ) {
644 a->acl_attrval_mr = a->acl_attrs[ 0 ].an_desc->ad_type->sat_equality;
647 if ( a->acl_attrval_mr == NULL ) {
648 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
649 "attr \"%s\" does not have an EQUALITY matching rule.\n",
650 fname, lineno, a->acl_attrs[ 0 ].an_name.bv_val );
654 rc = asserted_value_validate_normalize(
655 a->acl_attrs[ 0 ].an_desc,
657 SLAP_MR_EQUALITY|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
662 if ( rc != LDAP_SUCCESS ) {
663 char buf[ SLAP_TEXT_BUFLEN ];
665 snprintf( buf, sizeof( buf ), "%s: line %d: "
666 " attr \"%s\" normalization failed (%d: %s)",
667 a->acl_attrs[ 0 ].an_name.bv_val, rc, text );
668 Debug( LDAP_DEBUG_ANY, "%s: line %d: %s.\n",
669 fname, lineno, buf );
675 Debug( LDAP_DEBUG_ANY,
676 "%s: line %d: expecting <what> got \"%s\"\n",
677 fname, lineno, left );
682 if ( !BER_BVISNULL( &a->acl_dn_pat ) &&
683 ber_bvccmp( &a->acl_dn_pat, '*' ) )
685 free( a->acl_dn_pat.bv_val );
686 BER_BVZERO( &a->acl_dn_pat );
687 a->acl_dn_style = ACL_STYLE_REGEX;
690 if ( !BER_BVISEMPTY( &a->acl_dn_pat ) ||
691 a->acl_dn_style != ACL_STYLE_REGEX )
693 if ( a->acl_dn_style != ACL_STYLE_REGEX ) {
695 rc = dnNormalize( 0, NULL, NULL, &a->acl_dn_pat, &bv, NULL);
696 if ( rc != LDAP_SUCCESS ) {
697 Debug( LDAP_DEBUG_ANY,
698 "%s: line %d: bad DN \"%s\" in to DN clause\n",
699 fname, lineno, a->acl_dn_pat.bv_val );
702 free( a->acl_dn_pat.bv_val );
706 int e = regcomp( &a->acl_dn_re, a->acl_dn_pat.bv_val,
707 REG_EXTENDED | REG_ICASE );
709 char err[ SLAP_TEXT_BUFLEN ],
710 buf[ SLAP_TEXT_BUFLEN ];
712 regerror( e, &a->acl_dn_re, err, sizeof( err ) );
713 snprintf( buf, sizeof( buf ),
714 "regular expression \"%s\" bad because of %s",
716 Debug( LDAP_DEBUG_ANY, "%s: line %d: %s\n",
717 fname, lineno, buf );
723 /* by clause - select who has what access to entries */
724 } else if ( strcasecmp( argv[i], "by" ) == 0 ) {
726 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
727 "to clause required before by clause in access line\n",
733 * by clause consists of <who> and <access>
736 b = (Access *) ch_calloc( 1, sizeof(Access) );
738 ACL_INVALIDATE( b->a_access_mask );
741 Debug( LDAP_DEBUG_ANY,
742 "%s: line %d: premature EOL: expecting <who>\n",
748 for ( ; i < argc; i++ ) {
749 slap_style_t sty = ACL_STYLE_REGEX;
750 char *style_modifier = NULL;
751 char *style_level = NULL;
754 slap_dn_access *bdn = &b->a_dn;
757 split( argv[i], '=', &left, &right );
758 split( left, '.', &left, &style );
760 split( style, ',', &style, &style_modifier );
762 if ( strncasecmp( style, "level", STRLENOF( "level" ) ) == 0 ) {
763 split( style, '{', &style, &style_level );
764 if ( style_level != NULL ) {
765 char *p = strchr( style_level, '}' );
767 Debug( LDAP_DEBUG_ANY,
768 "%s: line %d: premature eol: "
769 "expecting closing '}' in \"level{n}\"\n",
772 } else if ( p == style_level ) {
773 Debug( LDAP_DEBUG_ANY,
774 "%s: line %d: empty level "
784 if ( style == NULL || *style == '\0' ||
785 strcasecmp( style, "exact" ) == 0 ||
786 strcasecmp( style, "baseObject" ) == 0 ||
787 strcasecmp( style, "base" ) == 0 )
789 sty = ACL_STYLE_BASE;
791 } else if ( strcasecmp( style, "onelevel" ) == 0 ||
792 strcasecmp( style, "one" ) == 0 )
796 } else if ( strcasecmp( style, "subtree" ) == 0 ||
797 strcasecmp( style, "sub" ) == 0 )
799 sty = ACL_STYLE_SUBTREE;
801 } else if ( strcasecmp( style, "children" ) == 0 ) {
802 sty = ACL_STYLE_CHILDREN;
804 } else if ( strcasecmp( style, "level" ) == 0 )
806 if ( lutil_atoi( &level, style_level ) != 0 ) {
807 Debug( LDAP_DEBUG_ANY,
808 "%s: line %d: unable to parse level "
814 sty = ACL_STYLE_LEVEL;
816 } else if ( strcasecmp( style, "regex" ) == 0 ) {
817 sty = ACL_STYLE_REGEX;
819 } else if ( strcasecmp( style, "expand" ) == 0 ) {
820 sty = ACL_STYLE_EXPAND;
822 } else if ( strcasecmp( style, "ip" ) == 0 ) {
825 } else if ( strcasecmp( style, "path" ) == 0 ) {
826 sty = ACL_STYLE_PATH;
827 #ifndef LDAP_PF_LOCAL
828 Debug( LDAP_DEBUG_CONFIG | LDAP_DEBUG_ACL,
830 "\"path\" style modifier is useless without local"
831 SLAPD_CONF_UNKNOWN_IGNORED ".\n",
833 #ifdef SLAPD_CONF_UNKNOWN_BAILOUT
835 #endif /* SLAPD_CONF_UNKNOWN_BAILOUT */
836 #endif /* LDAP_PF_LOCAL */
839 Debug( LDAP_DEBUG_ANY,
840 "%s: line %d: unknown style \"%s\" in by clause\n",
841 fname, lineno, style );
845 if ( style_modifier &&
846 strcasecmp( style_modifier, "expand" ) == 0 )
849 case ACL_STYLE_REGEX:
850 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
851 "\"regex\" style implies "
852 "\"expand\" modifier"
853 SLAPD_CONF_UNKNOWN_IGNORED ".\n",
855 #ifdef SLAPD_CONF_UNKNOWN_BAILOUT
857 #endif /* SLAPD_CONF_UNKNOWN_BAILOUT */
860 case ACL_STYLE_EXPAND:
864 /* we'll see later if it's pertinent */
870 /* expand in <who> needs regex in <what> */
871 if ( ( sty == ACL_STYLE_EXPAND || expand )
872 && a->acl_dn_style != ACL_STYLE_REGEX )
874 Debug( LDAP_DEBUG_CONFIG | LDAP_DEBUG_ACL, "%s: line %d: "
875 "\"expand\" style or modifier used "
876 "in conjunction with "
877 "a non-regex <what> clause"
878 SLAPD_CONF_UNKNOWN_IGNORED ".\n",
880 #ifdef SLAPD_CONF_UNKNOWN_BAILOUT
882 #endif /* SLAPD_CONF_UNKNOWN_BAILOUT */
885 if ( strncasecmp( left, "real", STRLENOF( "real" ) ) == 0 ) {
888 left += STRLENOF( "real" );
891 if ( strcasecmp( left, "*" ) == 0 ) {
896 ber_str2bv( "*", STRLENOF( "*" ), 1, &bv );
897 sty = ACL_STYLE_REGEX;
899 } else if ( strcasecmp( left, "anonymous" ) == 0 ) {
900 ber_str2bv("anonymous", STRLENOF( "anonymous" ), 1, &bv);
901 sty = ACL_STYLE_ANONYMOUS;
903 } else if ( strcasecmp( left, "users" ) == 0 ) {
904 ber_str2bv("users", STRLENOF( "users" ), 1, &bv);
905 sty = ACL_STYLE_USERS;
907 } else if ( strcasecmp( left, "self" ) == 0 ) {
908 ber_str2bv("self", STRLENOF( "self" ), 1, &bv);
909 sty = ACL_STYLE_SELF;
911 } else if ( strcasecmp( left, "dn" ) == 0 ) {
912 if ( sty == ACL_STYLE_REGEX ) {
913 bdn->a_style = ACL_STYLE_REGEX;
914 if ( right == NULL ) {
919 bdn->a_style = ACL_STYLE_USERS;
921 } else if (*right == '\0' ) {
923 ber_str2bv("anonymous",
924 STRLENOF( "anonymous" ),
926 bdn->a_style = ACL_STYLE_ANONYMOUS;
928 } else if ( strcmp( right, "*" ) == 0 ) {
930 /* any or users? users for now */
934 bdn->a_style = ACL_STYLE_USERS;
936 } else if ( strcmp( right, ".+" ) == 0
937 || strcmp( right, "^.+" ) == 0
938 || strcmp( right, ".+$" ) == 0
939 || strcmp( right, "^.+$" ) == 0
940 || strcmp( right, ".+$$" ) == 0
941 || strcmp( right, "^.+$$" ) == 0 )
946 bdn->a_style = ACL_STYLE_USERS;
948 } else if ( strcmp( right, ".*" ) == 0
949 || strcmp( right, "^.*" ) == 0
950 || strcmp( right, ".*$" ) == 0
951 || strcmp( right, "^.*$" ) == 0
952 || strcmp( right, ".*$$" ) == 0
953 || strcmp( right, "^.*$$" ) == 0 )
960 acl_regex_normalized_dn( right, &bv );
961 if ( !ber_bvccmp( &bv, '*' ) ) {
962 regtest( fname, lineno, bv.bv_val );
966 } else if ( right == NULL || *right == '\0' ) {
967 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
968 "missing \"=\" in (or value after) \"%s\" "
970 fname, lineno, left );
974 ber_str2bv( right, 0, 1, &bv );
981 if ( !BER_BVISNULL( &bv ) ) {
982 if ( !BER_BVISEMPTY( &bdn->a_pat ) ) {
983 Debug( LDAP_DEBUG_ANY,
984 "%s: line %d: dn pattern already specified.\n",
989 if ( sty != ACL_STYLE_REGEX &&
990 sty != ACL_STYLE_ANONYMOUS &&
991 sty != ACL_STYLE_USERS &&
992 sty != ACL_STYLE_SELF &&
995 rc = dnNormalize(0, NULL, NULL,
996 &bv, &bdn->a_pat, NULL);
997 if ( rc != LDAP_SUCCESS ) {
998 Debug( LDAP_DEBUG_ANY,
999 "%s: line %d: bad DN \"%s\" in by DN clause\n",
1000 fname, lineno, bv.bv_val );
1004 if ( sty == ACL_STYLE_BASE
1006 && !BER_BVISNULL( &be->be_rootndn )
1007 && dn_match( &bdn->a_pat, &be->be_rootndn ) )
1009 Debug( LDAP_DEBUG_ANY,
1010 "%s: line %d: rootdn is always granted "
1011 "unlimited privileges.\n",
1023 for ( exp = strchr( bdn->a_pat.bv_val, '$' );
1024 exp && (ber_len_t)(exp - bdn->a_pat.bv_val)
1025 < bdn->a_pat.bv_len;
1026 exp = strchr( exp, '$' ) )
1028 if ( isdigit( exp[ 1 ] ) ) {
1035 bdn->a_expand = expand;
1038 Debug( LDAP_DEBUG_ANY,
1039 "%s: line %d: \"expand\" used "
1040 "with no expansions in \"pattern\""
1041 SLAPD_CONF_UNKNOWN_IGNORED ".\n",
1043 #ifdef SLAPD_CONF_UNKNOWN_BAILOUT
1045 #endif /* SLAPD_CONF_UNKNOWN_BAILOUT */
1048 if ( sty == ACL_STYLE_SELF ) {
1049 bdn->a_self_level = level;
1053 Debug( LDAP_DEBUG_ANY,
1054 "%s: line %d: bad negative level \"%d\" "
1055 "in by DN clause\n",
1056 fname, lineno, level );
1058 } else if ( level == 1 ) {
1059 Debug( LDAP_DEBUG_ANY,
1060 "%s: line %d: \"onelevel\" should be used "
1061 "instead of \"level{1}\" in by DN clause\n",
1063 } else if ( level == 0 && sty == ACL_STYLE_LEVEL ) {
1064 Debug( LDAP_DEBUG_ANY,
1065 "%s: line %d: \"base\" should be used "
1066 "instead of \"level{0}\" in by DN clause\n",
1070 bdn->a_level = level;
1075 if ( strcasecmp( left, "dnattr" ) == 0 ) {
1076 if ( right == NULL || right[0] == '\0' ) {
1077 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1078 "missing \"=\" in (or value after) \"%s\" "
1080 fname, lineno, left );
1084 if( bdn->a_at != NULL ) {
1085 Debug( LDAP_DEBUG_ANY,
1086 "%s: line %d: dnattr already specified.\n",
1091 rc = slap_str2ad( right, &bdn->a_at, &text );
1093 if( rc != LDAP_SUCCESS ) {
1094 char buf[ SLAP_TEXT_BUFLEN ];
1096 snprintf( buf, sizeof( buf ),
1097 "dnattr \"%s\": %s",
1099 Debug( LDAP_DEBUG_ANY,
1100 "%s: line %d: %s\n",
1101 fname, lineno, buf );
1106 if( !is_at_syntax( bdn->a_at->ad_type,
1107 SLAPD_DN_SYNTAX ) &&
1108 !is_at_syntax( bdn->a_at->ad_type,
1109 SLAPD_NAMEUID_SYNTAX ))
1111 char buf[ SLAP_TEXT_BUFLEN ];
1113 snprintf( buf, sizeof( buf ),
1115 "inappropriate syntax: %s\n",
1117 bdn->a_at->ad_type->sat_syntax_oid );
1118 Debug( LDAP_DEBUG_ANY,
1119 "%s: line %d: %s\n",
1120 fname, lineno, buf );
1124 if( bdn->a_at->ad_type->sat_equality == NULL ) {
1125 Debug( LDAP_DEBUG_ANY,
1126 "%s: line %d: dnattr \"%s\": "
1127 "inappropriate matching (no EQUALITY)\n",
1128 fname, lineno, right );
1135 if ( strncasecmp( left, "group", STRLENOF( "group" ) ) == 0 ) {
1140 case ACL_STYLE_REGEX:
1141 /* legacy, tolerated */
1142 Debug( LDAP_DEBUG_CONFIG | LDAP_DEBUG_ACL,
1144 "deprecated group style \"regex\"; "
1145 "use \"expand\" instead.\n",
1147 sty = ACL_STYLE_EXPAND;
1150 case ACL_STYLE_BASE:
1151 /* legal, traditional */
1152 case ACL_STYLE_EXPAND:
1153 /* legal, substring expansion; supersedes regex */
1158 Debug( LDAP_DEBUG_ANY,
1160 "inappropriate style \"%s\" in by clause.\n",
1161 fname, lineno, style );
1165 if ( right == NULL || right[0] == '\0' ) {
1166 Debug( LDAP_DEBUG_ANY,
1168 "missing \"=\" in (or value after) \"%s\" "
1170 fname, lineno, left );
1174 if ( !BER_BVISEMPTY( &b->a_group_pat ) ) {
1175 Debug( LDAP_DEBUG_ANY,
1176 "%s: line %d: group pattern already specified.\n",
1181 /* format of string is
1182 "group/objectClassValue/groupAttrName" */
1183 if ( ( value = strchr(left, '/') ) != NULL ) {
1185 if ( *value && ( name = strchr( value, '/' ) ) != NULL ) {
1190 b->a_group_style = sty;
1191 if ( sty == ACL_STYLE_EXPAND ) {
1192 acl_regex_normalized_dn( right, &bv );
1193 if ( !ber_bvccmp( &bv, '*' ) ) {
1194 regtest( fname, lineno, bv.bv_val );
1196 b->a_group_pat = bv;
1199 ber_str2bv( right, 0, 0, &bv );
1200 rc = dnNormalize( 0, NULL, NULL, &bv,
1201 &b->a_group_pat, NULL );
1202 if ( rc != LDAP_SUCCESS ) {
1203 Debug( LDAP_DEBUG_ANY,
1204 "%s: line %d: bad DN \"%s\".\n",
1205 fname, lineno, right );
1210 if ( value && *value ) {
1211 b->a_group_oc = oc_find( value );
1214 if ( b->a_group_oc == NULL ) {
1215 Debug( LDAP_DEBUG_ANY,
1216 "%s: line %d: group objectclass "
1217 "\"%s\" unknown.\n",
1218 fname, lineno, value );
1223 b->a_group_oc = oc_find( SLAPD_GROUP_CLASS );
1225 if( b->a_group_oc == NULL ) {
1226 Debug( LDAP_DEBUG_ANY,
1227 "%s: line %d: group default objectclass "
1228 "\"%s\" unknown.\n",
1229 fname, lineno, SLAPD_GROUP_CLASS );
1234 if ( is_object_subclass( slap_schema.si_oc_referral,
1237 Debug( LDAP_DEBUG_ANY,
1238 "%s: line %d: group objectclass \"%s\" "
1239 "is subclass of referral.\n",
1240 fname, lineno, value );
1244 if ( is_object_subclass( slap_schema.si_oc_alias,
1247 Debug( LDAP_DEBUG_ANY,
1248 "%s: line %d: group objectclass \"%s\" "
1249 "is subclass of alias.\n",
1250 fname, lineno, value );
1254 if ( name && *name ) {
1255 rc = slap_str2ad( name, &b->a_group_at, &text );
1257 if( rc != LDAP_SUCCESS ) {
1258 char buf[ SLAP_TEXT_BUFLEN ];
1260 snprintf( buf, sizeof( buf ),
1261 "group \"%s\": %s.",
1263 Debug( LDAP_DEBUG_ANY,
1264 "%s: line %d: %s\n",
1265 fname, lineno, buf );
1271 rc = slap_str2ad( SLAPD_GROUP_ATTR, &b->a_group_at, &text );
1273 if ( rc != LDAP_SUCCESS ) {
1274 char buf[ SLAP_TEXT_BUFLEN ];
1276 snprintf( buf, sizeof( buf ),
1277 "group \"%s\": %s.",
1278 SLAPD_GROUP_ATTR, text );
1279 Debug( LDAP_DEBUG_ANY,
1280 "%s: line %d: %s\n",
1281 fname, lineno, buf );
1286 if ( !is_at_syntax( b->a_group_at->ad_type,
1287 SLAPD_DN_SYNTAX ) &&
1288 !is_at_syntax( b->a_group_at->ad_type,
1289 SLAPD_NAMEUID_SYNTAX ) &&
1290 !is_at_subtype( b->a_group_at->ad_type, slap_schema.si_ad_labeledURI->ad_type ) )
1292 char buf[ SLAP_TEXT_BUFLEN ];
1294 snprintf( buf, sizeof( buf ),
1295 "group \"%s\": inappropriate syntax: %s.",
1297 b->a_group_at->ad_type->sat_syntax_oid );
1298 Debug( LDAP_DEBUG_ANY,
1299 "%s: line %d: %s\n",
1300 fname, lineno, buf );
1307 struct berval vals[2];
1309 ber_str2bv( b->a_group_oc->soc_oid, 0, 0, &vals[0] );
1310 BER_BVZERO( &vals[1] );
1312 rc = oc_check_allowed( b->a_group_at->ad_type,
1316 char buf[ SLAP_TEXT_BUFLEN ];
1318 snprintf( buf, sizeof( buf ),
1319 "group: \"%s\" not allowed by \"%s\".",
1320 b->a_group_at->ad_cname.bv_val,
1321 b->a_group_oc->soc_oid );
1322 Debug( LDAP_DEBUG_ANY, "%s: line %d: %s\n",
1323 fname, lineno, buf );
1330 if ( strcasecmp( left, "peername" ) == 0 ) {
1332 case ACL_STYLE_REGEX:
1333 case ACL_STYLE_BASE:
1334 /* legal, traditional */
1335 case ACL_STYLE_EXPAND:
1336 /* cheap replacement to regex for simple expansion */
1338 case ACL_STYLE_PATH:
1339 /* legal, peername specific */
1343 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1344 "inappropriate style \"%s\" in by clause.\n",
1345 fname, lineno, style );
1349 if ( right == NULL || right[0] == '\0' ) {
1350 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1351 "missing \"=\" in (or value after) \"%s\" "
1353 fname, lineno, left );
1357 if ( !BER_BVISEMPTY( &b->a_peername_pat ) ) {
1358 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1359 "peername pattern already specified.\n",
1364 b->a_peername_style = sty;
1365 if ( sty == ACL_STYLE_REGEX ) {
1366 acl_regex_normalized_dn( right, &bv );
1367 if ( !ber_bvccmp( &bv, '*' ) ) {
1368 regtest( fname, lineno, bv.bv_val );
1370 b->a_peername_pat = bv;
1373 ber_str2bv( right, 0, 1, &b->a_peername_pat );
1375 if ( sty == ACL_STYLE_IP ) {
1380 split( right, '{', &addr, &port );
1381 split( addr, '%', &addr, &mask );
1383 b->a_peername_addr = inet_addr( addr );
1384 if ( b->a_peername_addr == (unsigned long)(-1) ) {
1385 /* illegal address */
1386 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1387 "illegal peername address \"%s\".\n",
1388 fname, lineno, addr );
1392 b->a_peername_mask = (unsigned long)(-1);
1393 if ( mask != NULL ) {
1394 b->a_peername_mask = inet_addr( mask );
1395 if ( b->a_peername_mask ==
1396 (unsigned long)(-1) )
1399 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1400 "illegal peername address mask "
1402 fname, lineno, mask );
1407 b->a_peername_port = -1;
1411 b->a_peername_port = strtol( port, &end, 10 );
1412 if ( end == port || end[0] != '}' ) {
1414 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1415 "illegal peername port specification "
1417 fname, lineno, port );
1426 if ( strcasecmp( left, "sockname" ) == 0 ) {
1428 case ACL_STYLE_REGEX:
1429 case ACL_STYLE_BASE:
1430 /* legal, traditional */
1431 case ACL_STYLE_EXPAND:
1432 /* cheap replacement to regex for simple expansion */
1437 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1438 "inappropriate style \"%s\" in by clause\n",
1439 fname, lineno, style );
1443 if ( right == NULL || right[0] == '\0' ) {
1444 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1445 "missing \"=\" in (or value after) \"%s\" "
1447 fname, lineno, left );
1451 if ( !BER_BVISNULL( &b->a_sockname_pat ) ) {
1452 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1453 "sockname pattern already specified.\n",
1458 b->a_sockname_style = sty;
1459 if ( sty == ACL_STYLE_REGEX ) {
1460 acl_regex_normalized_dn( right, &bv );
1461 if ( !ber_bvccmp( &bv, '*' ) ) {
1462 regtest( fname, lineno, bv.bv_val );
1464 b->a_sockname_pat = bv;
1467 ber_str2bv( right, 0, 1, &b->a_sockname_pat );
1472 if ( strcasecmp( left, "domain" ) == 0 ) {
1474 case ACL_STYLE_REGEX:
1475 case ACL_STYLE_BASE:
1476 case ACL_STYLE_SUBTREE:
1477 /* legal, traditional */
1480 case ACL_STYLE_EXPAND:
1481 /* tolerated: means exact,expand */
1483 Debug( LDAP_DEBUG_ANY,
1485 "\"expand\" modifier "
1486 "with \"expand\" style.\n",
1489 sty = ACL_STYLE_BASE;
1495 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1496 "inappropriate style \"%s\" in by clause.\n",
1497 fname, lineno, style );
1501 if ( right == NULL || right[0] == '\0' ) {
1502 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1503 "missing \"=\" in (or value after) \"%s\" "
1505 fname, lineno, left );
1509 if ( !BER_BVISEMPTY( &b->a_domain_pat ) ) {
1510 Debug( LDAP_DEBUG_ANY,
1511 "%s: line %d: domain pattern already specified.\n",
1516 b->a_domain_style = sty;
1517 b->a_domain_expand = expand;
1518 if ( sty == ACL_STYLE_REGEX ) {
1519 acl_regex_normalized_dn( right, &bv );
1520 if ( !ber_bvccmp( &bv, '*' ) ) {
1521 regtest( fname, lineno, bv.bv_val );
1523 b->a_domain_pat = bv;
1526 ber_str2bv( right, 0, 1, &b->a_domain_pat );
1531 if ( strcasecmp( left, "sockurl" ) == 0 ) {
1533 case ACL_STYLE_REGEX:
1534 case ACL_STYLE_BASE:
1535 /* legal, traditional */
1536 case ACL_STYLE_EXPAND:
1537 /* cheap replacement to regex for simple expansion */
1542 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1543 "inappropriate style \"%s\" in by clause.\n",
1544 fname, lineno, style );
1548 if ( right == NULL || right[0] == '\0' ) {
1549 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1550 "missing \"=\" in (or value after) \"%s\" "
1552 fname, lineno, left );
1556 if ( !BER_BVISEMPTY( &b->a_sockurl_pat ) ) {
1557 Debug( LDAP_DEBUG_ANY,
1558 "%s: line %d: sockurl pattern already specified.\n",
1563 b->a_sockurl_style = sty;
1564 if ( sty == ACL_STYLE_REGEX ) {
1565 acl_regex_normalized_dn( right, &bv );
1566 if ( !ber_bvccmp( &bv, '*' ) ) {
1567 regtest( fname, lineno, bv.bv_val );
1569 b->a_sockurl_pat = bv;
1572 ber_str2bv( right, 0, 1, &b->a_sockurl_pat );
1577 if ( strcasecmp( left, "set" ) == 0 ) {
1580 case ACL_STYLE_REGEX:
1581 Debug( LDAP_DEBUG_CONFIG | LDAP_DEBUG_ACL,
1583 "deprecated set style "
1584 "\"regex\" in <by> clause; "
1585 "use \"expand\" instead.\n",
1587 sty = ACL_STYLE_EXPAND;
1590 case ACL_STYLE_BASE:
1591 case ACL_STYLE_EXPAND:
1595 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1596 "inappropriate style \"%s\" in by clause.\n",
1597 fname, lineno, style );
1601 if ( !BER_BVISEMPTY( &b->a_set_pat ) ) {
1602 Debug( LDAP_DEBUG_ANY,
1603 "%s: line %d: set attribute already specified.\n",
1608 if ( right == NULL || *right == '\0' ) {
1609 Debug( LDAP_DEBUG_ANY,
1610 "%s: line %d: no set is defined.\n",
1615 b->a_set_style = sty;
1616 ber_str2bv( right, 0, 1, &b->a_set_pat );
1626 if ( strcasecmp( left, "aci" ) == 0 ) {
1629 } else if ( strncasecmp( left, "dynacl/", STRLENOF( "dynacl/" ) ) == 0 ) {
1630 name = &left[ STRLENOF( "dynacl/" ) ];
1631 opts = strchr( name, '/' );
1639 if ( slap_dynacl_config( fname, lineno, b, name, opts, sty, right ) ) {
1640 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1641 "unable to configure dynacl \"%s\".\n",
1642 fname, lineno, name );
1649 #else /* ! SLAP_DYNACL */
1651 #ifdef SLAPD_ACI_ENABLED
1652 if ( strcasecmp( left, "aci" ) == 0 ) {
1653 if (sty != ACL_STYLE_REGEX && sty != ACL_STYLE_BASE) {
1654 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1655 "inappropriate style \"%s\" in by clause.\n",
1656 fname, lineno, style );
1660 if( b->a_aci_at != NULL ) {
1661 Debug( LDAP_DEBUG_ANY,
1662 "%s: line %d: ACI attribute already specified.\n",
1667 if ( right != NULL && *right != '\0' ) {
1668 rc = slap_str2ad( right, &b->a_aci_at, &text );
1670 if( rc != LDAP_SUCCESS ) {
1671 char buf[ SLAP_TEXT_BUFLEN ];
1673 snprintf( buf, sizeof( buf ),
1676 Debug( LDAP_DEBUG_ANY,
1677 "%s: line %d: %s\n",
1678 fname, lineno, buf );
1683 b->a_aci_at = slap_ad_aci;
1686 if( !is_at_syntax( b->a_aci_at->ad_type,
1689 char buf[ SLAP_TEXT_BUFLEN ];
1691 snprintf( buf, sizeof( buf ),
1692 "ACI \"%s\": inappropriate syntax: %s.",
1694 b->a_aci_at->ad_type->sat_syntax_oid );
1695 Debug( LDAP_DEBUG_ANY, "%s: line %d: %s\n",
1696 fname, lineno, buf );
1702 #endif /* SLAPD_ACI_ENABLED */
1703 #endif /* ! SLAP_DYNACL */
1705 if ( strcasecmp( left, "ssf" ) == 0 ) {
1706 if ( sty != ACL_STYLE_REGEX && sty != ACL_STYLE_BASE ) {
1707 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1708 "inappropriate style \"%s\" in by clause.\n",
1709 fname, lineno, style );
1713 if ( b->a_authz.sai_ssf ) {
1714 Debug( LDAP_DEBUG_ANY,
1715 "%s: line %d: ssf attribute already specified.\n",
1720 if ( right == NULL || *right == '\0' ) {
1721 Debug( LDAP_DEBUG_ANY,
1722 "%s: line %d: no ssf is defined.\n",
1727 if ( lutil_atou( &b->a_authz.sai_ssf, right ) != 0 ) {
1728 Debug( LDAP_DEBUG_ANY,
1729 "%s: line %d: unable to parse ssf value (%s).\n",
1730 fname, lineno, right );
1734 if ( !b->a_authz.sai_ssf ) {
1735 Debug( LDAP_DEBUG_ANY,
1736 "%s: line %d: invalid ssf value (%s).\n",
1737 fname, lineno, right );
1743 if ( strcasecmp( left, "transport_ssf" ) == 0 ) {
1744 if ( sty != ACL_STYLE_REGEX && sty != ACL_STYLE_BASE ) {
1745 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1746 "inappropriate style \"%s\" in by clause.\n",
1747 fname, lineno, style );
1751 if ( b->a_authz.sai_transport_ssf ) {
1752 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1753 "transport_ssf attribute already specified.\n",
1758 if ( right == NULL || *right == '\0' ) {
1759 Debug( LDAP_DEBUG_ANY,
1760 "%s: line %d: no transport_ssf is defined.\n",
1765 if ( lutil_atou( &b->a_authz.sai_transport_ssf, right ) != 0 ) {
1766 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1767 "unable to parse transport_ssf value (%s).\n",
1768 fname, lineno, right );
1772 if ( !b->a_authz.sai_transport_ssf ) {
1773 Debug( LDAP_DEBUG_ANY,
1774 "%s: line %d: invalid transport_ssf value (%s).\n",
1775 fname, lineno, right );
1781 if ( strcasecmp( left, "tls_ssf" ) == 0 ) {
1782 if ( sty != ACL_STYLE_REGEX && sty != ACL_STYLE_BASE ) {
1783 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1784 "inappropriate style \"%s\" in by clause.\n",
1785 fname, lineno, style );
1789 if ( b->a_authz.sai_tls_ssf ) {
1790 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1791 "tls_ssf attribute already specified.\n",
1796 if ( right == NULL || *right == '\0' ) {
1797 Debug( LDAP_DEBUG_ANY,
1798 "%s: line %d: no tls_ssf is defined\n",
1803 if ( lutil_atou( &b->a_authz.sai_tls_ssf, right ) != 0 ) {
1804 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1805 "unable to parse tls_ssf value (%s).\n",
1806 fname, lineno, right );
1810 if ( !b->a_authz.sai_tls_ssf ) {
1811 Debug( LDAP_DEBUG_ANY,
1812 "%s: line %d: invalid tls_ssf value (%s).\n",
1813 fname, lineno, right );
1819 if ( strcasecmp( left, "sasl_ssf" ) == 0 ) {
1820 if ( sty != ACL_STYLE_REGEX && sty != ACL_STYLE_BASE ) {
1821 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1822 "inappropriate style \"%s\" in by clause.\n",
1823 fname, lineno, style );
1827 if ( b->a_authz.sai_sasl_ssf ) {
1828 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1829 "sasl_ssf attribute already specified.\n",
1834 if ( right == NULL || *right == '\0' ) {
1835 Debug( LDAP_DEBUG_ANY,
1836 "%s: line %d: no sasl_ssf is defined.\n",
1841 if ( lutil_atou( &b->a_authz.sai_sasl_ssf, right ) != 0 ) {
1842 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1843 "unable to parse sasl_ssf value (%s).\n",
1844 fname, lineno, right );
1848 if ( !b->a_authz.sai_sasl_ssf ) {
1849 Debug( LDAP_DEBUG_ANY,
1850 "%s: line %d: invalid sasl_ssf value (%s).\n",
1851 fname, lineno, right );
1857 if ( right != NULL ) {
1864 if ( i == argc || ( strcasecmp( left, "stop" ) == 0 ) ) {
1865 /* out of arguments or plain stop */
1867 ACL_PRIV_ASSIGN( b->a_access_mask, ACL_PRIV_ADDITIVE );
1868 b->a_type = ACL_STOP;
1870 access_append( &a->acl_access, b );
1874 if ( strcasecmp( left, "continue" ) == 0 ) {
1875 /* plain continue */
1877 ACL_PRIV_ASSIGN( b->a_access_mask, ACL_PRIV_ADDITIVE );
1878 b->a_type = ACL_CONTINUE;
1880 access_append( &a->acl_access, b );
1884 if ( strcasecmp( left, "break" ) == 0 ) {
1885 /* plain continue */
1887 ACL_PRIV_ASSIGN(b->a_access_mask, ACL_PRIV_ADDITIVE);
1888 b->a_type = ACL_BREAK;
1890 access_append( &a->acl_access, b );
1894 if ( strcasecmp( left, "by" ) == 0 ) {
1895 /* we've gone too far */
1897 ACL_PRIV_ASSIGN( b->a_access_mask, ACL_PRIV_ADDITIVE );
1898 b->a_type = ACL_STOP;
1900 access_append( &a->acl_access, b );
1905 if ( strncasecmp( left, "self", STRLENOF( "self" ) ) == 0 ) {
1907 ACL_PRIV_ASSIGN( b->a_access_mask, str2accessmask( &left[ STRLENOF( "self" ) ] ) );
1909 } else if ( strncasecmp( left, "realself", STRLENOF( "realself" ) ) == 0 ) {
1910 b->a_realdn_self = 1;
1911 ACL_PRIV_ASSIGN( b->a_access_mask, str2accessmask( &left[ STRLENOF( "realself" ) ] ) );
1914 ACL_PRIV_ASSIGN( b->a_access_mask, str2accessmask( left ) );
1917 if ( ACL_IS_INVALID( b->a_access_mask ) ) {
1918 Debug( LDAP_DEBUG_ANY,
1919 "%s: line %d: expecting <access> got \"%s\".\n",
1920 fname, lineno, left );
1924 b->a_type = ACL_STOP;
1926 if ( ++i == argc ) {
1927 /* out of arguments or plain stop */
1928 access_append( &a->acl_access, b );
1932 if ( strcasecmp( argv[i], "continue" ) == 0 ) {
1933 /* plain continue */
1934 b->a_type = ACL_CONTINUE;
1936 } else if ( strcasecmp( argv[i], "break" ) == 0 ) {
1937 /* plain continue */
1938 b->a_type = ACL_BREAK;
1940 } else if ( strcasecmp( argv[i], "stop" ) != 0 ) {
1945 access_append( &a->acl_access, b );
1948 Debug( LDAP_DEBUG_ANY,
1949 "%s: line %d: expecting \"to\" "
1950 "or \"by\" got \"%s\"\n",
1951 fname, lineno, argv[i] );
1956 /* if we have no real access clause, complain and do nothing */
1958 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1959 "warning: no access clause(s) "
1960 "specified in access line"
1961 SLAPD_CONF_UNKNOWN_IGNORED ".\n",
1963 #ifdef SLAPD_CONF_UNKNOWN_BAILOUT
1965 #endif /* SLAPD_CONF_UNKNOWN_BAILOUT */
1969 if ( slap_debug & LDAP_DEBUG_ACL ) {
1974 if ( a->acl_access == NULL ) {
1975 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1976 "warning: no by clause(s) "
1977 "specified in access line"
1978 SLAPD_CONF_UNKNOWN_IGNORED ".\n",
1980 #ifdef SLAPD_CONF_UNKNOWN_BAILOUT
1982 #endif /* SLAPD_CONF_UNKNOWN_BAILOUT */
1986 if ( be->be_nsuffix == NULL ) {
1987 Debug( LDAP_DEBUG_ACL, "%s: line %d: warning: "
1988 "scope checking needs suffix before ACLs.\n",
1990 /* go ahead, since checking is not authoritative */
1991 } else if ( !BER_BVISNULL( &be->be_nsuffix[ 1 ] ) ) {
1992 Debug( LDAP_DEBUG_ACL, "%s: line %d: warning: "
1993 "scope checking only applies to single-valued "
1994 "suffix databases\n",
1996 /* go ahead, since checking is not authoritative */
1998 switch ( check_scope( be, a ) ) {
1999 case ACL_SCOPE_UNKNOWN:
2000 Debug( LDAP_DEBUG_ACL, "%s: line %d: warning: "
2001 "cannot assess the validity of the ACL scope within "
2002 "backend naming context\n",
2006 case ACL_SCOPE_WARN:
2007 Debug( LDAP_DEBUG_ACL, "%s: line %d: warning: "
2008 "ACL could be out of scope within backend naming context\n",
2012 case ACL_SCOPE_PARTIAL:
2013 Debug( LDAP_DEBUG_ACL, "%s: line %d: warning: "
2014 "ACL appears to be partially out of scope within "
2015 "backend naming context\n",
2020 Debug( LDAP_DEBUG_ACL, "%s: line %d: warning: "
2021 "ACL appears to be out of scope within "
2022 "backend naming context\n",
2030 acl_append( &be->be_acl, a, pos );
2033 acl_append( &frontendDB->be_acl, a, pos );
2041 accessmask2str( slap_mask_t mask, char *buf, int debug )
2046 assert( buf != NULL );
2048 if ( ACL_IS_INVALID( mask ) ) {
2054 if ( ACL_IS_LEVEL( mask ) ) {
2055 if ( ACL_LVL_IS_NONE(mask) ) {
2056 ptr = lutil_strcopy( ptr, "none" );
2058 } else if ( ACL_LVL_IS_DISCLOSE(mask) ) {
2059 ptr = lutil_strcopy( ptr, "disclose" );
2061 } else if ( ACL_LVL_IS_AUTH(mask) ) {
2062 ptr = lutil_strcopy( ptr, "auth" );
2064 } else if ( ACL_LVL_IS_COMPARE(mask) ) {
2065 ptr = lutil_strcopy( ptr, "compare" );
2067 } else if ( ACL_LVL_IS_SEARCH(mask) ) {
2068 ptr = lutil_strcopy( ptr, "search" );
2070 } else if ( ACL_LVL_IS_READ(mask) ) {
2071 ptr = lutil_strcopy( ptr, "read" );
2073 } else if ( ACL_LVL_IS_WRITE(mask) ) {
2074 ptr = lutil_strcopy( ptr, "write" );
2076 } else if ( ACL_LVL_IS_WADD(mask) ) {
2077 ptr = lutil_strcopy( ptr, "add" );
2079 } else if ( ACL_LVL_IS_WDEL(mask) ) {
2080 ptr = lutil_strcopy( ptr, "delete" );
2082 } else if ( ACL_LVL_IS_MANAGE(mask) ) {
2083 ptr = lutil_strcopy( ptr, "manage" );
2086 ptr = lutil_strcopy( ptr, "unknown" );
2096 if( ACL_IS_ADDITIVE( mask ) ) {
2099 } else if( ACL_IS_SUBTRACTIVE( mask ) ) {
2106 if ( ACL_PRIV_ISSET(mask, ACL_PRIV_MANAGE) ) {
2111 if ( ACL_PRIV_ISSET(mask, ACL_PRIV_WRITE) ) {
2115 } else if ( ACL_PRIV_ISSET(mask, ACL_PRIV_WADD) ) {
2119 } else if ( ACL_PRIV_ISSET(mask, ACL_PRIV_WDEL) ) {
2124 if ( ACL_PRIV_ISSET(mask, ACL_PRIV_READ) ) {
2129 if ( ACL_PRIV_ISSET(mask, ACL_PRIV_SEARCH) ) {
2134 if ( ACL_PRIV_ISSET(mask, ACL_PRIV_COMPARE) ) {
2139 if ( ACL_PRIV_ISSET(mask, ACL_PRIV_AUTH) ) {
2144 if ( ACL_PRIV_ISSET(mask, ACL_PRIV_DISCLOSE) ) {
2149 if ( none && ACL_PRIV_ISSET(mask, ACL_PRIV_NONE) ) {
2158 if ( ACL_IS_LEVEL( mask ) ) {
2168 str2accessmask( const char *str )
2172 if( !ASCII_ALPHA(str[0]) ) {
2175 if ( str[0] == '=' ) {
2178 } else if( str[0] == '+' ) {
2179 ACL_PRIV_ASSIGN(mask, ACL_PRIV_ADDITIVE);
2181 } else if( str[0] == '-' ) {
2182 ACL_PRIV_ASSIGN(mask, ACL_PRIV_SUBSTRACTIVE);
2185 ACL_INVALIDATE(mask);
2189 for( i=1; str[i] != '\0'; i++ ) {
2190 if( TOLOWER((unsigned char) str[i]) == 'm' ) {
2191 ACL_PRIV_SET(mask, ACL_PRIV_MANAGE);
2193 } else if( TOLOWER((unsigned char) str[i]) == 'w' ) {
2194 ACL_PRIV_SET(mask, ACL_PRIV_WRITE);
2196 } else if( TOLOWER((unsigned char) str[i]) == 'a' ) {
2197 ACL_PRIV_SET(mask, ACL_PRIV_WADD);
2199 } else if( TOLOWER((unsigned char) str[i]) == 'z' ) {
2200 ACL_PRIV_SET(mask, ACL_PRIV_WDEL);
2202 } else if( TOLOWER((unsigned char) str[i]) == 'r' ) {
2203 ACL_PRIV_SET(mask, ACL_PRIV_READ);
2205 } else if( TOLOWER((unsigned char) str[i]) == 's' ) {
2206 ACL_PRIV_SET(mask, ACL_PRIV_SEARCH);
2208 } else if( TOLOWER((unsigned char) str[i]) == 'c' ) {
2209 ACL_PRIV_SET(mask, ACL_PRIV_COMPARE);
2211 } else if( TOLOWER((unsigned char) str[i]) == 'x' ) {
2212 ACL_PRIV_SET(mask, ACL_PRIV_AUTH);
2214 } else if( TOLOWER((unsigned char) str[i]) == 'd' ) {
2215 ACL_PRIV_SET(mask, ACL_PRIV_DISCLOSE);
2217 } else if( str[i] != '0' ) {
2218 ACL_INVALIDATE(mask);
2226 if ( strcasecmp( str, "none" ) == 0 ) {
2227 ACL_LVL_ASSIGN_NONE(mask);
2229 } else if ( strcasecmp( str, "disclose" ) == 0 ) {
2230 ACL_LVL_ASSIGN_DISCLOSE(mask);
2232 } else if ( strcasecmp( str, "auth" ) == 0 ) {
2233 ACL_LVL_ASSIGN_AUTH(mask);
2235 } else if ( strcasecmp( str, "compare" ) == 0 ) {
2236 ACL_LVL_ASSIGN_COMPARE(mask);
2238 } else if ( strcasecmp( str, "search" ) == 0 ) {
2239 ACL_LVL_ASSIGN_SEARCH(mask);
2241 } else if ( strcasecmp( str, "read" ) == 0 ) {
2242 ACL_LVL_ASSIGN_READ(mask);
2244 } else if ( strcasecmp( str, "add" ) == 0 ) {
2245 ACL_LVL_ASSIGN_WADD(mask);
2247 } else if ( strcasecmp( str, "delete" ) == 0 ) {
2248 ACL_LVL_ASSIGN_WDEL(mask);
2250 } else if ( strcasecmp( str, "write" ) == 0 ) {
2251 ACL_LVL_ASSIGN_WRITE(mask);
2253 } else if ( strcasecmp( str, "manage" ) == 0 ) {
2254 ACL_LVL_ASSIGN_MANAGE(mask);
2257 ACL_INVALIDATE( mask );
2267 "<access clause> ::= access to <what> "
2268 "[ by <who> <access> [ <control> ] ]+ \n";
2270 "<what> ::= * | [dn[.<dnstyle>]=<DN>] [filter=<filter>] [attrs=<attrspec>]\n"
2271 "<attrspec> ::= <attrname> [val[/<matchingRule>][.<attrstyle>]=<value>] | <attrlist>\n"
2272 "<attrlist> ::= <attr> [ , <attrlist> ]\n"
2273 "<attr> ::= <attrname> | @<objectClass> | !<objectClass> | entry | children\n";
2276 "<who> ::= [ * | anonymous | users | self | dn[.<dnstyle>]=<DN> ]\n"
2277 "\t[ realanonymous | realusers | realself | realdn[.<dnstyle>]=<DN> ]\n"
2278 "\t[dnattr=<attrname>]\n"
2279 "\t[realdnattr=<attrname>]\n"
2280 "\t[group[/<objectclass>[/<attrname>]][.<style>]=<group>]\n"
2281 "\t[peername[.<peernamestyle>]=<peer>] [sockname[.<style>]=<name>]\n"
2282 "\t[domain[.<domainstyle>]=<domain>] [sockurl[.<style>]=<url>]\n"
2284 "\t[dynacl/<name>[/<options>][.<dynstyle>][=<pattern>]]\n"
2285 #else /* ! SLAP_DYNACL */
2286 #ifdef SLAPD_ACI_ENABLED
2287 "\t[aci[=<attrname>]]\n"
2288 #endif /* SLAPD_ACI_ENABLED */
2289 #endif /* ! SLAP_DYNACL */
2290 "\t[ssf=<n>] [transport_ssf=<n>] [tls_ssf=<n>] [sasl_ssf=<n>]\n"
2291 "<style> ::= exact | regex | base(Object)\n"
2292 "<dnstyle> ::= base(Object) | one(level) | sub(tree) | children | "
2294 "<attrstyle> ::= exact | regex | base(Object) | one(level) | "
2295 "sub(tree) | children\n"
2296 "<peernamestyle> ::= exact | regex | ip | path\n"
2297 "<domainstyle> ::= exact | regex | base(Object) | sub(tree)\n"
2298 "<access> ::= [[real]self]{<level>|<priv>}\n"
2299 "<level> ::= none|disclose|auth|compare|search|read|{write|add|delete}|manage\n"
2300 "<priv> ::= {=|+|-}{0|d|x|c|s|r|{w|a|z}|m}+\n"
2301 "<control> ::= [ stop | continue | break ]\n"
2303 #ifdef SLAPD_ACI_ENABLED
2305 "\t<name>=ACI\t<pattern>=<attrname>\n"
2306 #endif /* SLAPD_ACI_ENABLED */
2307 #endif /* ! SLAP_DYNACL */
2310 Debug( LDAP_DEBUG_ANY, "%s%s%s\n", access, what, who );
2316 * Set pattern to a "normalized" DN from src.
2317 * At present it simply eats the (optional) space after
2318 * a RDN separator (,)
2319 * Eventually will evolve in a more complete normalization
2322 acl_regex_normalized_dn(
2324 struct berval *pattern )
2329 str = ch_strdup( src );
2330 len = strlen( src );
2332 for ( p = str; p && p[0]; p++ ) {
2334 if ( p[0] == '\\' && p[1] ) {
2336 * if escaping a hex pair we should
2337 * increment p twice; however, in that
2338 * case the second hex number does
2344 if ( p[0] == ',' && p[1] == ' ' ) {
2348 * too much space should be an error if we are pedantic
2350 for ( q = &p[2]; q[0] == ' '; q++ ) {
2353 AC_MEMCPY( p+1, q, len-(q-str)+1);
2356 pattern->bv_val = str;
2357 pattern->bv_len = p - str;
2370 if ( (*right = strchr( line, splitchar )) != NULL ) {
2371 *((*right)++) = '\0';
2376 access_append( Access **l, Access *a )
2378 for ( ; *l != NULL; l = &(*l)->a_next ) {
2386 acl_append( AccessControl **l, AccessControl *a, int pos )
2390 for (i=0 ; i != pos && *l != NULL; l = &(*l)->acl_next, i++ ) {
2399 access_free( Access *a )
2401 if ( !BER_BVISNULL( &a->a_dn_pat ) ) {
2402 free( a->a_dn_pat.bv_val );
2404 if ( !BER_BVISNULL( &a->a_realdn_pat ) ) {
2405 free( a->a_realdn_pat.bv_val );
2407 if ( !BER_BVISNULL( &a->a_peername_pat ) ) {
2408 free( a->a_peername_pat.bv_val );
2410 if ( !BER_BVISNULL( &a->a_sockname_pat ) ) {
2411 free( a->a_sockname_pat.bv_val );
2413 if ( !BER_BVISNULL( &a->a_domain_pat ) ) {
2414 free( a->a_domain_pat.bv_val );
2416 if ( !BER_BVISNULL( &a->a_sockurl_pat ) ) {
2417 free( a->a_sockurl_pat.bv_val );
2419 if ( !BER_BVISNULL( &a->a_set_pat ) ) {
2420 free( a->a_set_pat.bv_val );
2422 if ( !BER_BVISNULL( &a->a_group_pat ) ) {
2423 free( a->a_group_pat.bv_val );
2426 if ( a->a_dynacl != NULL ) {
2428 for ( da = a->a_dynacl; da; ) {
2429 slap_dynacl_t *tmp = da;
2433 if ( tmp->da_destroy ) {
2434 tmp->da_destroy( tmp->da_private );
2440 #endif /* SLAP_DYNACL */
2445 acl_free( AccessControl *a )
2450 if ( a->acl_filter ) {
2451 filter_free( a->acl_filter );
2453 if ( !BER_BVISNULL( &a->acl_dn_pat ) ) {
2454 if ( a->acl_dn_style == ACL_STYLE_REGEX ) {
2455 regfree( &a->acl_dn_re );
2457 free ( a->acl_dn_pat.bv_val );
2459 if ( a->acl_attrs ) {
2460 for ( an = a->acl_attrs; !BER_BVISNULL( &an->an_name ); an++ ) {
2461 free( an->an_name.bv_val );
2463 free( a->acl_attrs );
2465 for ( ; a->acl_access; a->acl_access = n ) {
2466 n = a->acl_access->a_next;
2467 access_free( a->acl_access );
2472 /* Because backend_startup uses acl_append to tack on the global_acl to
2473 * the end of each backend's acl, we cannot just take one argument and
2474 * merrily free our way to the end of the list. backend_destroy calls us
2475 * with the be_acl in arg1, and global_acl in arg2 to give us a stopping
2476 * point. config_destroy calls us with global_acl in arg1 and NULL in
2477 * arg2, so we then proceed to polish off the global_acl.
2480 acl_destroy( AccessControl *a, AccessControl *end )
2484 for ( ; a && a != end; a = n ) {
2491 access2str( slap_access_t access )
2493 if ( access == ACL_NONE ) {
2496 } else if ( access == ACL_DISCLOSE ) {
2499 } else if ( access == ACL_AUTH ) {
2502 } else if ( access == ACL_COMPARE ) {
2505 } else if ( access == ACL_SEARCH ) {
2508 } else if ( access == ACL_READ ) {
2511 } else if ( access == ACL_WRITE ) {
2514 } else if ( access == ACL_WADD ) {
2517 } else if ( access == ACL_WDEL ) {
2520 } else if ( access == ACL_MANAGE ) {
2529 str2access( const char *str )
2531 if ( strcasecmp( str, "none" ) == 0 ) {
2534 } else if ( strcasecmp( str, "disclose" ) == 0 ) {
2535 #ifndef SLAP_ACL_HONOR_DISCLOSE
2536 Debug( LDAP_DEBUG_ACL, "str2access: warning, "
2537 "\"disclose\" privilege disabled.\n",
2539 #endif /* SLAP_ACL_HONOR_DISCLOSE */
2540 return ACL_DISCLOSE;
2542 } else if ( strcasecmp( str, "auth" ) == 0 ) {
2545 } else if ( strcasecmp( str, "compare" ) == 0 ) {
2548 } else if ( strcasecmp( str, "search" ) == 0 ) {
2551 } else if ( strcasecmp( str, "read" ) == 0 ) {
2554 } else if ( strcasecmp( str, "write" ) == 0 ) {
2557 } else if ( strcasecmp( str, "add" ) == 0 ) {
2560 } else if ( strcasecmp( str, "delete" ) == 0 ) {
2563 } else if ( strcasecmp( str, "manage" ) == 0 ) {
2567 return( ACL_INVALID_ACCESS );
2570 #define ACLBUF_MAXLEN 8192
2572 static char aclbuf[ACLBUF_MAXLEN];
2575 dnaccess2text( slap_dn_access *bdn, char *ptr, int is_realdn )
2580 ptr = lutil_strcopy( ptr, "real" );
2583 if ( ber_bvccmp( &bdn->a_pat, '*' ) ||
2584 bdn->a_style == ACL_STYLE_ANONYMOUS ||
2585 bdn->a_style == ACL_STYLE_USERS ||
2586 bdn->a_style == ACL_STYLE_SELF )
2589 assert( ! ber_bvccmp( &bdn->a_pat, '*' ) );
2592 ptr = lutil_strcopy( ptr, bdn->a_pat.bv_val );
2593 if ( bdn->a_style == ACL_STYLE_SELF && bdn->a_self_level != 0 ) {
2594 int n = sprintf( ptr, ".level{%d}", bdn->a_self_level );
2601 ptr = lutil_strcopy( ptr, "dn." );
2602 if ( bdn->a_style == ACL_STYLE_BASE )
2603 ptr = lutil_strcopy( ptr, style_base );
2605 ptr = lutil_strcopy( ptr, style_strings[bdn->a_style] );
2606 if ( bdn->a_style == ACL_STYLE_LEVEL ) {
2607 int n = sprintf( ptr, "{%d}", bdn->a_level );
2612 if ( bdn->a_expand ) {
2613 ptr = lutil_strcopy( ptr, ",expand" );
2617 ptr = lutil_strcopy( ptr, bdn->a_pat.bv_val );
2624 access2text( Access *b, char *ptr )
2626 char maskbuf[ACCESSMASK_MAXLEN];
2628 ptr = lutil_strcopy( ptr, "\tby" );
2630 if ( !BER_BVISEMPTY( &b->a_dn_pat ) ) {
2631 ptr = dnaccess2text( &b->a_dn, ptr, 0 );
2634 ptr = lutil_strcopy( ptr, " dnattr=" );
2635 ptr = lutil_strcopy( ptr, b->a_dn_at->ad_cname.bv_val );
2638 if ( !BER_BVISEMPTY( &b->a_realdn_pat ) ) {
2639 ptr = dnaccess2text( &b->a_realdn, ptr, 1 );
2641 if ( b->a_realdn_at ) {
2642 ptr = lutil_strcopy( ptr, " realdnattr=" );
2643 ptr = lutil_strcopy( ptr, b->a_realdn_at->ad_cname.bv_val );
2646 if ( !BER_BVISEMPTY( &b->a_group_pat ) ) {
2647 ptr = lutil_strcopy( ptr, " group/" );
2648 ptr = lutil_strcopy( ptr, b->a_group_oc ?
2649 b->a_group_oc->soc_cname.bv_val : SLAPD_GROUP_CLASS );
2651 ptr = lutil_strcopy( ptr, b->a_group_at ?
2652 b->a_group_at->ad_cname.bv_val : SLAPD_GROUP_ATTR );
2654 ptr = lutil_strcopy( ptr, style_strings[b->a_group_style] );
2657 ptr = lutil_strcopy( ptr, b->a_group_pat.bv_val );
2661 if ( !BER_BVISEMPTY( &b->a_peername_pat ) ) {
2662 ptr = lutil_strcopy( ptr, " peername" );
2664 ptr = lutil_strcopy( ptr, style_strings[b->a_peername_style] );
2667 ptr = lutil_strcopy( ptr, b->a_peername_pat.bv_val );
2671 if ( !BER_BVISEMPTY( &b->a_sockname_pat ) ) {
2672 ptr = lutil_strcopy( ptr, " sockname" );
2674 ptr = lutil_strcopy( ptr, style_strings[b->a_sockname_style] );
2677 ptr = lutil_strcopy( ptr, b->a_sockname_pat.bv_val );
2681 if ( !BER_BVISEMPTY( &b->a_domain_pat ) ) {
2682 ptr = lutil_strcopy( ptr, " domain" );
2684 ptr = lutil_strcopy( ptr, style_strings[b->a_domain_style] );
2685 if ( b->a_domain_expand ) {
2686 ptr = lutil_strcopy( ptr, ",expand" );
2689 ptr = lutil_strcopy( ptr, b->a_domain_pat.bv_val );
2692 if ( !BER_BVISEMPTY( &b->a_sockurl_pat ) ) {
2693 ptr = lutil_strcopy( ptr, " sockurl" );
2695 ptr = lutil_strcopy( ptr, style_strings[b->a_sockurl_style] );
2698 ptr = lutil_strcopy( ptr, b->a_sockurl_pat.bv_val );
2702 if ( !BER_BVISEMPTY( &b->a_set_pat ) ) {
2703 ptr = lutil_strcopy( ptr, " set" );
2705 ptr = lutil_strcopy( ptr, style_strings[b->a_set_style] );
2708 ptr = lutil_strcopy( ptr, b->a_set_pat.bv_val );
2713 if ( b->a_dynacl ) {
2716 for ( da = b->a_dynacl; da; da = da->da_next ) {
2717 if ( da->da_unparse ) {
2718 struct berval bv = BER_BVNULL;
2719 (void)( *da->da_unparse )( da->da_private, &bv );
2720 assert( !BER_BVISNULL( &bv ) );
2721 ptr = lutil_strcopy( ptr, bv.bv_val );
2722 ch_free( bv.bv_val );
2726 #else /* ! SLAP_DYNACL */
2727 #ifdef SLAPD_ACI_ENABLED
2728 if ( b->a_aci_at != NULL ) {
2729 ptr = lutil_strcopy( ptr, " aci=" );
2730 ptr = lutil_strcopy( ptr, b->a_aci_at->ad_cname.bv_val );
2733 #endif /* SLAP_DYNACL */
2735 /* Security Strength Factors */
2736 if ( b->a_authz.sai_ssf ) {
2737 ptr += sprintf( ptr, " ssf=%u",
2738 b->a_authz.sai_ssf );
2740 if ( b->a_authz.sai_transport_ssf ) {
2741 ptr += sprintf( ptr, " transport_ssf=%u",
2742 b->a_authz.sai_transport_ssf );
2744 if ( b->a_authz.sai_tls_ssf ) {
2745 ptr += sprintf( ptr, " tls_ssf=%u",
2746 b->a_authz.sai_tls_ssf );
2748 if ( b->a_authz.sai_sasl_ssf ) {
2749 ptr += sprintf( ptr, " sasl_ssf=%u",
2750 b->a_authz.sai_sasl_ssf );
2754 if ( b->a_dn_self ) {
2755 ptr = lutil_strcopy( ptr, "self" );
2756 } else if ( b->a_realdn_self ) {
2757 ptr = lutil_strcopy( ptr, "realself" );
2759 ptr = lutil_strcopy( ptr, accessmask2str( b->a_access_mask, maskbuf, 0 ));
2760 if ( !maskbuf[0] ) ptr--;
2762 if( b->a_type == ACL_BREAK ) {
2763 ptr = lutil_strcopy( ptr, " break" );
2765 } else if( b->a_type == ACL_CONTINUE ) {
2766 ptr = lutil_strcopy( ptr, " continue" );
2768 } else if( b->a_type != ACL_STOP ) {
2769 ptr = lutil_strcopy( ptr, " unknown-control" );
2771 if ( !maskbuf[0] ) ptr = lutil_strcopy( ptr, " stop" );
2779 acl_unparse( AccessControl *a, struct berval *bv )
2785 bv->bv_val = aclbuf;
2790 ptr = lutil_strcopy( ptr, "to" );
2791 if ( !BER_BVISNULL( &a->acl_dn_pat ) ) {
2793 ptr = lutil_strcopy( ptr, " dn." );
2794 if ( a->acl_dn_style == ACL_STYLE_BASE )
2795 ptr = lutil_strcopy( ptr, style_base );
2797 ptr = lutil_strcopy( ptr, style_strings[a->acl_dn_style] );
2800 ptr = lutil_strcopy( ptr, a->acl_dn_pat.bv_val );
2801 ptr = lutil_strcopy( ptr, "\"\n" );
2804 if ( a->acl_filter != NULL ) {
2805 struct berval bv = BER_BVNULL;
2808 filter2bv( a->acl_filter, &bv );
2809 ptr = lutil_strcopy( ptr, " filter=\"" );
2810 ptr = lutil_strcopy( ptr, bv.bv_val );
2813 ch_free( bv.bv_val );
2816 if ( a->acl_attrs != NULL ) {
2821 ptr = lutil_strcopy( ptr, " attrs=" );
2822 for ( an = a->acl_attrs; an && !BER_BVISNULL( &an->an_name ); an++ ) {
2823 if ( ! first ) *ptr++ = ',';
2825 *ptr++ = an->an_oc_exclude ? '!' : '@';
2826 ptr = lutil_strcopy( ptr, an->an_oc->soc_cname.bv_val );
2829 ptr = lutil_strcopy( ptr, an->an_name.bv_val );
2836 if ( !BER_BVISEMPTY( &a->acl_attrval ) ) {
2838 ptr = lutil_strcopy( ptr, " val." );
2839 if ( a->acl_attrval_style == ACL_STYLE_BASE &&
2840 a->acl_attrs[0].an_desc->ad_type->sat_syntax ==
2841 slap_schema.si_syn_distinguishedName )
2842 ptr = lutil_strcopy( ptr, style_base );
2844 ptr = lutil_strcopy( ptr, style_strings[a->acl_attrval_style] );
2847 ptr = lutil_strcopy( ptr, a->acl_attrval.bv_val );
2853 ptr = lutil_strcopy( ptr, " *\n" );
2856 for ( b = a->acl_access; b != NULL; b = b->a_next ) {
2857 ptr = access2text( b, ptr );
2860 bv->bv_len = ptr - bv->bv_val;
2865 print_acl( Backend *be, AccessControl *a )
2869 acl_unparse( a, &bv );
2870 fprintf( stderr, "%s ACL: access %s\n",
2871 be == NULL ? "Global" : "Backend", bv.bv_val );
2873 #endif /* LDAP_DEBUG */