]> git.sur5r.net Git - openldap/commitdiff
Add support for obsolete attributes.
authorKurt Zeilenga <kurt@openldap.org>
Thu, 17 May 2001 07:31:59 +0000 (07:31 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Thu, 17 May 2001 07:31:59 +0000 (07:31 +0000)
We don't support collective attributes (yet).
Remove exit() calls from scheme parsers.  Need to do same for acl parser.

servers/slapd/at.c
servers/slapd/config.c
servers/slapd/modify.c
servers/slapd/proto-slap.h
servers/slapd/schemaparse.c
servers/slapd/slap.h

index 5a618ae2969db99d2441b2866ef52de92988353b..63eda95ad2137590f397e81e165f22cfc67106d7 100644 (file)
@@ -246,6 +246,11 @@ at_add(
                cname = "";
                return SLAP_SCHERR_ATTR_INCOMPLETE;
        }
+
+       if ( at->at_collective ) {
+               return SLAP_SCHERR_NOT_SUPPORTED;
+       }
+
        sat = (AttributeType *) ch_calloc( 1, sizeof(AttributeType) );
        AC_MEMCPY( &sat->sat_atype, at, sizeof(LDAPAttributeType));
 
@@ -323,7 +328,6 @@ at_add(
        }
 
        code = at_insert(sat,err);
-       return code;
 }
 
 #ifdef LDAP_DEBUG
index a5b3aa63c81c8177309106f0d62b52742cdabbb9..9fa1039d7db48dfdfd82c2253cc330edfbf8cc88 100644 (file)
@@ -1368,14 +1368,17 @@ read_config( const char *fname )
                         lutil_set_debug_level( cargv[1], level );
                /* specify an Object Identifier macro */
                } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
-                       parse_oidm( fname, lineno, cargc, cargv );
+                       rc = parse_oidm( fname, lineno, cargc, cargv );
+                       if( rc ) return rc;
 
                /* specify an objectclass */
                } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
                        if ( *cargv[1] == '(' ) {
                                char * p;
                                p = strchr(saveline,'(');
-                               parse_oc( fname, lineno, p, cargv );
+                               rc = parse_oc( fname, lineno, p, cargv );
+                               if( rc ) return rc;
+
                        } else {
 #ifdef NEW_LOGGING
                                LDAP_LOG(( "config", LDAP_LEVEL_INFO,
@@ -1396,7 +1399,9 @@ read_config( const char *fname )
                        if ( *cargv[1] == '(' ) {
                                char * p;
                                p = strchr(saveline,'(');
-                               parse_at( fname, lineno, p, cargv );
+                               rc = parse_at( fname, lineno, p, cargv );
+                               if( rc ) return rc;
+
                        } else {
 #ifdef NEW_LOGGING
                                LDAP_LOG(( "config", LDAP_LEVEL_INFO,
index 979a97efe9547b325af4f6e69cdf54fe6485552e..7a561dbcdeb27fc51cca0aa88e66179162313ca1 100644 (file)
@@ -414,6 +414,21 @@ int slap_modlist2mods(
                        return LDAP_CONSTRAINT_VIOLATION;
                }
 
+               if ( is_at_obsolete( ad->ad_type ) &&
+                       ( mod->sml_op == LDAP_MOD_ADD || ml->ml_bvalues != NULL ) )
+               {
+                       /*
+                        * attribute is obsolete,
+                        * only allow replace/delete with no values
+                        */
+                       slap_mods_free( mod );
+                       snprintf( textbuf, textlen,
+                               "%s: attribute is obsolete",
+                               ml->ml_type );
+                       *text = textbuf;
+                       return LDAP_CONSTRAINT_VIOLATION;
+               }
+
                /*
                 * check values
                 */
@@ -423,16 +438,6 @@ int slap_modlist2mods(
                                ad->ad_type->sat_syntax->ssyn_validate;
 
                        if( !validate ) {
-#ifdef NEW_LOGGING
-                               LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
-                                       "modlist2mods: %s: no validator for syntax %s\n",
-                                       ml->ml_type, ad->ad_type->sat_syntax->ssyn_oid ));
-#else
-                               Debug( LDAP_DEBUG_TRACE,
-                                       "modlist2mods: %s: no validator for syntax %s\n",
-                                       ml->ml_type, ad->ad_type->sat_syntax->ssyn_oid, 0 );
-#endif
-
                                slap_mods_free( mod );
                                *text = "no validator for syntax";
                                snprintf( textbuf, textlen,
index 883942cbd9052e108ffb6a4f04b4722e6550fa3a..258f14158ac995da7e9b40c6b2ce04be2a90b360 100644 (file)
@@ -685,12 +685,17 @@ LDAP_SLAPD_F (int) schema_prep LDAP_P((void));
  * schemaparse.c
  */
 
-LDAP_SLAPD_F (void) parse_oc_old LDAP_P(( Backend *be, const char *fname, int lineno, int argc, char **argv ));
-LDAP_SLAPD_F (void) parse_oc LDAP_P(( const char *fname, int lineno, char *line, char **argv ));
-LDAP_SLAPD_F (void) parse_at LDAP_P(( const char *fname, int lineno, char *line, char **argv ));
-LDAP_SLAPD_F (void) parse_oidm LDAP_P(( const char *fname, int lineno, int argc, char **argv ));
+LDAP_SLAPD_F (int) parse_oc_old LDAP_P((
+       Backend *be, const char *fname, int lineno, int argc, char **argv ));
+LDAP_SLAPD_F (int) parse_oc LDAP_P((
+       const char *fname, int lineno, char *line, char **argv ));
+LDAP_SLAPD_F (int) parse_at LDAP_P((
+       const char *fname, int lineno, char *line, char **argv ));
+LDAP_SLAPD_F (int) parse_oidm LDAP_P((
+       const char *fname, int lineno, int argc, char **argv ));
 LDAP_SLAPD_F (char *) scherr2str LDAP_P((int code)) LDAP_GCCATTR((const));
-LDAP_SLAPD_F (int) dscompare LDAP_P(( const char *s1, const char *s2del, char delim ));
+LDAP_SLAPD_F (int) dscompare LDAP_P(( const char *s1, const char *s2del,
+       char delim ));
 
 
 /*
index 6b377f608de21e34fa69c83e676c994119e948b2..5370bf644b1df094cc4f5c81946e10584d9f3629 100644 (file)
@@ -18,8 +18,8 @@
 
 int    global_schemacheck = 1; /* schemacheck on is default */
 
-static void            oc_usage(void)     LDAP_GCCATTR((noreturn));
-static void            at_usage(void)     LDAP_GCCATTR((noreturn));
+static void            oc_usage(void)
+static void            at_usage(void);
 
 static char *const err2text[] = {
        "Success",
@@ -36,7 +36,8 @@ static char *const err2text[] = {
        "SYNTAX or SUPerior required",
        "MatchingRule not found",
        "Syntax not found",
-       "Syntax required"
+       "Syntax required",
+       "Qualifier not supported"
 };
 
 char *
@@ -112,7 +113,7 @@ find_oidm(char *oid)
        return NULL;
 }
 
-void
+int
 parse_oidm(
     const char *fname,
     int                lineno,
@@ -127,7 +128,7 @@ parse_oidm(
                fprintf( stderr, "%s: line %d: too many arguments\n",
                        fname, lineno );
 usage: fprintf( stderr, "\tObjectIdentifier <name> <oid>\n");
-               exit( EXIT_FAILURE );
+               return 1;
        }
 
        oid = find_oidm( argv[1] );
@@ -136,7 +137,7 @@ usage:      fprintf( stderr, "\tObjectIdentifier <name> <oid>\n");
                        "%s: line %d: "
                        "ObjectIdentifier \"%s\" previously defined \"%s\"",
                        fname, lineno, argv[1], oid );
-               exit( EXIT_FAILURE );
+               return 1;
        }
 
        om = (OidMacro *) ch_malloc( sizeof(OidMacro) );
@@ -158,9 +159,11 @@ usage:     fprintf( stderr, "\tObjectIdentifier <name> <oid>\n");
        om->som_oid.bv_len = strlen( om->som_oid.bv_val );
        om->som_next = om_list;
        om_list = om;
+
+       return 0;
 }
 
-void
+int
 parse_oc(
     const char *fname,
     int                lineno,
@@ -178,7 +181,9 @@ parse_oc(
                fprintf( stderr, "%s: line %d: %s before %s\n",
                         fname, lineno, ldap_scherr2str(code), err );
                oc_usage();
+               return 1;
        }
+
        if ( oc->oc_oid ) {
                if ( !OID_LEADCHAR( oc->oc_oid[0] )) {
                        /* Expand OID macros */
@@ -187,7 +192,7 @@ parse_oc(
                                fprintf(stderr,
                                        "%s: line %d: OID %s not recognized\n",
                                        fname, lineno, oc->oc_oid);
-                               exit( EXIT_FAILURE );
+                               return 1;
                        }
                        if ( oid != oc->oc_oid ) {
                                ldap_memfree( oc->oc_oid );
@@ -195,14 +200,17 @@ parse_oc(
                        }
                }
        }
+
        /* oc->oc_oid == NULL will be an error someday */
        code = oc_add(oc,&err);
        if ( code ) {
                fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
                         fname, lineno, scherr2str(code), err);
-               exit( EXIT_FAILURE );
+               return 1;
        }
+
        ldap_memfree(oc);
+       return 0;
 }
 
 static void
@@ -220,7 +228,6 @@ oc_usage( void )
                "  [ \"MUST\" oids ]               ; AttributeTypes\n"
                "  [ \"MAY\" oids ]                ; AttributeTypes\n"
                "  whsp \")\"\n" );
-       exit( EXIT_FAILURE );
 }
 
 
@@ -248,10 +255,9 @@ at_usage( void )
                "                                   ; distributedOperation\n"
                "                                   ; dSAOperation\n"
                "  whsp \")\"\n");
-       exit( EXIT_FAILURE );
 }
 
-void
+int
 parse_at(
     const char *fname,
     int                lineno,
@@ -284,7 +290,7 @@ parse_at(
                        {
                            fprintf(stderr, "%s: line %d: OID %s not found\n",
                                fname, lineno, argv[4]);
-                           exit( EXIT_FAILURE );
+                               return 1;
                        }
                        memset(strstr(line, argv[4]), '0', slen);
                        soid = ch_strdup(syn->ssyn_syn.syn_oid );
@@ -296,6 +302,7 @@ parse_at(
                fprintf( stderr, "%s: line %d: %s before %s\n",
                         fname, lineno, ldap_scherr2str(code), err );
                at_usage();
+               return 1;
        }
        if ( at->at_oid ) {
                if ( !OID_LEADCHAR( at->at_oid[0] )) {
@@ -305,7 +312,7 @@ parse_at(
                                fprintf(stderr,
                                        "%s: line %d: OID %s not recognized\n",
                                        fname, lineno, at->at_oid);
-                               exit( EXIT_FAILURE );
+                               return 1;
                        }
                        if ( oid != at->at_oid ) {
                                ldap_memfree( at->at_oid );
@@ -322,7 +329,8 @@ parse_at(
        if ( code ) {
                fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
                         fname, lineno, scherr2str(code), err);
-               exit( EXIT_FAILURE );
+               return 1;
        }
        ldap_memfree(at);
+       return 0;
 }
index 84a8a9ca077ddaa33f68d73a27ba30b960ffba3a..2be9bfc0280dcce1f007274335b9ad37b6848870 100644 (file)
@@ -216,6 +216,7 @@ typedef struct slap_ssf_set {
 #define SLAP_SCHERR_MR_NOT_FOUND       12
 #define SLAP_SCHERR_SYN_NOT_FOUND      13
 #define SLAP_SCHERR_MR_INCOMPLETE      14
+#define SLAP_SCHERR_NOT_SUPPORTED      15
 
 typedef struct slap_oid_macro {
        struct berval som_oid;
@@ -382,6 +383,7 @@ typedef struct slap_attribute_type {
 #define is_at_operational(at)  ((at)->sat_usage)
 #define is_at_single_value(at) ((at)->sat_single_value)
 #define is_at_collective(at)   ((at)->sat_collective)
+#define is_at_obsolete(at)             ((at)->sat_obsolete)
 #define is_at_no_user_mod(at)  ((at)->sat_no_user_mod)
 
 typedef struct slap_object_class {