From: Kurt Zeilenga Date: Wed, 19 Dec 2001 22:41:00 +0000 (+0000) Subject: Patch slapadd(8) to provide a structuralObjectClass if missing X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~601 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=948925a68307c69157c1d6fa14575e032cba7afb;p=openldap Patch slapadd(8) to provide a structuralObjectClass if missing from input. This likely needs to be done by the frontend instead. Add structuralObjectClass to the root and subschema dses. --- diff --git a/servers/slapd/root_dse.c b/servers/slapd/root_dse.c index 61de132c3a..6ed03ab09f 100644 --- a/servers/slapd/root_dse.c +++ b/servers/slapd/root_dse.c @@ -39,14 +39,24 @@ root_dse_info( int i, j; char ** supportedSASLMechanisms; - AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass; - AttributeDescription *ad_namingContexts = slap_schema.si_ad_namingContexts; - AttributeDescription *ad_supportedControl = slap_schema.si_ad_supportedControl; - AttributeDescription *ad_supportedExtension = slap_schema.si_ad_supportedExtension; - AttributeDescription *ad_supportedLDAPVersion = slap_schema.si_ad_supportedLDAPVersion; - AttributeDescription *ad_supportedSASLMechanisms = slap_schema.si_ad_supportedSASLMechanisms; - AttributeDescription *ad_supportedFeatures = slap_schema.si_ad_supportedFeatures; - AttributeDescription *ad_ref = slap_schema.si_ad_ref; + AttributeDescription *ad_structuralObjectClass + = slap_schema.si_ad_structuralObjectClass; + AttributeDescription *ad_objectClass + = slap_schema.si_ad_objectClass; + AttributeDescription *ad_namingContexts + = slap_schema.si_ad_namingContexts; + AttributeDescription *ad_supportedControl + = slap_schema.si_ad_supportedControl; + AttributeDescription *ad_supportedExtension + = slap_schema.si_ad_supportedExtension; + AttributeDescription *ad_supportedLDAPVersion + = slap_schema.si_ad_supportedLDAPVersion; + AttributeDescription *ad_supportedSASLMechanisms + = slap_schema.si_ad_supportedSASLMechanisms; + AttributeDescription *ad_supportedFeatures + = slap_schema.si_ad_supportedFeatures; + AttributeDescription *ad_ref + = slap_schema.si_ad_ref; Attribute *a; @@ -61,6 +71,10 @@ root_dse_info( (void) dn_normalize( e->e_ndn ); e->e_private = NULL; + val.bv_val = "OpenLDAProotDSE"; + val.bv_len = sizeof("OpenLDAProotDSE")-1; + attr_merge( e, ad_structuralObjectClass, vals ); + val.bv_val = "top"; val.bv_len = sizeof("top")-1; attr_merge( e, ad_objectClass, vals ); diff --git a/servers/slapd/schema.c b/servers/slapd/schema.c index f56ca4deff..f28c99161e 100644 --- a/servers/slapd/schema.c +++ b/servers/slapd/schema.c @@ -22,7 +22,10 @@ int schema_info( Entry **entry, const char **text ) { - AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass; + AttributeDescription *ad_structuralObjectClass + = slap_schema.si_ad_structuralObjectClass; + AttributeDescription *ad_objectClass + = slap_schema.si_ad_objectClass; Entry *e; struct berval val; @@ -39,6 +42,10 @@ schema_info( Entry **entry, const char **text ) (void) dn_normalize( e->e_ndn ); e->e_private = NULL; + val.bv_val = "LDAPsubentry"; + val.bv_len = sizeof("LDAPsubentry")-1; + attr_merge( e, ad_structuralObjectClass, vals ); + val.bv_val = "top"; val.bv_len = sizeof("top")-1; attr_merge( e, ad_objectClass, vals ); diff --git a/servers/slapd/schema_check.c b/servers/slapd/schema_check.c index d8ae713294..2306eecfe6 100644 --- a/servers/slapd/schema_check.c +++ b/servers/slapd/schema_check.c @@ -24,7 +24,7 @@ static char * oc_check_required( /* * Determine the structural object class from a set of OIDs */ -static int structural_class( +int structural_class( struct berval **ocs, struct berval *scbv, const char **text ) @@ -157,7 +157,6 @@ entry_schema_check( if( !global_schemacheck ) return LDAP_SUCCESS; -#if 1 /* find the object class attribute - could error out here */ asc = attr_find( e->e_attrs, ad_structuralObjectClass ); if ( asc == NULL ) { @@ -215,7 +214,6 @@ entry_schema_check( return LDAP_OBJECT_CLASS_VIOLATION; } -#endif /* find the object class attribute */ aoc = attr_find( e->e_attrs, ad_objectClass ); diff --git a/servers/slapd/tools/slapadd.c b/servers/slapd/tools/slapadd.c index 65923fcae5..099033ac3b 100644 --- a/servers/slapd/tools/slapadd.c +++ b/servers/slapd/tools/slapadd.c @@ -81,8 +81,7 @@ main( int argc, char **argv ) } /* check backend */ - if( select_backend( e->e_ndn, is_entry_referral(e), nosubs ) != be ) - { + if( select_backend( e->e_ndn, is_entry_referral(e), nosubs ) != be ) { fprintf( stderr, "%s: database (%s) not configured to " "hold dn=\"%s\" (line=%d)\n", progname, @@ -94,6 +93,45 @@ main( int argc, char **argv ) break; } + { + Attribute *sc = attr_find( e->e_attrs, + slap_schema.si_ad_structuralObjectClass ); + Attribute *oc = attr_find( e->e_attrs, + slap_schema.si_ad_objectClass ); + + if( oc == NULL ) { + fprintf( stderr, "%s: dn=\"%s\" (line=%d): %s\n", + progname, e->e_dn, lineno, + "no objectClass attribute"); + rc = EXIT_FAILURE; + entry_free( e ); + if( continuemode ) continue; + break; + } + + if( sc == NULL ) { + struct berval *vals[2]; + struct berval scbv; + const char *text; + int ret = structural_class( + oc->a_vals, &scbv, &text ); + + if( scbv.bv_len == 0 ) { + fprintf( stderr, "%s: dn=\"%s\" (line=%d): %s\n", + progname, e->e_dn, lineno, text ); + rc = EXIT_FAILURE; + entry_free( e ); + if( continuemode ) continue; + break; + } + + vals[0] = &scbv; + vals[1] = NULL; + attr_merge( e, slap_schema.si_ad_structuralObjectClass, + vals ); + } + } + if( global_schemacheck ) { /* check schema */ const char *text;