From 372a941334f6fc88d8ac1f14466ad710409512f0 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Mon, 28 Jun 2004 06:42:00 +0000 Subject: [PATCH] add baseObject as alias for base. cleanup --- servers/slapd/aclparse.c | 308 +++++++++++++++++++-------------------- 1 file changed, 154 insertions(+), 154 deletions(-) diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index 6a1a4f267b..694b77f500 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -122,7 +122,6 @@ regtest(const char *fname, int lineno, char *pat) { } #ifdef LDAP_DEVEL - /* * Experimental * @@ -141,22 +140,22 @@ check_scope( BackendDB *be, AccessControl *a ) int patlen; struct berval dn; - dn = be->be_nsuffix[ 0 ]; + dn = be->be_nsuffix[0]; if ( a->acl_dn_pat.bv_len || a->acl_dn_style != ACL_STYLE_REGEX ) { slap_style_t style = a->acl_dn_style; if ( style == ACL_STYLE_REGEX ) { - char dnbuf[ SLAP_LDAPDN_MAXLEN + 2 ]; - char rebuf[ SLAP_LDAPDN_MAXLEN + 1 ]; + char dnbuf[SLAP_LDAPDN_MAXLEN + 2]; + char rebuf[SLAP_LDAPDN_MAXLEN + 1]; regex_t re; int rc; /* add trailing '$' */ - AC_MEMCPY( dnbuf, be->be_nsuffix[ 0 ].bv_val, - be->be_nsuffix[ 0 ].bv_len ); - dnbuf[ be->be_nsuffix[ 0 ].bv_len ] = '$'; - dnbuf[ be->be_nsuffix[ 0 ].bv_len + 1 ] = '\0'; + AC_MEMCPY( dnbuf, be->be_nsuffix[0].bv_val, + be->be_nsuffix[0].bv_len ); + dnbuf[be->be_nsuffix[0].bv_len] = '$'; + dnbuf[be->be_nsuffix[0].bv_len + 1] = '\0'; if ( regcomp( &re, dnbuf, REG_EXTENDED|REG_ICASE ) ) { return ACL_SCOPE_WARN; @@ -164,9 +163,9 @@ check_scope( BackendDB *be, AccessControl *a ) /* remove trailing '$' */ AC_MEMCPY( rebuf, a->acl_dn_pat.bv_val, - a->acl_dn_pat.bv_len + 1 ); - if ( a->acl_dn_pat.bv_val[ a->acl_dn_pat.bv_len - 1 ] == '$' ) { - rebuf[ a->acl_dn_pat.bv_len - 1 ] = '\0'; + a->acl_dn_pat.bv_len + 1 ); + if ( a->acl_dn_pat.bv_val[a->acl_dn_pat.bv_len - 1] == '$' ) { + rebuf[a->acl_dn_pat.bv_len - 1] = '\0'; } /* not a clear indication of scoping error, though */ @@ -174,7 +173,6 @@ check_scope( BackendDB *be, AccessControl *a ) ? ACL_SCOPE_WARN : ACL_SCOPE_OK; regfree( &re ); - return rc; } @@ -185,9 +183,7 @@ check_scope( BackendDB *be, AccessControl *a ) * match */ if ( dn.bv_len > patlen ) { /* base is blatantly wrong */ - if ( style == ACL_STYLE_BASE ) { - return ACL_SCOPE_ERR; - } + if ( style == ACL_STYLE_BASE ) return ACL_SCOPE_ERR; /* one can be wrong if there is more * than one level between the suffix @@ -196,8 +192,9 @@ check_scope( BackendDB *be, AccessControl *a ) int rdnlen = -1, sep = 0; if ( patlen > 0 ) { - if ( !DN_SEPARATOR( dn.bv_val[ dn.bv_len - patlen - 1 ] ) ) + if ( !DN_SEPARATOR( dn.bv_val[dn.bv_len - patlen - 1] )) { return ACL_SCOPE_ERR; + } sep = 1; } @@ -208,7 +205,9 @@ check_scope( BackendDB *be, AccessControl *a ) /* if the trailing part doesn't match, * then it's an error */ - if ( strcmp( a->acl_dn_pat.bv_val, &dn.bv_val[ dn.bv_len - patlen ] ) != 0 ) { + if ( strcmp( a->acl_dn_pat.bv_val, + &dn.bv_val[dn.bv_len - patlen] ) != 0 ) + { return ACL_SCOPE_ERR; } @@ -227,11 +226,14 @@ check_scope( BackendDB *be, AccessControl *a ) break; } - if ( dn.bv_len < patlen && !DN_SEPARATOR( a->acl_dn_pat.bv_val[ patlen -dn.bv_len - 1 ] ) ) { + if ( dn.bv_len < patlen && + !DN_SEPARATOR( a->acl_dn_pat.bv_val[patlen -dn.bv_len - 1] )) { return ACL_SCOPE_ERR; } - if ( strcmp( &a->acl_dn_pat.bv_val[ patlen - dn.bv_len ], dn.bv_val ) != 0 ) { + if ( strcmp( &a->acl_dn_pat.bv_val[patlen - dn.bv_len], dn.bv_val ) + != 0 ) + { return ACL_SCOPE_ERR; } @@ -314,19 +316,21 @@ parse_acl( } if ( style == NULL || *style == '\0' || - ( strcasecmp( style, "base" ) == 0 ) || - ( strcasecmp( style, "exact" ) == 0 )) + strcasecmp( style, "baseObject" ) == 0 || + strcasecmp( style, "base" ) == 0 || + strcasecmp( style, "exact" ) == 0 ) { a->acl_dn_style = ACL_STYLE_BASE; ber_str2bv( right, 0, 1, &a->acl_dn_pat ); - } else if ( strcasecmp( style, "onelevel" ) == 0 - || strcasecmp( style, "one" ) == 0 ) { + } else if ( strcasecmp( style, "oneLevel" ) == 0 || + strcasecmp( style, "one" ) == 0 ) + { a->acl_dn_style = ACL_STYLE_ONE; ber_str2bv( right, 0, 1, &a->acl_dn_pat ); - } else if ( strcasecmp( style, "subtree" ) == 0 - || strcasecmp( style, "sub" ) == 0 ) + } else if ( strcasecmp( style, "subtree" ) == 0 || + strcasecmp( style, "sub" ) == 0 ) { if( *right == '\0' ) { a->acl_dn_pat.bv_val = ch_strdup( "*" ); @@ -420,24 +424,33 @@ parse_acl( } a->acl_attrval_style = ACL_STYLE_REGEX; } else { - /* FIXME: if the attribute has DN syntax, - * we might allow one, subtree and children styles as well */ + /* FIXME: if the attribute has DN syntax, we might + * allow one, subtree and children styles as well */ if ( !strcasecmp( style, "exact" ) ) { a->acl_attrval_style = ACL_STYLE_BASE; - } else if ( a->acl_attrs[0].an_desc->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName ) { - if ( !strcasecmp( style, "base" ) ) { + } else if ( a->acl_attrs[0].an_desc->ad_type-> + sat_syntax == slap_schema.si_syn_distinguishedName ) + { + if ( !strcasecmp( style, "baseObject" ) || + !strcasecmp( style, "base" ) ) + { a->acl_attrval_style = ACL_STYLE_BASE; - } else if ( !strcasecmp( style, "onelevel" ) || !strcasecmp( style, "one" ) ) { + } else if ( !strcasecmp( style, "onelevel" ) || + !strcasecmp( style, "one" ) ) + { a->acl_attrval_style = ACL_STYLE_ONE; - } else if ( !strcasecmp( style, "subtree" ) || !strcasecmp( style, "sub" ) ) { + } else if ( !strcasecmp( style, "subtree" ) || + !strcasecmp( style, "sub" ) ) + { a->acl_attrval_style = ACL_STYLE_SUBTREE; } else if ( !strcasecmp( style, "children" ) ) { a->acl_attrval_style = ACL_STYLE_CHILDREN; } else { fprintf( stderr, "%s: line %d: unknown val.