From dad2c8c770164f5409e7fcf1e34213e41302e96b Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Thu, 10 Oct 2002 03:35:45 +0000 Subject: [PATCH] Sync with HEAD --- servers/slapd/acl.c | 26 ++++++++++------- servers/slapd/at.c | 9 ++++-- servers/slapd/oc.c | 36 +++++------------------ servers/slapd/phonetic.c | 63 +++++++++++++++++++++------------------- 4 files changed, 63 insertions(+), 71 deletions(-) diff --git a/servers/slapd/acl.c b/servers/slapd/acl.c index 3db4fd14e7..281d96e66a 100644 --- a/servers/slapd/acl.c +++ b/servers/slapd/acl.c @@ -919,7 +919,6 @@ dn_match_cleanup:; } if ( b->a_group_pat.bv_len ) { - char buf[ACL_BUF_SIZE]; struct berval bv; struct berval ndn = { 0, NULL }; int rc; @@ -928,29 +927,33 @@ dn_match_cleanup:; continue; } - bv.bv_len = sizeof(buf) - 1; - bv.bv_val = buf; - /* b->a_group is an unexpanded entry name, expanded it should be an * entry with objectclass group* and we test to see if odn is one of * the values in the attribute group */ /* see if asker is listed in dnattr */ if ( b->a_group_style == ACL_STYLE_REGEX ) { - string_expand(&bv, &b->a_group_pat, e->e_ndn, matches); - if ( dnNormalize2(NULL, &bv, &ndn) != LDAP_SUCCESS ) { + char buf[ACL_BUF_SIZE]; + bv.bv_len = sizeof(buf) - 1; + bv.bv_val = buf; + + string_expand( &bv, &b->a_group_pat, e->e_ndn, matches ); + if ( dnNormalize2( NULL, &bv, &ndn ) != LDAP_SUCCESS ) { /* did not expand to a valid dn */ continue; } + bv = ndn; + } else { bv = b->a_group_pat; } - rc = backend_group(be, conn, op, e, &bv, &op->o_ndn, - b->a_group_oc, b->a_group_at); - if ( ndn.bv_val ) - free( ndn.bv_val ); + rc = backend_group( be, conn, op, e, &bv, &op->o_ndn, + b->a_group_oc, b->a_group_at ); + + if ( ndn.bv_val ) free( ndn.bv_val ); + if ( rc != 0 ) { continue; } @@ -1674,7 +1677,8 @@ aci_group_member ( bv.bv_val = (char *)&buf; string_expand(&bv, &subjdn, e->e_ndn, matches); if ( dnNormalize2(NULL, &bv, &ndn) == LDAP_SUCCESS ) { - rc = (backend_group(be, conn, op, e, &ndn, &op->o_ndn, grp_oc, grp_ad) == 0); + rc = (backend_group(be, conn, op, e, &ndn, &op->o_ndn, + grp_oc, grp_ad) == 0); free( ndn.bv_val ); } } diff --git a/servers/slapd/at.c b/servers/slapd/at.c index 6542c81fa5..988cfb9f0c 100644 --- a/servers/slapd/at.c +++ b/servers/slapd/at.c @@ -408,6 +408,11 @@ at_add( return SLAP_SCHERR_ATTR_BAD_USAGE; } + if ( supsat->sat_obsolete && !sat->sat_obsolete ) { + /* subtypes must be obsolete if super is */ + return SLAP_SCHERR_ATTR_BAD_SUP; + } + if ( sat->sat_flags & SLAP_AT_FINAL ) { /* cannot subtype a "final" attribute type */ return SLAP_SCHERR_ATTR_BAD_SUP; @@ -594,12 +599,12 @@ at_schema_info( Entry *e ) vals[1].bv_val = NULL; for ( at = attr_list; at; at = at->sat_next ) { + if( at->sat_flags & SLAP_AT_HIDE ) continue; + if ( ldap_attributetype2bv( &at->sat_atype, vals ) == NULL ) { return -1; } - if( at->sat_flags & SLAP_AT_HIDE ) continue; - attr_merge( e, ad_attributeTypes, vals ); ldap_memfree( vals[0].bv_val ); } diff --git a/servers/slapd/oc.c b/servers/slapd/oc.c index 16a64ebf51..ff6a818303 100644 --- a/servers/slapd/oc.c +++ b/servers/slapd/oc.c @@ -286,7 +286,12 @@ oc_add_sups( && soc1->soc_kind != LDAP_SCHEMA_ABSTRACT ) { *err = *sups1; - return SLAP_SCHERR_CLASS_BAD_USAGE; + return SLAP_SCHERR_CLASS_BAD_SUP; + } + + if( soc1->soc_obsolete && !soc->soc_obsolete ) { + *err = *sups1; + return SLAP_SCHERR_CLASS_BAD_SUP; } if( soc->soc_flags & SLAP_OC_OPERATIONAL ) (*op)++; @@ -465,31 +470,6 @@ oc_add( return code; } -#ifdef LDAP_DEBUG -static void -oc_print( ObjectClass *oc ) -{ - int i; - const char *mid; - - printf( "objectclass %s\n", ldap_objectclass2name( &oc->soc_oclass ) ); - if ( oc->soc_required != NULL ) { - mid = "\trequires "; - for ( i = 0; oc->soc_required[i] != NULL; i++, mid = "," ) - printf( "%s%s", mid, - ldap_attributetype2name( &oc->soc_required[i]->sat_atype ) ); - printf( "\n" ); - } - if ( oc->soc_allowed != NULL ) { - mid = "\tallows "; - for ( i = 0; oc->soc_allowed[i] != NULL; i++, mid = "," ) - printf( "%s%s", mid, - ldap_attributetype2name( &oc->soc_allowed[i]->sat_atype ) ); - printf( "\n" ); - } -} -#endif - int oc_schema_info( Entry *e ) { @@ -501,12 +481,12 @@ oc_schema_info( Entry *e ) vals[1].bv_val = NULL; for ( oc = oc_list; oc; oc = oc->soc_next ) { + if( oc->soc_flags & SLAP_OC_HIDE ) continue; + if ( ldap_objectclass2bv( &oc->soc_oclass, vals ) == NULL ) { return -1; } - if( oc->soc_flags & SLAP_OC_HIDE ) continue; - #if 0 Debug( LDAP_DEBUG_TRACE, "Merging oc [%ld] %s\n", (long) vals[0].bv_len, vals[0].bv_val, 0 ); diff --git a/servers/slapd/phonetic.c b/servers/slapd/phonetic.c index 959e06e1e3..80522af3e7 100644 --- a/servers/slapd/phonetic.c +++ b/servers/slapd/phonetic.c @@ -1,23 +1,30 @@ /* phonetic.c - routines to do phonetic matching */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ -#include -#include -#include -#include -#include -#include #include "portable.h" + +#include + +#include +#include +#include +#include + #include "slap.h" -#if !defined(METAPHONE) && !defined(SOUNDEX) -#define METAPHONE +#if !defined(SLAPD_METAPHONE) && !defined(SLAPD_PHONETIC) +#define SLAPD_METAPHONE #endif #define iswordbreak(x) (!isascii(x) || isspace((unsigned char) (x)) || \ ispunct((unsigned char) (x)) || \ - isdigit((unsigned char) (x)) || x == '\0') + isdigit((unsigned char) (x)) || (x) == '\0') -char * +static char * first_word( char *s ) { if ( s == NULL ) { @@ -35,7 +42,7 @@ first_word( char *s ) return( s ); } -char * +static char * next_word( char *s ) { if ( s == NULL ) { @@ -57,7 +64,7 @@ next_word( char *s ) return( s ); } -char * +static char * word_dup( char *w ) { char *s, *ret; @@ -67,7 +74,7 @@ word_dup( char *w ) ; /* NULL */ save = *s; *s = '\0'; - ret = strdup( w ); + ret = ch_strdup( w ); *s = save; return( ret ); @@ -77,7 +84,7 @@ word_dup( char *w ) #define MAXPHONEMELEN 4 #endif -#if defined(SOUNDEX) +#if defined(SLAPD_PHONETIC) /* lifted from isode-8.0 */ char * @@ -85,8 +92,7 @@ phonetic( char *s ) { char code, adjacent, ch; char *p; - char **c; - int i, cmax; + int i; char phoneme[MAXPHONEMELEN + 1]; p = s; @@ -95,11 +101,11 @@ phonetic( char *s ) } adjacent = '0'; - phoneme[0] = TOUPPER(*p); + phoneme[0] = TOUPPER((unsigned char)*p); phoneme[1] = '\0'; for ( i = 0; i < 99 && (! iswordbreak(*p)); p++ ) { - ch = TOUPPER (*p); + ch = TOUPPER ((unsigned char)*p); code = '0'; @@ -152,11 +158,10 @@ phonetic( char *s ) if ( i > 0 ) phoneme[i] = '\0'; - return( strdup( phoneme ) ); + return( ch_strdup( phoneme ) ); } -#else -#if defined(METAPHONE) +#elif defined(SLAPD_METAPHONE) /* * Metaphone copied from C Gazette, June/July 1991, pp 56-57, @@ -166,7 +171,7 @@ phonetic( char *s ) */ /* Character coding array */ -static char vsvfn[26] = { +static const char vsvfn[26] = { 1, 16, 4, 16, 9, 2, 4, 16, 9, 2, 0, 2, 2, /* A B C D E F G H I J K L M */ 2, 1, 4, 0, 2, 4, 4, 1, 0, 0, 0, 8, 0}; @@ -183,9 +188,8 @@ char * phonetic( char *Word ) { char *n, *n_start, *n_end; /* pointers to string */ - char *metaph, *metaph_end; /* pointers to metaph */ + char *metaph_end; /* pointers to metaph */ char ntrans[40]; /* word with uppercase letters */ - char newm[8];/* new metaph for comparison */ int KSflag; /* state flag for X -> KS */ char buf[MAXPHONEMELEN + 2]; char *Metaph; @@ -197,13 +201,13 @@ phonetic( char *Word ) for (n = ntrans + 4, n_end = ntrans + 35; !iswordbreak( *Word ) && n < n_end; Word++) { - if (isalpha(*Word)) - *n++ = TOUPPER(*Word); + if (isalpha((unsigned char)*Word)) + *n++ = TOUPPER((unsigned char)*Word); } Metaph = buf; *Metaph = '\0'; if (n == ntrans + 4) { - return( strdup( buf ) ); /* Return if null */ + return( ch_strdup( buf ) ); /* Return if null */ } n_end = n; /* Set n_end to end of string */ @@ -424,8 +428,7 @@ phonetic( char *Word ) } *Metaph = 0; /* Null terminate */ - return( strdup( buf ) ); + return( ch_strdup( buf ) ); } -#endif /* metaphone */ -#endif /* soundex */ +#endif /* SLAPD_METAPHONE */ -- 2.39.5