]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/aclparse.c
fix substring_comp_candidates logic if intersection of candidates
[openldap] / servers / slapd / aclparse.c
index 65d0450317980efcab82f4b89e44336de339b599..3c69482fce31c16db8b448f813eea942b9d04d2f 100644 (file)
@@ -194,6 +194,8 @@ parse_acl(
                        split( argv[i], '=', &left, &right );
                        if ( strcasecmp( argv[i], "*" ) == 0 ) {
                                b->a_dnpat = ch_strdup( ".*" );
+                       } else if ( strcasecmp( argv[i], "anonymous" ) == 0 ) {
+                               b->a_dnpat = ch_strdup( "anonymous" );
                        } else if ( strcasecmp( argv[i], "self" ) == 0 ) {
                                b->a_dnpat = ch_strdup( "self" );
                        } else if ( strcasecmp( left, "dn" ) == 0 ) {
@@ -202,39 +204,38 @@ parse_acl(
                        } else if ( strcasecmp( left, "dnattr" ) == 0 ) {
                                b->a_dnattr = ch_strdup( right );
 
-#ifdef SLAPD_ACLGROUPS
                        } else if ( strncasecmp( left, "group", sizeof("group")-1 ) == 0 ) {
-                                char *name = NULL;
-                                char *value = NULL;
-
-                                /* format of string is "group/objectClassValue/groupAttrName"
-                                 */
-                                if ((value = strchr(left, '/')) != NULL) {
-                                        *value++ = '\0';
-                                        if (value && *value && (name = strchr(value, '/')) != NULL) 
-                                            *name++ = '\0';
-                                }
+                               char *name = NULL;
+                               char *value = NULL;
+
+                               /* format of string is "group/objectClassValue/groupAttrName" */
+                               if ((value = strchr(left, '/')) != NULL) {
+                                       *value++ = '\0';
+                                       if (value && *value
+                                               && (name = strchr(value, '/')) != NULL)
+                                       {
+                                               *name++ = '\0';
+                                       }
+                               }
 
                                regtest(fname, lineno, right);
                                b->a_group = dn_upcase(ch_strdup( right ));
 
-                                if (value && *value) {
-                                        b->a_group_oc = ch_strdup(value);
-                                        *--value = '/';
-                                }
-                                else
-                                        b->a_group_oc = ch_strdup("groupOfNames");
-
-                                if (name && *name) {
-                                        b->a_group_at = ch_strdup(name);
-                                        *--name = '/';
-                                }
-                                else
-                                        b->a_group_at = ch_strdup("member");
+                               if (value && *value) {
+                                       b->a_group_oc = ch_strdup(value);
+                                       *--value = '/';
+                               } else {
+                                       b->a_group_oc = ch_strdup("groupOfNames");
 
+                                       if (name && *name) {
+                                               b->a_group_at = ch_strdup(name);
+                                               *--name = '/';
 
+                                       } else {
+                                               b->a_group_at = ch_strdup("member");
+                                       }
+                               }
 
-#endif /* SLAPD_ACLGROUPS */
                        } else if ( strcasecmp( left, "domain" ) == 0 ) {
                                char    *s;
                                regtest(fname, lineno, right);
@@ -263,7 +264,7 @@ parse_acl(
 
                        /* get <access> */
                        split( argv[i], '=', &left, &right );
-                       if ( ACL_IS_INVALID(ACL_SET(str2access( left ),b->a_access)) ) {
+                       if ( ACL_IS_INVALID(ACL_SET(b->a_access,str2access( left ))) ) {
                                fprintf( stderr,
                            "%s: line %d: expecting <access> got \"%s\"\n",
                                    fname, lineno, left );
@@ -319,10 +320,8 @@ access2str( int access )
 
        if ( ACL_IS_NONE(access) ) {
                strcat( buf, "none" );
-#ifdef SLAPD_ACLAUTH
        } else if ( ACL_IS_AUTH(access) ) {
                strcat( buf, "auth" );
-#endif
        } else if ( ACL_IS_COMPARE(access) ) {
                strcat( buf, "compare" );
        } else if ( ACL_IS_SEARCH(access) ) {
@@ -331,6 +330,7 @@ access2str( int access )
                strcat( buf, "read" );
        } else if ( ACL_IS_WRITE(access) ) {
                strcat( buf, "write" );
+
        } else {
                strcat( buf, "unknown" );
        }
@@ -352,10 +352,8 @@ str2access( char *str )
 
        if ( strcasecmp( str, "none" ) == 0 ) {
                ACL_SET_NONE(access);
-#ifdef SLAPD_ACLAUTH
        } else if ( strcasecmp( str, "auth" ) == 0 ) {
                ACL_SET_AUTH(access);
-#endif
        } else if ( strcasecmp( str, "compare" ) == 0 ) {
                ACL_SET_COMPARE(access);
        } else if ( strcasecmp( str, "search" ) == 0 ) {
@@ -379,16 +377,10 @@ acl_usage( void )
                "<what> ::= * | [dn=<regex>] [filter=<ldapfilter>] [attrs=<attrlist>]\n"
                "<attrlist> ::= <attr> | <attr> , <attrlist>\n"
                "<attr> ::= <attrname> | entry | children\n"
-               "<who> ::= * | self | dn=<regex> | addr=<regex>\n"
+               "<who> ::= * | anonymous | self | dn=<regex> | addr=<regex>\n"
                        "\t| domain=<regex> | dnattr=<dnattrname>\n"
-#ifdef SLAPD_ACLGROUPS
                        "\t| group[/<objectclass>[/<attrname>]]=<regex>\n"
-#endif
-#ifdef SLAPD_ACLAUTH
-               "<access> ::= [self]{none|auth|compare|search|read|write}\n"
-#else
                "<access> ::= [self]{none|auth|compare|search|read|write}\n"
-#endif
                );
        exit( 1 );
 }
@@ -433,23 +425,28 @@ print_access( struct access *b )
        fprintf( stderr, "\tby" );
 
        if ( b->a_dnpat != NULL ) {
-               fprintf( stderr, " dn=%s", b->a_dnpat );
+               if( strcmp(b->a_dnpat, "anonymous") == 0 ) {
+                       fprintf( stderr, " anonymous" );
+               } else if( strcmp(b->a_dnpat, "self") == 0 ) {
+                       fprintf( stderr, " self" );
+               } else {
+                       fprintf( stderr, " dn=%s", b->a_dnpat );
+               }
        } else if ( b->a_addrpat != NULL ) {
                fprintf( stderr, " addr=%s", b->a_addrpat );
        } else if ( b->a_domainpat != NULL ) {
                fprintf( stderr, " domain=%s", b->a_domainpat );
        } else if ( b->a_dnattr != NULL ) {
                fprintf( stderr, " dnattr=%s", b->a_dnattr );
-       }
-#ifdef SLAPD_ACLGROUPS
-        else if ( b->a_group != NULL ) {
-                fprintf( stderr, " group: %s", b->a_group );
-                if ( b->a_group_oc )
-                        fprintf( stderr, " objectClass: %s", b->a_group_oc );
-                if ( b->a_group_at )
-                        fprintf( stderr, " attributeType: %s", b->a_group_at );
-        }
-#endif
+       } else if ( b->a_group != NULL ) {
+               fprintf( stderr, " group: %s", b->a_group );
+               if ( b->a_group_oc ) {
+                       fprintf( stderr, " objectClass: %s", b->a_group_oc );
+                       if ( b->a_group_at ) {
+                               fprintf( stderr, " attributeType: %s", b->a_group_at );
+                       }
+               }
+    }
        fprintf( stderr, "\n" );
 }