#define HASH_Update(c,buf,len) lutil_HASHUpdate(c,buf,len)
#define HASH_Final(d,c) lutil_HASHFinal(d,c)
-#define SLAP_NVALUES 1
-
/* not yet implemented */
-#define objectIdentifierNormalize NULL
-#define integerOrderingMatch NULL
#define uniqueMemberMatch NULL
-#define integerFirstComponentNormalize NULL
-#define objectIdentifierFirstComponentNormalize NULL
#define OpenLDAPaciMatch NULL
/* approx matching rules */
-#ifdef SLAP_NVALUES
-#define directoryStringApproxMatchOID NULL
-#define IA5StringApproxMatchOID NULL
-#else
#define directoryStringApproxMatchOID "1.3.6.1.4.1.4203.666.4.4"
-#define directoryStringApproxMatch approxMatch
+#define directoryStringApproxMatch approxMatch
#define directoryStringApproxIndexer approxIndexer
-#define directoryStringApproxFilter approxFilter
+#define directoryStringApproxFilter approxFilter
#define IA5StringApproxMatchOID "1.3.6.1.4.1.4203.666.4.5"
#define IA5StringApproxMatch approxMatch
#define IA5StringApproxIndexer approxIndexer
#define IA5StringApproxFilter approxFilter
-#endif
static int
inValidate(
{
SubstringsAssertion *sa;
char pre;
- unsigned casefold;
ber_len_t nkeys = 0;
size_t slen, mlen, klen;
BerVarray keys;
*(uid.bv_val++) = '\0';
}
- rc = dnNormalize2( NULL, &out, normalized, ctx );
+ rc = dnNormalize( 0, NULL, NULL, &out, normalized, ctx );
if( rc != LDAP_SUCCESS ) {
free( out.bv_val );
*/
if( in->bv_len == 4 ) {
- if( !memcmp( in->bv_val, "TRUE", 4 ) ) {
+ if( bvmatch( in, &slap_true_bv ) ) {
return LDAP_SUCCESS;
}
} else if( in->bv_len == 5 ) {
- if( !memcmp( in->bv_val, "FALSE", 5 ) ) {
+ if( bvmatch( in, &slap_false_bv ) ) {
return LDAP_SUCCESS;
}
}
return LDAP_SUCCESS;
}
- flags = (mr == slap_schema.si_mr_caseExactMatch)
+ flags = SLAP_MR_ASSOCIATED( mr, slap_schema.si_mr_caseExactMatch )
? LDAP_UTF8_NOCASEFOLD : LDAP_UTF8_CASEFOLD;
flags |= ( ( use & SLAP_MR_EQUALITY_APPROX ) == SLAP_MR_EQUALITY_APPROX )
? LDAP_UTF8_APPROX : 0;
return LDAP_SUCCESS;
}
-#ifndef SLAP_NVALUES
-
-#ifndef SLAPD_APPROX_OLDSINGLESTRING
#if defined(SLAPD_APPROX_INITIALS)
-#define SLAPD_APPROX_DELIMITER "._ "
-#define SLAPD_APPROX_WORDLEN 2
+# define SLAPD_APPROX_DELIMITER "._ "
+# define SLAPD_APPROX_WORDLEN 2
#else
-#define SLAPD_APPROX_DELIMITER " "
-#define SLAPD_APPROX_WORDLEN 1
+# define SLAPD_APPROX_DELIMITER " "
+# define SLAPD_APPROX_WORDLEN 1
#endif
static int
int i, count, len, nextchunk=0, nextavail=0;
/* Yes, this is necessary */
- nval = UTF8bvnormalize( value, NULL, LDAP_UTF8_APPROX );
+ nval = UTF8bvnormalize( value, NULL, LDAP_UTF8_APPROX, NULL );
if( nval == NULL ) {
*matchp = 1;
return LDAP_SUCCESS;
/* Yes, this is necessary */
assertv = UTF8bvnormalize( ((struct berval *)assertedValue),
- NULL, LDAP_UTF8_APPROX );
+ NULL, LDAP_UTF8_APPROX, NULL );
if( assertv == NULL ) {
ber_bvfree( nval );
*matchp = 1;
MatchingRule *mr,
struct berval *prefix,
BerVarray values,
- BerVarray *keysp )
+ BerVarray *keysp,
+ void *ctx )
{
char *c;
int i,j, len, wordcount, keycount=0;
for( j=0; values[j].bv_val != NULL; j++ ) {
struct berval val = { 0, NULL };
/* Yes, this is necessary */
- UTF8bvnormalize( &values[j], &val, LDAP_UTF8_APPROX );
+ UTF8bvnormalize( &values[j], &val, LDAP_UTF8_APPROX, NULL );
assert( val.bv_val != NULL );
/* Isolate how many words there are. There will be a key for each */
MatchingRule *mr,
struct berval *prefix,
void * assertedValue,
- BerVarray *keysp )
+ BerVarray *keysp,
+ void *ctx )
{
char *c;
int i, count, len;
/* Yes, this is necessary */
val = UTF8bvnormalize( ((struct berval *)assertedValue),
- NULL, LDAP_UTF8_APPROX );
+ NULL, LDAP_UTF8_APPROX, NULL );
if( val == NULL || val->bv_val == NULL ) {
keys = (struct berval *)ch_malloc( sizeof(struct berval) );
keys[0].bv_val = NULL;
return LDAP_SUCCESS;
}
-#else
-/* No other form of Approximate Matching is defined */
-
-static int
-approxMatch(
- int *matchp,
- slap_mask_t flags,
- Syntax *syntax,
- MatchingRule *mr,
- struct berval *value,
- void *assertedValue )
-{
- char *vapprox, *avapprox;
- char *s, *t;
-
- /* Yes, this is necessary */
- s = UTF8normalize( value, UTF8_NOCASEFOLD );
- if( s == NULL ) {
- *matchp = 1;
- return LDAP_SUCCESS;
- }
-
- /* Yes, this is necessary */
- t = UTF8normalize( ((struct berval *)assertedValue),
- UTF8_NOCASEFOLD );
- if( t == NULL ) {
- free( s );
- *matchp = -1;
- return LDAP_SUCCESS;
- }
-
- vapprox = phonetic( strip8bitChars( s ) );
- avapprox = phonetic( strip8bitChars( t ) );
-
- free( s );
- free( t );
-
- *matchp = strcmp( vapprox, avapprox );
-
- ch_free( vapprox );
- ch_free( avapprox );
-
- return LDAP_SUCCESS;
-}
-
-static int
-approxIndexer(
- slap_mask_t use,
- slap_mask_t flags,
- Syntax *syntax,
- MatchingRule *mr,
- struct berval *prefix,
- BerVarray values,
- BerVarray *keysp )
-{
- int i;
- BerVarray *keys;
- char *s;
-
- for( i=0; values[i].bv_val != NULL; i++ ) {
- /* empty - just count them */
- }
-
- /* we should have at least one value at this point */
- assert( i > 0 );
-
- keys = (struct berval *)ch_malloc( sizeof( struct berval ) * (i+1) );
-
- /* Copy each value and run it through phonetic() */
- for( i=0; values[i].bv_val != NULL; i++ ) {
- /* Yes, this is necessary */
- s = UTF8normalize( &values[i], UTF8_NOCASEFOLD );
-
- /* strip 8-bit chars and run through phonetic() */
- ber_str2bv( phonetic( strip8bitChars( s ) ), 0, 0, &keys[i] );
- free( s );
- }
- keys[i].bv_val = NULL;
-
- *keysp = keys;
- return LDAP_SUCCESS;
-}
-
-static int
-approxFilter(
- slap_mask_t use,
- slap_mask_t flags,
- Syntax *syntax,
- MatchingRule *mr,
- struct berval *prefix,
- void * assertedValue,
- BerVarray *keysp )
-{
- BerVarray keys;
- char *s;
-
- keys = (struct berval *)ch_malloc( sizeof( struct berval * ) * 2 );
-
- /* Yes, this is necessary */
- s = UTF8normalize( ((struct berval *)assertedValue),
- UTF8_NOCASEFOLD );
- if( s == NULL ) {
- keys[0] = NULL;
- } else {
- /* strip 8-bit chars and run through phonetic() */
- keys[0] = ber_bvstr( phonetic( strip8bitChars( s ) ) );
- free( s );
- keys[1] = NULL;
- }
-
- *keysp = keys;
- return LDAP_SUCCESS;
-}
-#endif
-#endif /* !SLAP_NVALUES */
-
/* Remove all spaces and '-' characters */
static int
telephoneNumberNormalize(
}
static int
-oidValidate(
+numericoidValidate(
Syntax *syntax,
- struct berval *val )
+ struct berval *in )
{
- ber_len_t i;
+ struct berval val = *in;
- if( val->bv_len == 0 ) {
+ if( val.bv_len == 0 ) {
/* disallow empty strings */
return LDAP_INVALID_SYNTAX;
}
- if( OID_LEADCHAR(val->bv_val[0]) ) {
- int dot = 0;
- for(i=1; i < val->bv_len; i++) {
- if( OID_SEPARATOR( val->bv_val[i] ) ) {
- if( dot++ ) return 1;
- } else if ( OID_CHAR( val->bv_val[i] ) ) {
- dot = 0;
- } else {
- return LDAP_INVALID_SYNTAX;
- }
+ while( OID_LEADCHAR( val.bv_val[0] ) ) {
+ if ( val.bv_len == 1 ) {
+ return LDAP_SUCCESS;
}
- return !dot ? LDAP_SUCCESS : LDAP_INVALID_SYNTAX;
-
- } else if( DESC_LEADCHAR(val->bv_val[0]) ) {
- for(i=1; i < val->bv_len; i++) {
- if( !DESC_CHAR(val->bv_val[i] ) ) {
- return LDAP_INVALID_SYNTAX;
- }
+ if ( val.bv_val[0] == '0' ) {
+ break;
}
- return LDAP_SUCCESS;
- }
-
- return LDAP_INVALID_SYNTAX;
-}
-
-static int
-integerMatch(
- int *matchp,
- slap_mask_t flags,
- Syntax *syntax,
- MatchingRule *mr,
- struct berval *value,
- void *assertedValue )
-{
- char *v, *av;
- int vsign = 1, avsign = 1; /* default sign = '+' */
- struct berval *asserted;
- ber_len_t vlen, avlen;
- int match;
-
- /* Skip leading space/sign/zeroes, and get the sign of the *value number */
- v = value->bv_val;
- vlen = value->bv_len;
-
-#ifndef SLAP_NVALUES
- if( mr == slap_schema.si_mr_integerFirstComponentMatch ) {
- char *tmp = memchr( v, '$', vlen );
- if( tmp ) vlen = tmp - v;
- while( vlen && ASCII_SPACE( v[vlen-1] )) vlen--;
- }
-#endif
+ val.bv_val++;
+ val.bv_len--;
- for( ; vlen && ( *v < '1' || '9' < *v ); v++, vlen-- ) { /* ANSI 2.2.1 */
- if( *v == '-' ) vsign = -1;
- }
+ while ( OID_LEADCHAR( val.bv_val[0] )) {
+ val.bv_val++;
+ val.bv_len--;
- if( vlen == 0 ) vsign = 0;
+ if ( val.bv_len == 0 ) {
+ return LDAP_SUCCESS;
+ }
+ }
- /* Do the same with the *assertedValue number */
- asserted = (struct berval *) assertedValue;
- av = asserted->bv_val;
- avlen = asserted->bv_len;
- for( ; avlen && ( *av < '1' || '9' < *av ); av++, avlen-- )
- if( *av == '-' )
- avsign = -1;
- if( avlen == 0 )
- avsign = 0;
+ if( !OID_SEPARATOR( val.bv_val[0] )) {
+ break;
+ }
- match = vsign - avsign;
- if( match == 0 ) {
- match = (vlen != avlen
- ? ( vlen < avlen ? -1 : 1 )
- : memcmp( v, av, vlen ));
- if( vsign < 0 ) match = -match;
+ val.bv_val++;
+ val.bv_len--;
}
- *matchp = match;
- return LDAP_SUCCESS;
+ return LDAP_INVALID_SYNTAX;
}
-
+
static int
integerValidate(
Syntax *syntax,
- struct berval *val )
+ struct berval *in )
{
ber_len_t i;
+ struct berval val = *in;
- if( !val->bv_len ) return LDAP_INVALID_SYNTAX;
+ if( val.bv_len == 0 ) return LDAP_INVALID_SYNTAX;
- if(( val->bv_val[0] == '+' ) || ( val->bv_val[0] == '-' )) {
- if( val->bv_len < 2 ) return LDAP_INVALID_SYNTAX;
+ if ( val.bv_val[0] == '-' ) {
+ val.bv_len--;
+ val.bv_val++;
- } else if( !ASCII_DIGIT(val->bv_val[0]) ) {
- return LDAP_INVALID_SYNTAX;
+ if( val.bv_len == 0 ) { /* bare "-" */
+ return LDAP_INVALID_SYNTAX;
+ }
+
+ if( val.bv_val[0] == '0' ) { /* "-0" */
+ return LDAP_INVALID_SYNTAX;
+ }
+
+ } else if ( val.bv_val[0] == '0' ) {
+ if( val.bv_len > 1 ) { /* "0<more>" */
+ return LDAP_INVALID_SYNTAX;
+ }
+
+ return LDAP_SUCCESS;
}
- for( i=1; i < val->bv_len; i++ ) {
- if( !ASCII_DIGIT(val->bv_val[i]) ) return LDAP_INVALID_SYNTAX;
+ for( i=0; i < val.bv_len; i++ ) {
+ if( !ASCII_DIGIT(val.bv_val[i]) ) {
+ return LDAP_INVALID_SYNTAX;
+ }
}
return LDAP_SUCCESS;
}
static int
-integerNormalize(
- slap_mask_t use,
+integerMatch(
+ int *matchp,
+ slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
- struct berval *val,
- struct berval *normalized,
- void *ctx )
+ struct berval *value,
+ void *assertedValue )
{
- char *p;
- int negative=0;
- ber_len_t len;
-
- p = val->bv_val;
- len = val->bv_len;
+ struct berval *asserted = (struct berval *) assertedValue;
+ int vsign = 1, asign = 1; /* default sign = '+' */
+ struct berval v, a;
+ int match;
- /* Ignore leading spaces */
- while ( len && ( *p == ' ' )) {
- p++;
- len--;
+ v = *value;
+ if( v.bv_val[0] == '-' ) {
+ vsign = -1;
+ v.bv_val++;
+ v.bv_len--;
}
- /* save sign */
- if( len ) {
- negative = ( *p == '-' );
- if(( *p == '-' ) || ( *p == '+' )) {
- p++;
- len--;
- }
- }
+ if( v.bv_len == 0 ) vsign = 0;
- /* Ignore leading zeros */
- while ( len && ( *p == '0' )) {
- p++;
- len--;
+ a = *asserted;
+ if( a.bv_val[0] == '-' ) {
+ asign = -1;
+ a.bv_val++;
+ a.bv_len--;
}
- /* If there are no non-zero digits left, the number is zero, otherwise
- allocate space for the number and copy it into the buffer */
- if( len == 0 ) {
- normalized->bv_val = ber_strdup_x("0", ctx);
- normalized->bv_len = 1;
+ if( a.bv_len == 0 ) vsign = 0;
- } else {
- normalized->bv_len = len+negative;
- normalized->bv_val = sl_malloc( normalized->bv_len + 1, ctx );
- if( negative ) normalized->bv_val[0] = '-';
- AC_MEMCPY( normalized->bv_val + negative, p, len );
- normalized->bv_val[len+negative] = '\0';
+ match = vsign - asign;
+ if( match == 0 ) {
+ match = ( v.bv_len != a.bv_len
+ ? ( v.bv_len < a.bv_len ? -1 : 1 )
+ : memcmp( v.bv_val, a.bv_val, v.bv_len ));
+ if( vsign < 0 ) match = -match;
}
+ *matchp = match;
return LDAP_SUCCESS;
}
-
+
static int
countryStringValidate(
Syntax *syntax,
void *ctx )
{
char *p, *q;
- int casefold = (mr != slap_schema.si_mr_caseExactIA5Match);
+ int casefold = SLAP_MR_ASSOCIATED(mr, slap_schema.si_mr_caseExactIA5Match);
assert( val->bv_len );
p = val->bv_val;
/* Ignore initial whitespace */
- while ( ASCII_SPACE( *p ) ) {
- p++;
- }
+ while ( ASCII_SPACE( *p ) ) p++;
normalized->bv_val = ber_strdup_x( p, ctx );
p = q = normalized->bv_val;
* position. One is enough because the above loop collapsed
* all whitespace to a single space.
*/
-
- if ( ASCII_SPACE( q[-1] ) ) {
- --q;
- }
+ if ( ASCII_SPACE( q[-1] ) ) --q;
/* null terminate */
*q = '\0';
normalized->bv_len = q - normalized->bv_val;
-
if( normalized->bv_len == 0 ) {
normalized->bv_val = sl_realloc( normalized->bv_val, 2, ctx );
normalized->bv_val[0] = ' ';
return LDAP_SUCCESS;
}
-#ifndef SLAP_NVALUES
-static int
-objectIdentifierFirstComponentMatch(
- int *matchp,
- slap_mask_t flags,
- Syntax *syntax,
- MatchingRule *mr,
- struct berval *value,
- void *assertedValue )
-{
- int rc = LDAP_SUCCESS;
- int match;
- struct berval *asserted = (struct berval *) assertedValue;
- ber_len_t i, j;
- struct berval oid;
-
- if( value->bv_len == 0 || value->bv_val[0] != '(' /*')'*/ ) {
- return LDAP_INVALID_SYNTAX;
- }
-
- /* trim leading white space */
- for( i=1; ASCII_SPACE(value->bv_val[i]) && i < value->bv_len; i++ ) {
- /* empty */
- }
-
- /* grab next word */
- oid.bv_val = &value->bv_val[i];
- j = value->bv_len - i;
- for( i=0; !ASCII_SPACE(oid.bv_val[i]) && i < j; i++ ) {
- /* empty */
- }
- oid.bv_len = i;
-
- /* insert attributeTypes, objectclass check here */
- if( OID_LEADCHAR(asserted->bv_val[0]) ) {
- rc = objectIdentifierMatch( &match, flags, syntax, mr, &oid, asserted );
-
- } else {
- if ( !strcmp( syntax->ssyn_oid, SLAP_SYNTAX_MATCHINGRULES_OID ) ) {
- MatchingRule *asserted_mr = mr_bvfind( asserted );
- MatchingRule *stored_mr = mr_bvfind( &oid );
-
- if( asserted_mr == NULL ) {
- rc = SLAPD_COMPARE_UNDEFINED;
- } else {
- match = asserted_mr != stored_mr;
- }
-
- } else if ( !strcmp( syntax->ssyn_oid,
- SLAP_SYNTAX_ATTRIBUTETYPES_OID ) )
- {
- AttributeType *asserted_at = at_bvfind( asserted );
- AttributeType *stored_at = at_bvfind( &oid );
-
- if( asserted_at == NULL ) {
- rc = SLAPD_COMPARE_UNDEFINED;
- } else {
- match = asserted_at != stored_at;
- }
-
- } else if ( !strcmp( syntax->ssyn_oid,
- SLAP_SYNTAX_OBJECTCLASSES_OID ) )
- {
- ObjectClass *asserted_oc = oc_bvfind( asserted );
- ObjectClass *stored_oc = oc_bvfind( &oid );
-
- if( asserted_oc == NULL ) {
- rc = SLAPD_COMPARE_UNDEFINED;
- } else {
- match = asserted_oc != stored_oc;
- }
- }
- }
-
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, ENTRY,
- "objectIdentifierFirstComponentMatch: %d\n %s\n %s\n",
- match, value->bv_val, asserted->bv_val );
-#else
- Debug( LDAP_DEBUG_ARGS, "objectIdentifierFirstComponentMatch "
- "%d\n\t\"%s\"\n\t\"%s\"\n",
- match, value->bv_val, asserted->bv_val );
-#endif
-
- if( rc == LDAP_SUCCESS ) *matchp = match;
- return rc;
-}
-#endif
-
static int
integerBitAndMatch(
int *matchp,
return LDAP_SUCCESS;
}
-#ifndef SLAP_NVALUES
+static int
+serialNumberAndIssuerValidate(
+ Syntax *syntax,
+ struct berval *in )
+{
+ int rc = LDAP_INVALID_SYNTAX;
+ struct berval serialNumber, issuer;
+
+ serialNumber.bv_val = in->bv_val;
+ for( serialNumber.bv_len = 0;
+ serialNumber.bv_len < in->bv_len;
+ serialNumber.bv_len++ )
+ {
+ if ( serialNumber.bv_val[serialNumber.bv_len] == '$' ) {
+ issuer.bv_val = &serialNumber.bv_val[serialNumber.bv_len+1];
+ issuer.bv_len = in->bv_len - (serialNumber.bv_len+1);
+
+ if( serialNumber.bv_len == 0 || issuer.bv_len == 0 ) break;
+
+ rc = integerValidate( NULL, &serialNumber );
+ if( rc ) break;
+
+ rc = dnValidate( NULL, &issuer );
+ break;
+ }
+ }
+
+ return rc;
+}
+
+static int
+serialNumberAndIssuerNormalize(
+ slap_mask_t usage,
+ Syntax *syntax,
+ MatchingRule *mr,
+ struct berval *val,
+ struct berval *normalized,
+ void *ctx )
+{
+ int rc = LDAP_INVALID_SYNTAX;
+ struct berval serialNumber, issuer, nissuer;
+
+ serialNumber.bv_val = val->bv_val;
+ for( serialNumber.bv_len = 0;
+ serialNumber.bv_len < val->bv_len;
+ serialNumber.bv_len++ )
+ {
+ if ( serialNumber.bv_val[serialNumber.bv_len] == '$' ) {
+ issuer.bv_val = &serialNumber.bv_val[serialNumber.bv_len+1];
+ issuer.bv_len = val->bv_len - (serialNumber.bv_len+1);
+
+ if( serialNumber.bv_len == 0 || issuer.bv_len == 0 ) break;
+
+ rc = dnNormalize( usage, syntax, mr, &issuer, &nissuer, ctx );
+ if( rc ) break;
+
+ normalized->bv_len = serialNumber.bv_len + 1 + nissuer.bv_len;
+ normalized->bv_val = ch_malloc( normalized->bv_len + 1);
+
+ AC_MEMCPY( normalized->bv_val,
+ serialNumber.bv_val, serialNumber.bv_len );
+ normalized->bv_val[serialNumber.bv_len] = '$';
+ AC_MEMCPY( &normalized->bv_val[serialNumber.bv_len+1],
+ nissuer.bv_val, nissuer.bv_len );
+ normalized->bv_val[normalized->bv_len] = '\0';
+ break;
+ }
+ }
+
+ return rc;
+}
+
#ifdef HAVE_TLS
#include <openssl/x509.h>
#include <openssl/err.h>
struct berval * in,
struct berval * out )
{
+ int rc;
X509 *xcert;
unsigned char *p = in->bv_val;
struct berval serial;
X509_free(xcert);
return LDAP_INVALID_SYNTAX;
}
- if ( dnX509normalize(X509_get_issuer_name(xcert), &issuer_dn )
- != LDAP_SUCCESS )
- {
+
+ rc = dnX509normalize(X509_get_issuer_name(xcert), &issuer_dn );
+ if( rc != LDAP_SUCCESS ) {
X509_free(xcert);
ber_memfree(serial.bv_val);
return LDAP_INVALID_SYNTAX;
}
static int
-serial_and_issuer_parse(
- struct berval *assertion,
- struct berval *serial,
- struct berval *issuer_dn )
-{
- char *begin;
- char *end;
- char *p;
- struct berval bv;
-
- begin = assertion->bv_val;
- end = assertion->bv_val+assertion->bv_len-1;
- for (p=begin; p<=end && *p != '$'; p++) /* empty */ ;
- if ( p > end ) return LDAP_INVALID_SYNTAX;
-
- /* p now points at the $ sign, now use
- * begin and end to delimit the serial number
- */
- while (ASCII_SPACE(*begin)) begin++;
- end = p-1;
- while (ASCII_SPACE(*end)) end--;
-
- if( end <= begin ) return LDAP_INVALID_SYNTAX;
-
- bv.bv_len = end-begin+1;
- bv.bv_val = begin;
- ber_dupbv(serial, &bv);
-
- /* now extract the issuer, remember p was at the dollar sign */
- begin = p+1;
- end = assertion->bv_val+assertion->bv_len-1;
- while (ASCII_SPACE(*begin)) begin++;
- /* should we trim spaces at the end too? is it safe always? no, no */
-
- if( end <= begin ) return LDAP_INVALID_SYNTAX;
-
- if ( issuer_dn ) {
- bv.bv_len = end-begin+1;
- bv.bv_val = begin;
-
- dnNormalize2( NULL, &bv, issuer_dn );
- }
-
- return LDAP_SUCCESS;
-}
-
-static int
-certificateExactMatch(
- int *matchp,
- slap_mask_t flags,
- Syntax *syntax,
- MatchingRule *mr,
- struct berval *value,
- void *assertedValue )
-{
- X509 *xcert;
- unsigned char *p = value->bv_val;
- struct berval serial;
- struct berval issuer_dn;
- struct berval asserted_serial;
- struct berval asserted_issuer_dn;
- int ret;
-
- xcert = d2i_X509(NULL, &p, value->bv_len);
- if ( !xcert ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, ENTRY,
- "certificateExactMatch: error parsing cert: %s\n",
- ERR_error_string(ERR_get_error(),NULL), 0, 0 );
-#else
- Debug( LDAP_DEBUG_ARGS, "certificateExactMatch: "
- "error parsing cert: %s\n",
- ERR_error_string(ERR_get_error(),NULL), NULL, NULL );
-#endif
- return LDAP_INVALID_SYNTAX;
- }
-
- asn1_integer2str(xcert->cert_info->serialNumber, &serial);
- dnX509normalize(X509_get_issuer_name(xcert), &issuer_dn);
-
- X509_free(xcert);
-
- serial_and_issuer_parse(assertedValue,
- &asserted_serial, &asserted_issuer_dn);
-
- ret = integerMatch(
- matchp,
- flags,
- slap_schema.si_syn_integer,
- slap_schema.si_mr_integerMatch,
- &serial,
- &asserted_serial);
- if ( ret == LDAP_SUCCESS ) {
- if ( *matchp == 0 ) {
- /* We need to normalize everything for dnMatch */
- ret = dnMatch(
- matchp,
- flags,
- slap_schema.si_syn_distinguishedName,
- slap_schema.si_mr_distinguishedNameMatch,
- &issuer_dn,
- &asserted_issuer_dn);
- }
- }
-
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, ARGS, "certificateExactMatch "
- "%d\n\t\"%s $ %s\"\n",
- *matchp, serial.bv_val, issuer_dn.bv_val );
- LDAP_LOG( CONFIG, ARGS, "\t\"%s $ %s\"\n",
- asserted_serial.bv_val, asserted_issuer_dn.bv_val,
- 0 );
-#else
- Debug( LDAP_DEBUG_ARGS, "certificateExactMatch "
- "%d\n\t\"%s $ %s\"\n",
- *matchp, serial.bv_val, issuer_dn.bv_val );
- Debug( LDAP_DEBUG_ARGS, "\t\"%s $ %s\"\n",
- asserted_serial.bv_val, asserted_issuer_dn.bv_val,
- NULL );
-#endif
-
- ber_memfree(serial.bv_val);
- ber_memfree(issuer_dn.bv_val);
- ber_memfree(asserted_serial.bv_val);
- ber_memfree(asserted_issuer_dn.bv_val);
-
- return ret;
-}
-
-/*
- * Index generation function
- * We just index the serials, in most scenarios the issuer DN is one of
- * a very small set of values.
- */
-static int certificateExactIndexer(
- slap_mask_t use,
- slap_mask_t flags,
+certificateExactNormalize(
+ slap_mask_t usage,
Syntax *syntax,
MatchingRule *mr,
- struct berval *prefix,
- BerVarray values,
- BerVarray *keysp )
+ struct berval *val,
+ struct berval *normalized,
+ void *ctx )
{
- int i;
- BerVarray keys;
- X509 *xcert;
- unsigned char *p;
- struct berval serial;
-
- /* we should have at least one value at this point */
- assert( values != NULL && values[0].bv_val != NULL );
-
- for( i=0; values[i].bv_val != NULL; i++ ) {
- /* empty -- just count them */
- }
-
- keys = ch_malloc( sizeof( struct berval ) * (i+1) );
+ int rc;
- for( i=0; values[i].bv_val != NULL; i++ ) {
- p = values[i].bv_val;
- xcert = d2i_X509(NULL, &p, values[i].bv_len);
- if ( !xcert ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, ENTRY,
- "certificateExactIndexer: error parsing cert: %s\n",
- ERR_error_string(ERR_get_error(),NULL), 0, 0);
-#else
- Debug( LDAP_DEBUG_ARGS, "certificateExactIndexer: "
- "error parsing cert: %s\n",
- ERR_error_string(ERR_get_error(),NULL),
- NULL, NULL );
-#endif
- /* Do we leak keys on error? */
- return LDAP_INVALID_SYNTAX;
- }
+ if( SLAP_MR_IS_VALUE_OF_ASSERTION_SYNTAX( usage ) ) {
+ rc = serialNumberAndIssuerNormalize( usage, syntax, mr,
+ val, normalized, ctx );
- asn1_integer2str(xcert->cert_info->serialNumber, &serial);
- X509_free(xcert);
- xintegerNormalize( slap_schema.si_syn_integer,
- &serial, &keys[i] );
- ber_memfree(serial.bv_val);
-#ifdef NEW_LOGGING
- LDAP_LOG( CONFIG, ENTRY,
- "certificateExactIndexer: returning: %s\n", keys[i].bv_val, 0, 0);
-#else
- Debug( LDAP_DEBUG_ARGS, "certificateExactIndexer: "
- "returning: %s\n",
- keys[i].bv_val,
- NULL, NULL );
-#endif
+ } else {
+ rc = certificateExactConvert( val, normalized );
}
- keys[i].bv_val = NULL;
- *keysp = keys;
- return LDAP_SUCCESS;
+ return rc;
}
+#endif /* HAVE_TLS */
-/* Index generation function */
-/* We think this is always called with a value in matching rule syntax */
-static int certificateExactFilter(
- slap_mask_t use,
- slap_mask_t flags,
- Syntax *syntax,
- MatchingRule *mr,
- struct berval *prefix,
- void * assertedValue,
- BerVarray *keysp )
-{
- BerVarray keys;
- struct berval asserted_serial;
- int ret;
-
- ret = serial_and_issuer_parse( assertedValue, &asserted_serial, NULL );
- if( ret != LDAP_SUCCESS ) return ret;
-
- keys = ch_malloc( sizeof( struct berval ) * 2 );
- xintegerNormalize( syntax, &asserted_serial, &keys[0] );
- keys[1].bv_val = NULL;
- *keysp = keys;
-
- ber_memfree(asserted_serial.bv_val);
- return LDAP_SUCCESS;
-}
-#endif
-#endif
static int
check_time_syntax (struct berval *val,
return rc;
}
- normalized->bv_val = sl_malloc( 16, ctx );
+ normalized->bv_val = sl_malloc( sizeof("YYYYmmddHHMMSSZ"), ctx );
if ( normalized->bv_val == NULL ) {
return LBER_ERROR_MEMORY;
}
return LDAP_SUCCESS;
}
+static int
+firstComponentNormalize(
+ slap_mask_t usage,
+ Syntax *syntax,
+ MatchingRule *mr,
+ struct berval *val,
+ struct berval *normalized,
+ void *ctx )
+{
+ int rc;
+ struct berval oid;
+ ber_len_t len;
+
+ if( val->bv_len < 3 ) return LDAP_INVALID_SYNTAX;
+
+ if( val->bv_val[0] != '(' /*')'*/ &&
+ val->bv_val[0] != '{' /*'}'*/ )
+ {
+ return LDAP_INVALID_SYNTAX;
+ }
+
+ /* trim leading white space */
+ for( len=1;
+ len < val->bv_len && ASCII_SPACE(val->bv_val[len]);
+ len++ )
+ {
+ /* empty */
+ }
+
+ /* grab next word */
+ oid.bv_val = &val->bv_val[len];
+ len = val->bv_len - len;
+ for( oid.bv_len=0;
+ !ASCII_SPACE(oid.bv_val[oid.bv_len]) && oid.bv_len < len;
+ oid.bv_len++ )
+ {
+ /* empty */
+ }
+
+ if( mr == slap_schema.si_mr_objectIdentifierFirstComponentMatch ) {
+ rc = numericoidValidate( NULL, &oid );
+ } else if( mr == slap_schema.si_mr_integerFirstComponentMatch ) {
+ rc = integerValidate( NULL, &oid );
+ } else {
+ rc = LDAP_INVALID_SYNTAX;
+ }
+
+
+ if( rc == LDAP_SUCCESS ) {
+ ber_dupbv_x( normalized, &oid, ctx );
+ }
+
+ return rc;
+}
+
#define X_BINARY "X-BINARY-TRANSFER-REQUIRED 'TRUE' "
#define X_NOT_H_R "X-NOT-HUMAN-READABLE 'TRUE' "
{"( 1.3.6.1.4.1.1466.115.121.1.11 DESC 'Country String' )",
0, countryStringValidate, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.12 DESC 'Distinguished Name' )",
- 0, dnValidate, dnPretty2},
+ 0, dnValidate, dnPretty},
{"( 1.3.6.1.4.1.1466.115.121.1.13 DESC 'Data Quality' )",
0, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.14 DESC 'Delivery Method' )",
{"( 1.3.6.1.4.1.1466.115.121.1.37 DESC 'Object Class Description' )",
0, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.38 DESC 'OID' )",
- 0, oidValidate, NULL},
+ 0, numericoidValidate, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.39 DESC 'Other Mailbox' )",
0, IA5StringValidate, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.40 DESC 'Octet String' )",
0, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.44 DESC 'Printable String' )",
0, printableStringValidate, 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},
+ {"( 1.3.6.1.4.1.1466.115.121.1.45 DESC 'SubtreeSpecification' )",
+#define subtreeSpecificationValidate UTF8StringValidate /* FIXME */
+ 0, subtreeSpecificationValidate, 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},
{"( 1.3.6.1.1.1.0.1 DESC 'RFC2307 Boot Parameter' )",
0, bootParameterValidate, NULL},
-#ifdef HAVE_TLS
/* From PKIX */
/* These OIDs are not published yet, but will be in the next
* I-D for PKIX LDAPv3 schema as have been advanced by David
* Chadwick in private mail.
*/
{"( 1.2.826.0.1.3344810.7.1 DESC 'Serial Number and Issuer' )",
- 0, UTF8StringValidate, NULL},
-#endif
+ 0, serialNumberAndIssuerValidate, NULL},
/* OpenLDAP Experimental Syntaxes */
#ifdef SLAPD_ACI_ENABLED
* EQUALITY matching rules must be listed after associated APPROX
* matching rules. So, we list all APPROX matching rules first.
*/
-#ifndef SLAP_NVALUES
{"( " directoryStringApproxMatchOID " NAME 'directoryStringApproxMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
SLAP_MR_HIDE | SLAP_MR_EQUALITY_APPROX | SLAP_MR_EXT, NULL,
NULL, NULL, IA5StringApproxMatch,
IA5StringApproxIndexer, IA5StringApproxFilter,
NULL},
-#endif
/*
* Other matching rules
{"( 2.5.13.0 NAME 'objectIdentifierMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
SLAP_MR_EQUALITY | SLAP_MR_EXT, NULL,
- NULL, objectIdentifierNormalize, octetStringMatch,
+ NULL, NULL, octetStringMatch,
octetStringIndexer, octetStringFilter,
- NULL},
+ NULL },
{"( 2.5.13.1 NAME 'distinguishedNameMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
SLAP_MR_EQUALITY | SLAP_MR_EXT, NULL,
NULL, dnNormalize, dnMatch,
octetStringIndexer, octetStringFilter,
- NULL},
+ NULL },
{"( 2.5.13.2 NAME 'caseIgnoreMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
SLAP_MR_ORDERING, directoryStringSyntaxes,
NULL, UTF8StringNormalize, octetStringOrderingMatch,
NULL, NULL,
- NULL},
+ "caseIgnoreMatch" },
{"( 2.5.13.4 NAME 'caseIgnoreSubstringsMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
SLAP_MR_SUBSTR, NULL,
NULL, UTF8StringNormalize, octetStringSubstringsMatch,
octetStringSubstringsIndexer, octetStringSubstringsFilter,
- NULL},
+ "caseIgnoreMatch" },
{"( 2.5.13.5 NAME 'caseExactMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
SLAP_MR_ORDERING, directoryStringSyntaxes,
NULL, UTF8StringNormalize, octetStringOrderingMatch,
NULL, NULL,
- NULL},
+ "caseExactMatch" },
{"( 2.5.13.7 NAME 'caseExactSubstringsMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
SLAP_MR_SUBSTR, directoryStringSyntaxes,
NULL, UTF8StringNormalize, octetStringSubstringsMatch,
octetStringSubstringsIndexer, octetStringSubstringsFilter,
- NULL},
+ "caseExactMatch" },
{"( 2.5.13.8 NAME 'numericStringMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 )",
SLAP_MR_EQUALITY | SLAP_MR_EXT, NULL,
NULL, numericStringNormalize, octetStringSubstringsMatch,
octetStringSubstringsIndexer, octetStringSubstringsFilter,
- NULL},
+ NULL },
{"( 2.5.13.10 NAME 'numericStringSubstringsMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
SLAP_MR_SUBSTR, NULL,
NULL, numericStringNormalize, octetStringSubstringsMatch,
octetStringSubstringsIndexer, octetStringSubstringsFilter,
- NULL},
+ "numericStringMatch" },
{"( 2.5.13.11 NAME 'caseIgnoreListMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )",
SLAP_MR_EQUALITY | SLAP_MR_EXT, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL},
+ NULL, NULL, NULL, NULL, NULL, NULL },
{"( 2.5.13.12 NAME 'caseIgnoreListSubstringsMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
SLAP_MR_SUBSTR, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL},
+ NULL, NULL, NULL, NULL, NULL,
+ "caseIgnoreListMatch" },
{"( 2.5.13.13 NAME 'booleanMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 )",
SLAP_MR_EQUALITY | SLAP_MR_EXT, NULL,
NULL, NULL, booleanMatch,
octetStringIndexer, octetStringFilter,
- NULL},
+ NULL },
{"( 2.5.13.14 NAME 'integerMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
SLAP_MR_EQUALITY | SLAP_MR_EXT, NULL,
- NULL, integerNormalize, integerMatch,
+ NULL, NULL, integerMatch,
octetStringIndexer, octetStringFilter,
- NULL},
+ NULL },
{"( 2.5.13.15 NAME 'integerOrderingMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
SLAP_MR_ORDERING, NULL,
- NULL, integerNormalize, integerOrderingMatch,
+ NULL, NULL, integerMatch,
NULL, NULL,
- NULL},
+ "integerMatch" },
{"( 2.5.13.16 NAME 'bitStringMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.6 )",
SLAP_MR_EQUALITY | SLAP_MR_EXT, NULL,
NULL, NULL, octetStringMatch,
octetStringIndexer, octetStringFilter,
- NULL},
+ NULL },
{"( 2.5.13.17 NAME 'octetStringMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
SLAP_MR_EQUALITY | SLAP_MR_EXT, NULL,
NULL, NULL, octetStringMatch,
octetStringIndexer, octetStringFilter,
- NULL},
+ NULL },
{"( 2.5.13.18 NAME 'octetStringOrderingMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
SLAP_MR_ORDERING, NULL,
NULL, NULL, octetStringOrderingMatch,
NULL, NULL,
- NULL},
+ "octetStringMatch" },
{"( 2.5.13.19 NAME 'octetStringSubstringsMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
SLAP_MR_SUBSTR, NULL,
NULL, NULL, octetStringSubstringsMatch,
octetStringSubstringsIndexer, octetStringSubstringsFilter,
- NULL},
+ "octetStringMatch" },
{"( 2.5.13.20 NAME 'telephoneNumberMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 )",
NULL,
telephoneNumberNormalize, octetStringMatch,
octetStringIndexer, octetStringFilter,
- NULL},
+ NULL },
{"( 2.5.13.21 NAME 'telephoneNumberSubstringsMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
SLAP_MR_SUBSTR, NULL,
NULL, telephoneNumberNormalize, octetStringSubstringsMatch,
octetStringSubstringsIndexer, octetStringSubstringsFilter,
- NULL},
+ "telephoneNumberMatch" },
{"( 2.5.13.22 NAME 'presentationAddressMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.43 )",
SLAP_MR_EQUALITY | SLAP_MR_EXT, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL},
+ NULL, NULL, NULL, NULL, NULL, NULL },
{"( 2.5.13.23 NAME 'uniqueMemberMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.34 )",
SLAP_MR_EQUALITY | SLAP_MR_EXT, NULL,
NULL, uniqueMemberNormalize, uniqueMemberMatch,
NULL, NULL,
- NULL},
+ NULL },
{"( 2.5.13.24 NAME 'protocolInformationMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.42 )",
SLAP_MR_EQUALITY | SLAP_MR_EXT, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL},
+ NULL, NULL, NULL, NULL, NULL, NULL },
{"( 2.5.13.27 NAME 'generalizedTimeMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
SLAP_MR_EQUALITY | SLAP_MR_EXT, NULL,
NULL, generalizedTimeNormalize, octetStringMatch,
NULL, NULL,
- NULL},
+ NULL },
{"( 2.5.13.28 NAME 'generalizedTimeOrderingMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
SLAP_MR_ORDERING, NULL,
NULL, generalizedTimeNormalize, octetStringOrderingMatch,
NULL, NULL,
- NULL},
+ "generalizedTimeMatch" },
{"( 2.5.13.29 NAME 'integerFirstComponentMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
- SLAP_MR_EQUALITY | SLAP_MR_EXT, integerFirstComponentMatchSyntaxes,
- NULL, integerFirstComponentNormalize, integerMatch,
- NULL, NULL,
- NULL},
+ SLAP_MR_EQUALITY | SLAP_MR_EXT,
+ integerFirstComponentMatchSyntaxes,
+ NULL, firstComponentNormalize, integerMatch,
+ octetStringIndexer, octetStringFilter,
+ NULL },
{"( 2.5.13.30 NAME 'objectIdentifierFirstComponentMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
SLAP_MR_EQUALITY | SLAP_MR_EXT,
objectIdentifierFirstComponentMatchSyntaxes,
- NULL, objectIdentifierFirstComponentNormalize, octetStringMatch,
+ NULL, firstComponentNormalize, octetStringMatch,
octetStringIndexer, octetStringFilter,
- NULL},
+ NULL },
-#ifndef SLAP_NVALUES
#ifdef HAVE_TLS
{"( 2.5.13.34 NAME 'certificateExactMatch' "
"SYNTAX 1.2.826.0.1.3344810.7.1 )",
SLAP_MR_EQUALITY | SLAP_MR_EXT, certificateExactMatchSyntaxes,
- certificateExactConvert, NULL, certificateExactMatch,
- certificateExactIndexer, certificateExactFilter,
- NULL},
-#endif
+ NULL, certificateExactNormalize, octetStringMatch,
+ octetStringIndexer, octetStringFilter,
+ NULL },
#endif
{"( 1.3.6.1.4.1.1466.109.114.1 NAME 'caseExactIA5Match' "
SLAP_MR_SUBSTR, NULL,
NULL, IA5StringNormalize, octetStringSubstringsMatch,
octetStringSubstringsIndexer, octetStringSubstringsFilter,
- NULL},
+ "caseIgnoreIA5Match" },
{"( 1.3.6.1.4.1.4203.1.2.1 NAME 'caseExactIA5SubstringsMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
SLAP_MR_SUBSTR, NULL,
NULL, IA5StringNormalize, octetStringSubstringsMatch,
octetStringSubstringsIndexer, octetStringSubstringsFilter,
- NULL},
+ "caseExactIA5Match" },
#ifdef SLAPD_AUTHPASSWD
/* needs updating */
SLAP_MR_EXT, NULL,
NULL, NULL, integerBitAndMatch,
NULL, NULL,
- NULL},
+ "integerMatch" },
{"( 1.2.840.113556.1.4.804 NAME 'integerBitOrMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
SLAP_MR_EXT, NULL,
NULL, NULL, integerBitOrMatch,
NULL, NULL,
- NULL},
+ "integerMatch" },
{NULL, SLAP_MR_NONE, NULL,
NULL, NULL, NULL, NULL, NULL,