]> git.sur5r.net Git - openldap/commitdiff
Much as we would like to, we have to live for the time being with
authorJulio Sánchez Fernández <jsanchez@openldap.org>
Wed, 22 Sep 1999 18:32:48 +0000 (18:32 +0000)
committerJulio Sánchez Fernández <jsanchez@openldap.org>
Wed, 22 Sep 1999 18:32:48 +0000 (18:32 +0000)
broken objectclass and attributetype definitions where the OID is
missing.  The implementation of OIDmacros was making this impossible.
This change tries to restore the old behaviour, while preserving the
new feature.  Note that part of the restored behaviour lets OIDs that
are not in the numericoid format get through.  We may lose this, but
then we need to fix some of the sample provided schemas, notably
pilot.schema.

servers/slapd/schemaparse.c

index 14fef80d1daefe081ed1b690c0ea45d13dbcf873..a0b7954a72af5f192bbbcdb1e99f3c96d7b12b00 100644 (file)
@@ -244,36 +244,29 @@ parse_oc(
        const char      *err;
        char            *oid = NULL;
 
-       /* Kludge for OIDmacros. If the numericOid field starts nonnumeric
-        * look for and expand a macro. The macro's place in the input line
-        * will be replaced with a field of '0's to keep ldap_str2objectclass
-        * happy. The actual oid will be swapped into place afterward.
-        */
-       if ( !isdigit( *argv[2] ))
-       {
-               oid = find_oidm(argv[2]);
-               if (!oid)
-               {
-                       fprintf(stderr, "%s: line %d: OID %s not recognized\n",
-                               fname, lineno, argv[2]);
-                       exit( EXIT_FAILURE );
-               }
-               if (oid != argv[2])
-                       memset(strstr(line, argv[2]), '0', strlen(argv[2]));
-               else
-                       oid = NULL;
-       }
        oc = ldap_str2objectclass(line,&code,&err);
        if ( !oc ) {
                fprintf( stderr, "%s: line %d: %s before %s\n",
                         fname, lineno, ldap_scherr2str(code), err );
                oc_usage();
        }
-       if (oid)
-       {
-               ldap_memfree(oc->oc_oid);
-               oc->oc_oid = oid;
+       if ( oc->oc_oid ) {
+               if ( !isdigit( oc->oc_oid[0] )) {
+                       /* Expand OID macros */
+                       oid = find_oidm( oc->oc_oid );
+                       if ( !oid ) {
+                               fprintf(stderr,
+                                       "%s: line %d: OID %s not recognized\n",
+                                       fname, lineno, oc->oc_oid);
+                               exit( EXIT_FAILURE );
+                       }
+                       if ( oid != oc->oc_oid ) {
+                               ldap_memfree( oc->oc_oid );
+                               oc->oc_oid = oid;
+                       }
+               }
        }
+       /* oc->oc_oid == NULL will be an error someday */
        code = oc_add(oc,&err);
        if ( code ) {
                fprintf( stderr, "%s: line %d: %s %s\n",
@@ -349,25 +342,12 @@ parse_at(
        char            *oid = NULL;
        char            *soid = NULL;
 
-       /* Kludge for OIDmacros. If the numericOid field starts nonnumeric
-        * look for and expand a macro. The macro's place in the input line
-        * will be replaced with a field of '0's to keep ldap_str2attr
-        * happy. The actual oid will be swapped into place afterward.
-        */
-       if ( !isdigit( *argv[2] ))
-       {
-               oid = find_oidm(argv[2]);
-               if (!oid)
-               {
-                       fprintf(stderr, "%s: line %d: OID %s not recognized\n",
-                               fname, lineno, argv[2]);
-                       exit( EXIT_FAILURE );
-               }
-               if (oid != argv[2])
-                       memset(strstr(line, argv[2]), '0', strlen(argv[2]));
-               else
-                       oid = NULL;
-       }
+       /* Kludge for OIDmacros for syntaxes. If the syntax field starts
+        * nonnumeric, look for and expand a macro. The macro's place in
+        * the input line will be replaced with a field of '0's to keep
+        * ldap_str2attributetype happy. The actual oid will be swapped
+        * into place afterwards.
+        */
        for (; argv[3]; argv++)
        {
                if (!strcasecmp(argv[3], "syntax") &&
@@ -393,11 +373,23 @@ parse_at(
                         fname, lineno, ldap_scherr2str(code), err );
                at_usage();
        }
-       if (oid)
-       {
-               ldap_memfree(at->at_oid);
-               at->at_oid = oid;
+       if ( at->at_oid ) {
+               if ( !isdigit( at->at_oid[0] )) {
+                       /* Expand OID macros */
+                       oid = find_oidm( at->at_oid );
+                       if ( !oid ) {
+                               fprintf(stderr,
+                                       "%s: line %d: OID %s not recognized\n",
+                                       fname, lineno, at->at_oid);
+                               exit( EXIT_FAILURE );
+                       }
+                       if ( oid != at->at_oid ) {
+                               ldap_memfree( at->at_oid );
+                               at->at_oid = oid;
+                       }
+               }
        }
+       /* at->at_oid == NULL will be an error someday */
        if (soid)
        {
                ldap_memfree(at->at_syntax_oid);