]> git.sur5r.net Git - openldap/commitdiff
Sync with HEAD
authorKurt Zeilenga <kurt@openldap.org>
Thu, 10 Oct 2002 03:35:45 +0000 (03:35 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Thu, 10 Oct 2002 03:35:45 +0000 (03:35 +0000)
servers/slapd/acl.c
servers/slapd/at.c
servers/slapd/oc.c
servers/slapd/phonetic.c

index 3db4fd14e7a8ef160146691494275374ffdffc9e..281d96e66a588e538f91fa1b8dc81bcf5af149c0 100644 (file)
@@ -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 );
                }
        }
index 6542c81fa5368c426b2bbed68567fb5666341610..988cfb9f0c8e6f39014d752f661b39ce1eb42dcf 100644 (file)
@@ -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 );
        }
index 16a64ebf514af8e002b31686b97608263676b61f..ff6a81830344bcc302d320d8a37f87a2e846a67b 100644 (file)
@@ -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 );
index 959e06e1e332479aeae05f92dcd4d8c2ce8f4f13..80522af3e753bb15f9e538c6c6b70ed7286167ed 100644 (file)
@@ -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 <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
 #include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/ctype.h>
+#include <ac/string.h>
+#include <ac/socket.h>
+#include <ac/time.h>
+
 #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 */