From: Kurt Zeilenga Date: Thu, 17 May 2001 07:31:59 +0000 (+0000) Subject: Add support for obsolete attributes. X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1403 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0aef7722e635aebe3f1b6941b4f5411d86d29653;p=openldap Add support for obsolete attributes. We don't support collective attributes (yet). Remove exit() calls from scheme parsers. Need to do same for acl parser. --- diff --git a/servers/slapd/at.c b/servers/slapd/at.c index 5a618ae296..63eda95ad2 100644 --- a/servers/slapd/at.c +++ b/servers/slapd/at.c @@ -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 diff --git a/servers/slapd/config.c b/servers/slapd/config.c index a5b3aa63c8..9fa1039d7d 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -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, diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 979a97efe9..7a561dbcde 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -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, diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 883942cbd9..258f14158a 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -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 )); /* diff --git a/servers/slapd/schemaparse.c b/servers/slapd/schemaparse.c index 6b377f608d..5370bf644b 100644 --- a/servers/slapd/schemaparse.c +++ b/servers/slapd/schemaparse.c @@ -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 \n"); - exit( EXIT_FAILURE ); + return 1; } oid = find_oidm( argv[1] ); @@ -136,7 +137,7 @@ usage: fprintf( stderr, "\tObjectIdentifier \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 \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; } diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 84a8a9ca07..2be9bfc028 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -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 {