From: Kurt Zeilenga Date: Sun, 2 Jul 2000 17:16:18 +0000 (+0000) Subject: Add experimental support for undefined attribute types. X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~2489 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b1172dc5ac5cd1c06cf333104537751b0c4a06df;p=openldap Add experimental support for undefined attribute types. --- diff --git a/servers/slapd/ad.c b/servers/slapd/ad.c index 96078b257d..701534a766 100644 --- a/servers/slapd/ad.c +++ b/servers/slapd/ad.c @@ -243,3 +243,54 @@ int ad_inlist( } +int slap_str2undef_ad( + const char *str, + AttributeDescription **ad, + const char **text ) +{ + struct berval bv; + bv.bv_val = (char *) str; + bv.bv_len = strlen( str ); + + return slap_bv2undef_ad( &bv, ad, text ); +} + +int slap_bv2undef_ad( + struct berval *bv, + AttributeDescription **ad, + const char **text ) +{ + AttributeDescription desc; + + assert( ad != NULL ); + assert( *ad == NULL ); /* temporary */ + + if( bv == NULL || bv->bv_len == 0 ) { + *text = "empty attribute description"; + return LDAP_UNDEFINED_TYPE; + } + + /* make sure description is IA5 */ + if( ad_keystring( bv ) ) { + *text = "attribute description contains inappropriate characters"; + return LDAP_UNDEFINED_TYPE; + } + + desc.ad_type = slap_schema.si_at_undefined; + desc.ad_flags = SLAP_DESC_NONE; + desc.ad_lang = NULL; + + desc.ad_cname = ber_bvdup( bv ); + + /* canoncial to upper case */ + ldap_pvt_str2upper( bv->bv_val ); + + if( *ad == NULL ) { + *ad = ch_malloc( sizeof( AttributeDescription ) ); + } + + **ad = desc; + + return LDAP_SUCCESS; +} + diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index 115daa3eea..c8817c87ef 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -115,11 +115,19 @@ str2entry( char *s ) if( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, - "<= str2entry NULL (str2ad=%s)\n", text, 0, 0 ); - entry_free( e ); - free( value.bv_val ); - free( type ); - return( NULL ); + "<= str2entry: str2ad(%s): %s\n", type, text, 0 ); + + rc = slap_str2undef_ad( type, &ad, &text ); + + if( rc != LDAP_SUCCESS ) { + Debug( LDAP_DEBUG_TRACE, + "<= str2entry: str2undef_ad(%s): %s\n", + type, text, 0 ); + entry_free( e ); + free( value.bv_val ); + free( type ); + return( NULL ); + } } rc = attr_merge( e, ad, vals ); diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index c6aa3dc7c5..27cf5cedff 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -41,6 +41,16 @@ LDAP_SLAPD_F (int) ad_inlist LDAP_P(( AttributeDescription *desc, char **attrs )); +LDAP_SLAPD_F (int) slap_str2undef_ad LDAP_P(( + const char *, + AttributeDescription **ad, + const char **text )); + +LDAP_SLAPD_F (int) slap_bv2undef_ad LDAP_P(( + struct berval *bv, + AttributeDescription **ad, + const char **text )); + /* * acl.c */ diff --git a/servers/slapd/schema_prep.c b/servers/slapd/schema_prep.c index 57df22771a..bb15ffba48 100644 --- a/servers/slapd/schema_prep.c +++ b/servers/slapd/schema_prep.c @@ -199,6 +199,17 @@ struct slap_schema_ad_map { { NULL, NULL, NULL, NULL, 0 } }; +static AttributeType slap_at_undefined = { + "UNDEFINED", /* cname */ + { "1.1.1", NULL, NULL, 1, NULL, + NULL, NULL, NULL, NULL, + 0, 0, 0, 1, 3 }, + NULL, /* sup */ + NULL, /* subtypes */ + NULL, NULL, NULL, NULL, /* matching rules */ + NULL, /* syntax (this may need to be defined) */ + NULL /* next */ +}; int schema_prep( void ) @@ -245,6 +256,8 @@ schema_prep( void ) } } + slap_schema.si_at_undefined = &slap_at_undefined; + ++schema_init_done; return LDAP_SUCCESS; } diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 4beb7a9c37..2445f5ff56 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -388,10 +388,10 @@ struct slap_internal_schema { ObjectClass *si_oc_subschema; ObjectClass *si_oc_rootdse; - /* objectClass attribute */ + /* objectClass attribute descriptions */ AttributeDescription *si_ad_objectClass; - /* operational attributes */ + /* operational attribute descriptions */ AttributeDescription *si_ad_structuralObjectClass; AttributeDescription *si_ad_creatorsName; AttributeDescription *si_ad_createTimestamp; @@ -399,14 +399,14 @@ struct slap_internal_schema { AttributeDescription *si_ad_modifyTimestamp; AttributeDescription *si_ad_subschemaSubentry; - /* root DSE attributes */ + /* root DSE attribute descriptions */ AttributeDescription *si_ad_namingContexts; AttributeDescription *si_ad_supportedControl; AttributeDescription *si_ad_supportedExtension; AttributeDescription *si_ad_supportedLDAPVersion; AttributeDescription *si_ad_supportedSASLMechanisms; - /* subschema subentry attributes */ + /* subschema subentry attribute descriptions */ AttributeDescription *si_ad_objectClasses; AttributeDescription *si_ad_attributeTypes; AttributeDescription *si_ad_ldapSyntaxes; @@ -424,12 +424,15 @@ struct slap_internal_schema { AttributeDescription *si_ad_aci; #endif - /* Other */ + /* Other attributes descriptions */ AttributeDescription *si_ad_userPassword; AttributeDescription *si_ad_authPassword; #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND AttributeDescription *si_ad_krbName; #endif + + /* Undefined Attribute Type */ + AttributeType *si_at_undefined; }; typedef struct slap_attr_assertion {