]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/aclparse.c
cleanup
[openldap] / servers / slapd / aclparse.c
index 93f173611be75045e6059ca4b4c8af610b26dfcc..61dda94b37ae62207041095f3b78e03cd26ec6a3 100644 (file)
@@ -40,6 +40,7 @@
 
 static char *style_strings[] = {
        "regex",
+       "expand",
        "base",
        "one",
        "subtree",
@@ -427,6 +428,9 @@ parse_acl(
                                } else if ( strcasecmp( style, "regex" ) == 0 ) {
                                        sty = ACL_STYLE_REGEX;
 
+                               } else if ( strcasecmp( style, "expand" ) == 0 ) {
+                                       sty = ACL_STYLE_EXPAND;
+
                                } else if ( strcasecmp( style, "ip" ) == 0 ) {
                                        sty = ACL_STYLE_IP;
 
@@ -448,9 +452,41 @@ parse_acl(
                                if ( style_modifier &&
                                        strcasecmp( style_modifier, "expand" ) == 0 )
                                {
-                                       expand = 1;
+                                       switch ( sty ) {
+                                       case ACL_STYLE_REGEX:
+                                               fprintf( stderr, "%s: line %d: "
+                                                       "\"regex\" style implies "
+                                                       "\"expand\" modifier (ignored)\n",
+                                                       fname, lineno );
+                                               break;
+
+                                       case ACL_STYLE_EXPAND:
+                                               fprintf( stderr, "%s: line %d: "
+                                                       "\"expand\" style used "
+                                                       "in conjunction with "
+                                                       "\"expand\" modifier (ignored)\n",
+                                                       fname, lineno );
+                                               break;
+
+                                       default:
+                                               /* we'll see later if it's pertinent */
+                                               expand = 1;
+                                               break;
+                                       }
                                }
 
+                               /* expand in <who> needs regex in <what> */
+                               if ( ( sty == ACL_STYLE_EXPAND || expand )
+                                               && a->acl_dn_style != ACL_STYLE_REGEX )
+                               {
+                                       fprintf( stderr, "%s: line %d: "
+                                               "\"expand\" style or modifier used "
+                                               "in conjunction with "
+                                               "a non-regex <what> clause\n",
+                                               fname, lineno );
+                               }
+
+
                                if ( strcasecmp( argv[i], "*" ) == 0 ) {
                                        bv.bv_val = ch_strdup( "*" );
                                        bv.bv_len = 1;
@@ -608,10 +644,27 @@ parse_acl(
                                        char *name = NULL;
                                        char *value = NULL;
 
-                                       if (sty != ACL_STYLE_REGEX && sty != ACL_STYLE_BASE) {
+                                       switch ( sty ) {
+                                       case ACL_STYLE_REGEX:
+                                               /* legacy, tolerated */
+                                               fprintf( stderr, "%s: line %d: "
+                                                       "deprecated group style \"regex\"; "
+                                                       "use \"expand\" instead\n",
+                                                       fname, lineno, style );
+                                               sty = ACL_STYLE_EXPAND;
+                                               break;
+
+                                       case ACL_STYLE_BASE:
+                                               /* legal, traditional */
+                                       case ACL_STYLE_EXPAND:
+                                               /* legal, substring expansion; supersedes regex */
+                                               break;
+
+                                       default:
+                                               /* unknown */
                                                fprintf( stderr, "%s: line %d: "
                                                        "inappropriate style \"%s\" in by clause\n",
-                                                   fname, lineno, style );
+                                                       fname, lineno, style );
                                                acl_usage();
                                        }
 
@@ -640,7 +693,7 @@ parse_acl(
                                        }
 
                                        b->a_group_style = sty;
-                                       if (sty == ACL_STYLE_REGEX) {
+                                       if (sty == ACL_STYLE_EXPAND) {
                                                acl_regex_normalized_dn( right, &bv );
                                                if ( !ber_bvccmp( &bv, '*' ) ) {
                                                        regtest(fname, lineno, bv.bv_val);
@@ -764,8 +817,12 @@ parse_acl(
                                        switch (sty) {
                                        case ACL_STYLE_REGEX:
                                        case ACL_STYLE_BASE:
+                                               /* legal, traditional */
+                                       case ACL_STYLE_EXPAND:
+                                               /* cheap replacement to regex for simple expansion */
                                        case ACL_STYLE_IP:
                                        case ACL_STYLE_PATH:
+                                               /* legal, peername specific */
                                                break;
 
                                        default:
@@ -849,7 +906,16 @@ parse_acl(
                                }
 
                                if ( strcasecmp( left, "sockname" ) == 0 ) {
-                                       if (sty != ACL_STYLE_REGEX && sty != ACL_STYLE_BASE) {
+                                       switch (sty) {
+                                       case ACL_STYLE_REGEX:
+                                       case ACL_STYLE_BASE:
+                                               /* legal, traditional */
+                                       case ACL_STYLE_EXPAND:
+                                               /* cheap replacement to regex for simple expansion */
+                                               break;
+
+                                       default:
+                                               /* unknown */
                                                fprintf( stderr, "%s: line %d: "
                                                        "inappropriate style \"%s\" in by clause\n",
                                                    fname, lineno, style );
@@ -889,9 +955,23 @@ parse_acl(
                                        case ACL_STYLE_REGEX:
                                        case ACL_STYLE_BASE:
                                        case ACL_STYLE_SUBTREE:
+                                               /* legal, traditional */
+                                               break;
+
+                                       case ACL_STYLE_EXPAND:
+                                               /* tolerated: means exact,expand */
+                                               if ( expand ) {
+                                                       fprintf( stderr,
+                                                               "%s: line %d: "
+                                                               "\"expand\" modifier with \"expand\" style\n",
+                                                               fname, lineno );
+                                               }
+                                               sty = ACL_STYLE_BASE;
+                                               expand = 1;
                                                break;
 
                                        default:
+                                               /* unknown */
                                                fprintf( stderr,
                                                        "%s: line %d: inappropriate style \"%s\" in by clause\n",
                                                    fname, lineno, style );
@@ -927,9 +1007,18 @@ parse_acl(
                                }
 
                                if ( strcasecmp( left, "sockurl" ) == 0 ) {
-                                       if (sty != ACL_STYLE_REGEX && sty != ACL_STYLE_BASE) {
-                                               fprintf( stderr,
-                                                       "%s: line %d: inappropriate style \"%s\" in by clause\n",
+                                       switch (sty) {
+                                       case ACL_STYLE_REGEX:
+                                       case ACL_STYLE_BASE:
+                                               /* legal, traditional */
+                                       case ACL_STYLE_EXPAND:
+                                               /* cheap replacement to regex for simple expansion */
+                                               break;
+
+                                       default:
+                                               /* unknown */
+                                               fprintf( stderr, "%s: line %d: "
+                                                       "inappropriate style \"%s\" in by clause\n",
                                                    fname, lineno, style );
                                                acl_usage();
                                        }