/* schema_init.c - init builtin schema */
/* $OpenLDAP$ */
/*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
struct berval *in )
{
int rc;
- struct berval *dn;
+ struct berval dn;
if( in->bv_len == 0 ) return LDAP_SUCCESS;
- dn = ber_bvdup( in );
- if( !dn ) return LDAP_OTHER;
+ ber_dupbv( &dn, in );
+ if( !dn.bv_val ) return LDAP_OTHER;
- if( dn->bv_val[dn->bv_len-1] == 'B'
- && dn->bv_val[dn->bv_len-2] == '\'' )
+ if( dn.bv_val[dn.bv_len-1] == 'B'
+ && dn.bv_val[dn.bv_len-2] == '\'' )
{
/* assume presence of optional UID */
ber_len_t i;
- for(i=dn->bv_len-3; i>1; i--) {
- if( dn->bv_val[i] != '0' && dn->bv_val[i] != '1' ) {
+ for(i=dn.bv_len-3; i>1; i--) {
+ if( dn.bv_val[i] != '0' && dn.bv_val[i] != '1' ) {
break;
}
}
- if( dn->bv_val[i] != '\'' ||
- dn->bv_val[i-1] != '#' ) {
- ber_bvfree( dn );
+ if( dn.bv_val[i] != '\'' ||
+ dn.bv_val[i-1] != '#' ) {
+ ber_memfree( dn.bv_val );
return LDAP_INVALID_SYNTAX;
}
/* trim the UID to allow use of dnValidate */
- dn->bv_val[i-1] = '\0';
- dn->bv_len = i-1;
+ dn.bv_val[i-1] = '\0';
+ dn.bv_len = i-1;
}
- rc = dnValidate( NULL, dn );
+ rc = dnValidate( NULL, &dn );
- ber_bvfree( dn );
+ ber_memfree( &dn );
return rc;
}
if( uidlen ) {
struct berval b2;
b2.bv_val = ch_malloc(dnlen + uidlen + 1);
- SAFEMEMCPY( b2.bv_val, normalized->bv_val, dnlen );
+ AC_MEMCPY( b2.bv_val, normalized->bv_val, dnlen );
/* restore the separator */
*uid = '#';
/* shift the UID */
- SAFEMEMCPY( normalized->bv_val+dnlen, uid, uidlen );
+ AC_MEMCPY( normalized->bv_val+dnlen, uid, uidlen );
b2.bv_len = dnlen + uidlen;
normalized->bv_val[dnlen+uidlen] = '\0';
free(normalized->bv_val);
static SubstringsAssertion *
UTF8SubstringsassertionNormalize(
SubstringsAssertion *sa,
- char casefold )
+ unsigned casefold )
{
SubstringsAssertion *nsa;
int i;
while( *++q & 0x80 ) {
/* empty */
}
- p = memmove(p, q, strlen(q) + 1);
+ p = AC_MEMCPY(p, q, strlen(q) + 1);
} else {
p++;
}
size_t avlen;
/* Yes, this is necessary */
- nval = UTF8normalize( value, UTF8_NOCASEFOLD );
+ nval = UTF8normalize( value, LDAP_UTF8_NOCASEFOLD );
if( nval == NULL ) {
*matchp = 1;
return LDAP_SUCCESS;
/* Yes, this is necessary */
assertv = UTF8normalize( ((struct berval *)assertedValue),
- UTF8_NOCASEFOLD );
+ LDAP_UTF8_NOCASEFOLD );
if( assertv == NULL ) {
ch_free( nval );
*matchp = 1;
for( j=0; values[j].bv_val != NULL; j++ ) {
/* Yes, this is necessary */
- val = UTF8normalize( &values[j], UTF8_NOCASEFOLD );
+ val = UTF8normalize( &values[j], LDAP_UTF8_NOCASEFOLD );
strip8bitChars( val );
/* Isolate how many words there are. There will be a key for each */
/* Allocate/increase storage to account for new keys */
newkeys = (struct berval *)ch_malloc( (keycount + wordcount + 1)
* sizeof(struct berval) );
- memcpy( newkeys, keys, keycount * sizeof(struct berval) );
+ AC_MEMCPY( newkeys, keys, keycount * sizeof(struct berval) );
if( keys ) ch_free( keys );
keys = newkeys;
/* Yes, this is necessary */
val = UTF8normalize( ((struct berval *)assertValue),
- UTF8_NOCASEFOLD );
+ LDAP_UTF8_NOCASEFOLD );
if( val == NULL ) {
keys = (struct berval *)ch_malloc( sizeof(struct berval) );
keys[0].bv_val = NULL;
{
*matchp = UTF8normcmp( value->bv_val,
((struct berval *) assertedValue)->bv_val,
- UTF8_NOCASEFOLD );
+ LDAP_UTF8_NOCASEFOLD );
return LDAP_SUCCESS;
}
struct berval left;
int i;
ber_len_t inlen=0;
- char *nav, casefold;
+ char *nav;
+ unsigned casefold;
casefold = strcmp( mr->smr_oid, caseExactSubstringsMatchOID )
- ? UTF8_CASEFOLD : UTF8_NOCASEFOLD;
+ ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD;
nav = UTF8normalize( value, casefold );
if( nav == NULL ) {
BVarray *keysp )
{
int i;
- char casefold;
+ unsigned casefold;
size_t slen, mlen;
BVarray keys;
HASH_CONTEXT HASHcontext;
mlen = mr->smr_oidlen;
casefold = strcmp( mr->smr_oid, caseExactMatchOID )
- ? UTF8_CASEFOLD : UTF8_NOCASEFOLD;
+ ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD;
for( i=0; values[i].bv_val != NULL; i++ ) {
struct berval value;
void * assertValue,
BVarray *keysp )
{
- char casefold;
+ unsigned casefold;
size_t slen, mlen;
BVarray keys;
HASH_CONTEXT HASHcontext;
mlen = mr->smr_oidlen;
casefold = strcmp( mr->smr_oid, caseExactMatchOID )
- ? UTF8_CASEFOLD : UTF8_NOCASEFOLD;
+ ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD;
ber_str2bv( UTF8normalize( ((struct berval *) assertValue), casefold ),
0, 0, &value );
BVarray values,
BVarray *keysp )
{
- char casefold;
+ unsigned casefold;
ber_len_t i, nkeys;
size_t slen, mlen;
BVarray keys;
assert( i > 0 );
casefold = strcmp( mr->smr_oid, caseExactSubstringsMatchOID )
- ? UTF8_CASEFOLD : UTF8_NOCASEFOLD;
+ ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD;
nvalues = ch_malloc( sizeof( struct berval ) * (i+1) );
for( i=0; values[i].bv_val != NULL; i++ ) {
BVarray *keysp )
{
SubstringsAssertion *sa;
- char pre, casefold;
+ char pre;
+ unsigned casefold;
ber_len_t nkeys = 0;
size_t slen, mlen, klen;
BVarray keys;
struct berval digest;
casefold = strcmp( mr->smr_oid, caseExactSubstringsMatchOID )
- ? UTF8_CASEFOLD : UTF8_NOCASEFOLD;
+ ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD;
sa = UTF8SubstringsassertionNormalize( assertValue, casefold );
if( sa == NULL ) {
{
*matchp = UTF8normcmp( value->bv_val,
((struct berval *) assertedValue)->bv_val,
- UTF8_CASEFOLD );
+ LDAP_UTF8_CASEFOLD );
return LDAP_SUCCESS;
}
if( negative ) {
normalized->bv_val[0] = '-';
}
- memcpy( normalized->bv_val + negative, p, len );
+ AC_MEMCPY( normalized->bv_val + negative, p, len );
}
return LDAP_SUCCESS;
{
ber_len_t i;
- if( !val->bv_len ) return LDAP_INVALID_SYNTAX;
-
for(i=0; i < val->bv_len; i++) {
if( !SLAP_PRINTABLE(val->bv_val[i]) ) {
return LDAP_INVALID_SYNTAX;
{
ber_len_t i;
- if( !val->bv_len ) return LDAP_INVALID_SYNTAX;
-
for(i=0; i < val->bv_len; i++) {
if( !SLAP_PRINTABLES(val->bv_val[i]) ) {
return LDAP_INVALID_SYNTAX;
{
ber_len_t i;
- if( !val->bv_len ) return LDAP_INVALID_SYNTAX;
-
for(i=0; i < val->bv_len; i++) {
- if( !isascii(val->bv_val[i]) ) return LDAP_INVALID_SYNTAX;
+ if( !LDAP_ASCII(val->bv_val[i]) ) {
+ return LDAP_INVALID_SYNTAX;
+ }
}
return LDAP_SUCCESS;
p++;
}
- if( *p == '\0' ) {
- return LDAP_INVALID_SYNTAX;
- }
-
normalized->bv_val = ch_strdup( p );
p = q = normalized->bv_val;
}
}
- assert( normalized->bv_val < p );
+ assert( normalized->bv_val <= p );
assert( q <= p );
- /* cannot start with a space */
- assert( !ASCII_SPACE(*normalized->bv_val) );
-
/*
* If the string ended in space, backup the pointer one
* position. One is enough because the above loop collapsed
--q;
}
- /* cannot end with a space */
- assert( !ASCII_SPACE( q[-1] ) );
-
/* null terminate */
*q = '\0';
X509_free(xcert);
- out->bv_len = serial->bv_len + 3 + issuer_dn->bv_len + 1;
+ out->bv_len = serial->bv_len + issuer_dn->bv_len + sizeof(" $ ");
out->bv_val = ch_malloc(out->bv_len);
p = out->bv_val;
AC_MEMCPY(p, serial->bv_val, serial->bv_len);
p += serial->bv_len;
- AC_MEMCPY(p, " $ ", 3);
+ AC_MEMCPY(p, " $ ", sizeof(" $ ")-1);
p += 3;
AC_MEMCPY(p, issuer_dn->bv_val, issuer_dn->bv_len);
p += issuer_dn->bv_len;
bv.bv_len = end-begin+1;
bv.bv_val = begin;
- *serial = ber_bvdup(&bv);
+ *serial = ber_dupbv(NULL, &bv);
/* now extract the issuer, remember p was at the dollar sign */
begin = p+1;
return LDAP_INVALID_SYNTAX;
}
- for ( p++; ( p < e ) && ( *p != ')' ); p++ ) {
+ for ( p++; ( p < e ) && ( *p != /*'('*/ ')' ); p++ ) {
if ( *p == ',' ) {
commas++;
if ( commas > 2 ) {
slap_syntax_transform_func *sd_str2ber;
#endif
} syntax_defs[] = {
- {"( 1.3.6.1.4.1.1466.115.121.1.1 DESC 'ACI Item' " X_BINARY X_NOT_H_R ")",
+ {"( 1.3.6.1.4.1.1466.115.121.1.1 DESC 'ACI Item' "
+ X_BINARY X_NOT_H_R ")",
SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.2 DESC 'Access Point' " X_NOT_H_R ")",
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.3 DESC 'Attribute Type Description' )",
0, NULL, NULL, NULL},
- {"( 1.3.6.1.4.1.1466.115.121.1.4 DESC 'Audio' " X_NOT_H_R ")",
+ {"( 1.3.6.1.4.1.1466.115.121.1.4 DESC 'Audio' "
+ X_NOT_H_R ")",
SLAP_SYNTAX_BLOB, blobValidate, NULL, NULL},
- {"( 1.3.6.1.4.1.1466.115.121.1.5 DESC 'Binary' " X_NOT_H_R ")",
+ {"( 1.3.6.1.4.1.1466.115.121.1.5 DESC 'Binary' "
+ X_NOT_H_R ")",
SLAP_SYNTAX_BER, berValidate, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.6 DESC 'Bit String' )",
0, bitStringValidate, bitStringNormalize, NULL },
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.44 DESC 'Printable String' )",
0, printableStringValidate, IA5StringNormalize, NULL},
+ {"( 1.3.6.1.4.1.1466.115.121.1.45 DESC 'SubtreeSpecification' "
+ X_BINARY X_NOT_H_R ")",
+ SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.49 DESC 'Supported Algorithm' "
X_BINARY X_NOT_H_R ")",
SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
UTF8StringValidate /* THIS WILL CHANGE FOR NEW ACI SYNTAX */,
NULL, NULL},
+#ifdef SLAPD_AUTHPASSWD
/* needs updating */
{"( 1.3.6.1.4.1.4203.666.2.2 DESC 'OpenLDAP authPassword' )",
SLAP_SYNTAX_HIDE, NULL, NULL, NULL},
+#endif
/* OpenLDAP Void Syntax */
{"( 1.3.6.1.4.1.4203.1.1.1 DESC 'OpenLDAP void' )" ,
*/
{"( " directoryStringApproxMatchOID " NAME 'directoryStringApproxMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
- SLAP_MR_EQUALITY_APPROX | SLAP_MR_EXT,
+ SLAP_MR_HIDE | SLAP_MR_EQUALITY_APPROX | SLAP_MR_EXT,
NULL, NULL,
directoryStringApproxMatch,
directoryStringApproxIndexer,
{"( " IA5StringApproxMatchOID " NAME 'IA5StringApproxMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
- SLAP_MR_EQUALITY_APPROX | SLAP_MR_EXT,
+ SLAP_MR_HIDE | SLAP_MR_EQUALITY_APPROX | SLAP_MR_EXT,
NULL, NULL,
IA5StringApproxMatch,
IA5StringApproxIndexer,
caseExactIA5SubstringsFilter,
NULL},
+#ifdef SLAPD_AUTHPASSWD
/* needs updating */
{"( 1.3.6.1.4.1.4203.666.4.1 NAME 'authPasswordMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
NULL, NULL,
authPasswordMatch, NULL, NULL,
NULL},
+#endif
{"( 1.3.6.1.4.1.4203.666.4.2 NAME 'OpenLDAPaciMatch' "
"SYNTAX 1.3.6.1.4.1.4203.666.2.1 )",
};
int
-schema_init( void )
+slap_schema_init( void )
{
int res;
int i;
);
if ( res ) {
- fprintf( stderr, "schema_init: Error registering syntax %s\n",
+ fprintf( stderr, "slap_schema_init: Error registering syntax %s\n",
syntax_defs[i].sd_desc );
return LDAP_OTHER;
}
for ( i=0; mrule_defs[i].mrd_desc != NULL; i++ ) {
if( mrule_defs[i].mrd_usage == SLAP_MR_NONE ) {
fprintf( stderr,
- "schema_init: Ingoring unusable matching rule %s\n",
+ "slap_schema_init: Ingoring unusable matching rule %s\n",
mrule_defs[i].mrd_desc );
continue;
}
if ( res ) {
fprintf( stderr,
- "schema_init: Error registering matching rule %s\n",
+ "slap_schema_init: Error registering matching rule %s\n",
mrule_defs[i].mrd_desc );
return LDAP_OTHER;
}
}
+
+ res = slap_schema_load();
schema_init_done = 1;
- return LDAP_SUCCESS;
+ return res;
}
void