From: Howard Chu Date: Sat, 9 Apr 2005 16:13:04 +0000 (+0000) Subject: Preserve OID macros for display in back-config X-Git-Tag: OPENLDAP_AC_BP~942 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e2a3fc3af3bcf5623c46f091b233d937be7c0caf;p=openldap Preserve OID macros for display in back-config --- diff --git a/servers/slapd/at.c b/servers/slapd/at.c index e4030aec05..f5b27f6a39 100644 --- a/servers/slapd/at.c +++ b/servers/slapd/at.c @@ -323,6 +323,7 @@ at_add( int code; char *cname; char *oid; + char *oidm = NULL; if ( !OID_LEADCHAR( at->at_oid[0] )) { /* Expand OID macros */ @@ -332,7 +333,7 @@ at_add( return SLAP_SCHERR_OIDM; } if ( oid != at->at_oid ) { - ldap_memfree( at->at_oid ); + oidm = at->at_oid; at->at_oid = oid; } } @@ -394,6 +395,7 @@ at_add( sat->sat_cname.bv_val = cname; sat->sat_cname.bv_len = strlen( cname ); + sat->sat_oidmacro = oidm; ldap_pvt_thread_mutex_init(&sat->sat_ad_mutex); if ( at->at_sup_oid ) { @@ -650,12 +652,20 @@ at_unparse( BerVarray *res, AttributeType *start, AttributeType *end, int sys ) } i = 0; for ( at=start; at; at=LDAP_STAILQ_NEXT(at, sat_next)) { + LDAPAttributeType lat, *latp; if ( sys && !(at->sat_flags & SLAP_AT_HARDCODE)) continue; - if ( ldap_attributetype2bv( &at->sat_atype, &bv ) == NULL ) { + if ( at->sat_oidmacro ) { + lat = at->sat_atype; + lat.at_oid = at->sat_oidmacro; + latp = ⪫ + } else { + latp = &at->sat_atype; + } + if ( ldap_attributetype2bv( latp, &bv ) == NULL ) { ber_bvarray_free( bva ); } if ( !sys ) { - idx.bv_len = sprintf(idx.bv_val, "{%02d}", i); + idx.bv_len = sprintf(idx.bv_val, "{%d}", i); } bva[i].bv_len = idx.bv_len + bv.bv_len; bva[i].bv_val = ch_malloc( bva[i].bv_len + 1 ); diff --git a/servers/slapd/cr.c b/servers/slapd/cr.c index 948f4ec0cd..a1c6005e93 100644 --- a/servers/slapd/cr.c +++ b/servers/slapd/cr.c @@ -340,6 +340,7 @@ cr_add( ContentRule *scr; int code; int op = 0; + char *oidm = NULL; if ( cr->cr_names != NULL ) { int i; @@ -359,7 +360,7 @@ cr_add( return SLAP_SCHERR_OIDM; } if ( oid != cr->cr_oid ) { - ldap_memfree( cr->cr_oid ); + oidm = cr->cr_oid; cr->cr_oid = oid; } } @@ -367,6 +368,7 @@ cr_add( scr = (ContentRule *) ch_calloc( 1, sizeof(ContentRule) ); AC_MEMCPY( &scr->scr_crule, cr, sizeof(LDAPContentRule) ); + scr->scr_oidmacro = oidm; scr->scr_sclass = oc_find(cr->cr_oid); if ( !scr->scr_sclass ) { *err = cr->cr_oid; @@ -434,12 +436,20 @@ cr_unparse( BerVarray *res, ContentRule *start, ContentRule *end, int sys ) } i = 0; for ( cr=start; cr; cr=LDAP_STAILQ_NEXT(cr, scr_next)) { + LDAPContentRule lcr, *lcrp; if ( sys && !(cr->scr_flags & SLAP_CR_HARDCODE)) continue; - if ( ldap_contentrule2bv( &cr->scr_crule, &bv ) == NULL ) { + if ( cr->scr_oidmacro ) { + lcr = cr->scr_crule; + lcr.cr_oid = cr->scr_oidmacro; + lcrp = &lcr; + } else { + lcrp = &cr->scr_crule; + } + if ( ldap_contentrule2bv( lcrp, &bv ) == NULL ) { ber_bvarray_free( bva ); } if ( !sys ) { - idx.bv_len = sprintf(idx.bv_val, "{%02d}", i); + idx.bv_len = sprintf(idx.bv_val, "{%d}", i); } bva[i].bv_len = idx.bv_len + bv.bv_len; bva[i].bv_val = ch_malloc( bva[i].bv_len + 1 ); diff --git a/servers/slapd/oc.c b/servers/slapd/oc.c index 2b5b5f06f7..87f4728e08 100644 --- a/servers/slapd/oc.c +++ b/servers/slapd/oc.c @@ -467,6 +467,7 @@ oc_add( ObjectClass *soc; int code; int op = 0; + char *oidm = NULL; if ( oc->oc_names != NULL ) { int i; @@ -486,7 +487,7 @@ oc_add( return SLAP_SCHERR_OIDM; } if ( oid != oc->oc_oid ) { - ldap_memfree( oc->oc_oid ); + oidm = oc->oc_oid; oc->oc_oid = oid; } } @@ -494,6 +495,7 @@ oc_add( soc = (ObjectClass *) ch_calloc( 1, sizeof(ObjectClass) ); AC_MEMCPY( &soc->soc_oclass, oc, sizeof(LDAPObjectClass) ); + soc->soc_oidmacro = oidm; if( oc->oc_names != NULL ) { soc->soc_cname.bv_val = soc->soc_names[0]; } else { @@ -560,12 +562,20 @@ oc_unparse( BerVarray *res, ObjectClass *start, ObjectClass *end, int sys ) } i = 0; for ( oc=start; oc; oc=LDAP_STAILQ_NEXT(oc, soc_next)) { + LDAPObjectClass loc, *locp; if ( sys && !(oc->soc_flags & SLAP_OC_HARDCODE)) continue; - if ( ldap_objectclass2bv( &oc->soc_oclass, &bv ) == NULL ) { + if ( oc->soc_oidmacro ) { + loc = oc->soc_oclass; + loc.oc_oid = oc->soc_oidmacro; + locp = &loc; + } else { + locp = &oc->soc_oclass; + } + if ( ldap_objectclass2bv( locp, &bv ) == NULL ) { ber_bvarray_free( bva ); } if ( !sys ) { - idx.bv_len = sprintf(idx.bv_val, "{%02d}", i); + idx.bv_len = sprintf(idx.bv_val, "{%d}", i); } bva[i].bv_len = idx.bv_len + bv.bv_len; bva[i].bv_val = ch_malloc( bva[i].bv_len + 1 ); diff --git a/servers/slapd/oidm.c b/servers/slapd/oidm.c index 0e0f6210a3..25407644a4 100644 --- a/servers/slapd/oidm.c +++ b/servers/slapd/oidm.c @@ -184,7 +184,7 @@ void oidm_unparse( BerVarray *res, OidMacro *start, OidMacro *end, int sys ) if ( sys && !(om->som_flags & SLAP_OM_HARDCODE)) continue; for ( j=0; !BER_BVISNULL(&om->som_names[j]); i++,j++ ) { if ( !sys ) { - idx.bv_len = sprintf(idx.bv_val, "{%02d}", i ); + idx.bv_len = sprintf(idx.bv_val, "{%d}", i ); } bva[i].bv_len = idx.bv_len + om->som_names[j].bv_len + om->som_subs[j].bv_len + 1; diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index fc020433c2..bf9568880c 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -641,6 +641,7 @@ typedef struct slap_attribute_type { Syntax *sat_syntax; AttributeTypeSchemaCheckFN *sat_check; + char *sat_oidmacro; #define SLAP_AT_NONE 0x0000U #define SLAP_AT_ABSTRACT 0x0100U /* cannot be instantiated */ @@ -700,6 +701,7 @@ typedef struct slap_object_class { AttributeType **soc_required; AttributeType **soc_allowed; ObjectClassSchemaCheckFN *soc_check; + char *soc_oidmacro; slap_mask_t soc_flags; #define soc_oid soc_oclass.oc_oid #define soc_names soc_oclass.oc_names @@ -751,6 +753,7 @@ typedef struct slap_content_rule { #define scr_at_oids_may scr_crule.cr_at_oids_may #define scr_at_oids_not scr_crule.cr_at_oids_not + char *scr_oidmacro; #define SLAP_CR_HARDCODE 0x10000U int scr_flags;