/* end of preamble */
-#if !defined(SLAPD_SCHEMA_COMPAT) && !defined(SLAPD_SCHEMA_NOT_COMPAT)
- /* define SLAPD_SCHEMA_COMPAT if you want old schema codes */
-#define SLAPD_SCHEMA_NOT_COMPAT 1
-#endif
-
-
/* Define if on AIX 3.
System headers sometimes define this.
We just want to avoid a redefinition error message. */
/* end of preamble */
-#if !defined( SLAPD_SCHEMA_COMPAT ) && !defined( SLAPD_SCHEMA_NOT_COMPAT )
- /* use new schema codes */
-#define SLAPD_SCHEMA_NOT_COMPAT 1
-#endif
-
/* comment this out if you don't have Cyrus SASL */
#define HAVE_CYRUS_SASL 1
AccessControl *ac, int *count,
Backend *be, Operation *op,
Entry *e,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *desc,
-#else
- const char *desc,
-#endif
int nmatches, regmatch_t *matches );
static slap_control_t acl_mask(
AccessControl *ac, slap_access_mask_t *mask,
Backend *be, Connection *conn, Operation *op,
Entry *e,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *desc,
-#else
- const char *desc,
-#endif
struct berval *val,
regmatch_t *matches );
Backend *be,
Operation *op,
Entry *e,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *desc,
-#else
- const char *desc,
-#endif
struct berval *val,
struct berval *aci,
regmatch_t *matches,
Connection *conn,
Operation *op,
Entry *e,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *desc,
-#else
- const char *desc,
-#endif
struct berval *val,
slap_access_t access )
{
slap_access_mask_t mask;
slap_control_t control;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
const char *attr = desc ? desc->ad_cname->bv_val : NULL;
-#else
- const char *attr = desc;
-#endif
regmatch_t matches[MAXREMATCHES];
* by ACL_WRITE checking as any found here are not provided
* by the user
*/
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
if ( access >= ACL_WRITE && is_at_no_user_mod( desc->ad_type ) )
-#else
- if ( access >= ACL_WRITE && oc_check_op_no_usermod_attr( attr ) )
-#endif
{
Debug( LDAP_DEBUG_ACL, "NoUserMod Operational attribute:"
" %s access granted\n",
Backend *be,
Operation *op,
Entry *e,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *desc,
-#else
- const char *desc,
-#endif
int nmatch,
regmatch_t *matches )
{
assert( e != NULL );
assert( count != NULL );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
attr = desc ? desc->ad_cname->bv_val : NULL;
-#else
- attr = desc;
-#endif
if( a == NULL ) {
if( be == NULL ) {
Connection *conn,
Operation *op,
Entry *e,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *desc,
-#else
- const char *desc,
-#endif
struct berval *val,
regmatch_t *matches
)
#ifdef LDAP_DEBUG
char accessmaskbuf[ACCESSMASK_MAXLEN];
#endif
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
const char *attr = desc ? desc->ad_cname->bv_val : NULL;
-#else
- const char *attr = desc;
-#endif
assert( a != NULL );
assert( mask != NULL );
if ( b->a_dn_at != NULL && op->o_ndn != NULL ) {
Attribute *at;
struct berval bv;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
int match;
const char *text;
const char *desc = b->a_dn_at->ad_cname->bv_val;
-#else
- const char *desc = b->a_dn_at;
-#endif
Debug( LDAP_DEBUG_ACL, "<= check a_dn_at: %s\n",
b->a_dn_at, 0, 0);
bv.bv_len = strlen( bv.bv_val );
/* see if asker is listed in dnattr */
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
for( at = attrs_find( e->e_attrs, b->a_dn_at );
at == NULL;
at = attrs_find( e->e_attrs->a_next, b->a_dn_at ) )
{
continue;
}
-#else
- /* see if asker is listed in dnattr */
- if ( (at = attr_find( e->e_attrs, b->a_dn_at )) != NULL &&
- value_find( at->a_vals, &bv, at->a_syntax, 3 ) == 0 )
- {
- if ( b->a_dn_self && (val == NULL
- || value_cmp( &bv, val, at->a_syntax, 2 ) ) )
- {
- continue;
- }
-
- /* asker not listed in dnattr - check for self access */
- } else if ( ! b->a_dn_self || val == NULL
- || value_cmp( &bv, val, at->a_syntax, 2 ) != 0 )
- {
- continue;
- }
-#endif
}
if ( b->a_group_pat != NULL && op->o_ndn != NULL ) {
* by ACL_WRITE checking as any found here are not provided
* by the user
*/
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
if ( is_at_no_user_mod( mlist->sml_desc->ad_type ) ) {
Debug( LDAP_DEBUG_ACL, "acl: no-user-mod %s:"
" modify access granted\n",
mlist->sml_desc->ad_cname->bv_val, 0, 0 );
continue;
}
-#else
- if ( oc_check_op_no_usermod_attr( mlist->sml_type ) ) {
- Debug( LDAP_DEBUG_ACL, "acl: no-user-mod %s:"
- " modify access granted\n",
- mlist->sml_type, 0, 0 );
- continue;
- }
-#endif
switch ( mlist->sml_op ) {
case LDAP_MOD_REPLACE:
char *subjdn, *grpdn = NULL;
char *grpoc;
char *grpat;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
ObjectClass *grp_oc = NULL;
AttributeDescription *grp_ad = NULL;
char *text;
-#else
- char *grp_oc;
- char *grp_ad;
-#endif
int rc;
/* format of string is "group/objectClassValue/groupAttrName" */
grpat = aci_bvstrdup(&bv);
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
rc = slap_str2ad( grpat, &grp_ad, &text );
if( rc != LDAP_SUCCESS ) {
rc = 0;
goto done;
}
-#else
- grp_ad = grpat;
-#endif
rc = 0;
grpdn = (char *)ch_malloc(1024);
}
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
done:
if( grp_ad != NULL ) ad_free( grp_ad, 1 );
-#endif
ch_free(grpdn);
ch_free(grpat);
ch_free(grpoc);
Backend *be,
Operation *op,
Entry *e,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *desc,
-#else
- const char *attr,
-#endif
struct berval *val,
struct berval *aci,
regmatch_t *matches,
struct berval bv, perms, sdn;
char *subjdn;
int rc, i;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
char *attr;
-#endif
/* parse an aci of the form:
oid#scope#action;rights;attr;rights;attr$action;rights;attr;rights;attr#dnType#subjectDN
} else if (aci_strbvcmp( "dnattr", &bv ) == 0) {
char *dnattr = aci_bvstrdup(&sdn);
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
Attribute *at;
AttributeDescription *ad = NULL;
const char *text;
ad_free( ad, 1 );
return rc;
-#else
- Attribute *at;
- at = attr_find( e->e_attrs, dnattr );
- ch_free( dnattr );
-
- if (at != NULL) {
- bv.bv_val = op->o_ndn;
- bv.bv_len = strlen( bv.bv_val );
-
- if (value_find( at->a_vals, &bv, at->a_syntax, 3 ) == 0 )
- return(1);
- }
-#endif
} else if (aci_strbvcmp( "group", &bv ) == 0) {
if (aci_group_member(&sdn, SLAPD_GROUP_CLASS, SLAPD_GROUP_ATTR, be, e, op, matches))
char *left, *right;
AccessControl *a;
Access *b;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
int rc;
const char *text;
-#endif
a = NULL;
for ( i = 1; i < argc; i++ ) {
acl_usage();
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
rc = slap_str2ad( right, &b->a_dn_at, &text );
if( rc != LDAP_SUCCESS ) {
acl_usage();
}
-#else
- b->a_dn_at = ch_strdup( right );
-#endif
continue;
}
b->a_group_pat = ch_strdup( right );
if (value && *value) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
b->a_group_oc = oc_find( value );
-#else
- b->a_group_oc = ch_strdup(value);
-#endif
*--value = '/';
if( b->a_group_oc == NULL ) {
acl_usage();
}
} else {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
b->a_group_oc = oc_find(SLAPD_GROUP_CLASS);
if( b->a_group_oc == NULL ) {
fname, lineno, SLAPD_GROUP_CLASS );
acl_usage();
}
-#else
- b->a_group_oc = ch_strdup(SLAPD_GROUP_CLASS);
-#endif
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
#if 0
if( is_object_subclass( b->a_group_oc,
slap_schema.si_oc_referral ) )
fname, lineno, value );
acl_usage();
}
-#endif
#endif
if (name && *name) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
rc = slap_str2ad( right, &b->a_group_at, &text );
if( rc != LDAP_SUCCESS ) {
fname, lineno, right, text );
acl_usage();
}
-#else
- b->a_group_at = ch_strdup(name);
-#endif
*--name = '/';
} else {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
rc = slap_str2ad( SLAPD_GROUP_ATTR, &b->a_group_at, &text );
if( rc != LDAP_SUCCESS ) {
fname, lineno, SLAPD_GROUP_ATTR, text );
acl_usage();
}
-#else
- b->a_group_at = ch_strdup( SLAPD_GROUP_ATTR );
-#endif
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
if( !is_at_syntax( b->a_group_at->ad_type,
SLAPD_DN_SYNTAX ) )
{
acl_usage();
}
}
-#endif
continue;
}
acl_usage();
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
if ( right != NULL && *right != '\0' ) {
rc = slap_str2ad( right, &b->a_aci_at, &text );
acl_usage();
}
-#else
- if ( right != NULL && *right != '\0' ) {
- b->a_aci_at = ch_strdup( right );
- } else {
- b->a_aci_at = ch_strdup( SLAPD_ACI_ATTR );
- }
-#endif
continue;
}
#endif /* SLAPD_ACI_ENABLED */
}
if ( b->a_dn_at != NULL ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
fprintf( stderr, " dnattr=%s", b->a_dn_at->ad_cname->bv_val );
-#else
- fprintf( stderr, " dnattr=%s", b->a_dn_at );
-#endif
}
if ( b->a_group_pat != NULL ) {
fprintf( stderr, " objectClass: %s", b->a_group_oc );
if ( b->a_group_at ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
fprintf( stderr, " attributeType: %s", b->a_group_at->ad_cname->bv_val );
-#else
- fprintf( stderr, " attributeType: %s", b->a_group_at );
-#endif
}
}
}
#ifdef SLAPD_ACI_ENABLED
if ( b->a_aci_at != NULL ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
fprintf( stderr, " aci=%s", b->a_aci_at->ad_cname->bv_val );
-#else
- fprintf( stderr, " aci=%s", b->a_aci_at );
-#endif
}
#endif
#include "ldap_pvt.h"
#include "slap.h"
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *ad_dup(
AttributeDescription *desc )
{
return 0;
}
-#endif
#include "ldap_pvt.h"
#include "slap.h"
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
static int slap_mods2entry(
Modifications *mods,
Entry **e,
const char **text );
-#else
-static int add_created_attrs(Operation *op, Entry *e);
-#endif
int
do_add( Connection *conn, Operation *op )
ber_tag_t tag;
Entry *e;
Backend *be;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
LDAPModList *modlist = NULL;
LDAPModList **modtail = &modlist;
Modifications *mods = NULL;
-#endif
const char *text;
int rc = LDAP_SUCCESS;
for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT;
tag = ber_next_element( ber, &len, last ) )
{
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
LDAPModList *mod = (LDAPModList *) ch_malloc( sizeof(LDAPModList) );
-#else
- LDAPModList tmpmod;
- LDAPModList *mod = &tmpmod;
-#endif
mod->ml_op = LDAP_MOD_ADD;
mod->ml_next = NULL;
send_ldap_disconnect( conn, op,
LDAP_PROTOCOL_ERROR, "decoding error" );
rc = -1;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
free( mod );
-#endif
goto done;
}
send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR,
NULL, "no values for attribute type", NULL, NULL );
free( mod->ml_type );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
free( mod );
-#endif
goto done;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
*modtail = mod;
modtail = &mod->ml_next;
-#else
- attr_merge( e, mod->ml_type, mod->ml_bvalues );
-
- free( mod->ml_type );
- ber_bvecfree( mod->ml_bvalues );
-#endif
}
if ( ber_scanf( ber, /*{*/ "}") == LBER_ERROR ) {
goto done;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
if ( modlist == NULL )
-#else
- if ( e->e_attrs == NULL )
-#endif
{
send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR,
NULL, "no attributes provided", NULL, NULL );
{
int update = be->be_update_ndn != NULL;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
rc = slap_modlist2mods( modlist, update, &mods, &text );
if( rc != LDAP_SUCCESS ) {
send_ldap_result( conn, op, rc,
goto done;
}
-#endif
#ifndef SLAPD_MULTIMASTER
if ( (be->be_lastmod == ON || (be->be_lastmod == UNDEFINED &&
global_lastmod == ON)) && !update )
#endif
{
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
Modifications **modstail;
for( modstail = &mods;
*modstail != NULL;
assert( (*modstail)->sml_desc != NULL );
}
rc = slap_mods_opattrs( op, modstail, &text );
-#else
- char *text = "no-user-modification attribute type";
- rc = add_created_attrs( op, e );
-#endif
if( rc != LDAP_SUCCESS ) {
send_ldap_result( conn, op, rc,
NULL, text, NULL, NULL );
}
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
rc = slap_mods2entry( mods, &e, &text );
if( rc != LDAP_SUCCESS ) {
send_ldap_result( conn, op, rc,
NULL, text, NULL, NULL );
goto done;
}
-#endif
if ( (*be->be_add)( be, conn, op, e ) == 0 ) {
#ifdef SLAPD_MULTIMASTER
}
done:
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
if( modlist != NULL ) {
slap_modlist_free( modlist );
}
if( mods != NULL ) {
slap_mods_free( mods );
}
-#endif
if( e != NULL ) {
entry_free( e );
}
return rc;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
static int slap_mods2entry(
Modifications *mods,
Entry **e,
return LDAP_SUCCESS;
}
-#else
-static int
-add_created_attrs( Operation *op, Entry *e )
-{
- char buf[22];
- struct berval bv;
- struct berval *bvals[2];
- Attribute *a;
- struct tm *ltm;
- time_t currenttime;
-
- Debug( LDAP_DEBUG_TRACE, "add_created_attrs\n", 0, 0, 0 );
-
- bvals[0] = &bv;
- bvals[1] = NULL;
-
- /* return error on any attempts by the user to add these attrs */
- for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
- if ( oc_check_op_no_usermod_attr( a->a_type ) ) {
- return LDAP_CONSTRAINT_VIOLATION;
- }
- }
-
- if ( op->o_dn == NULL || op->o_dn[0] == '\0' ) {
- bv.bv_val = SLAPD_ANONYMOUS;
- bv.bv_len = sizeof(SLAPD_ANONYMOUS)-1;
-;
- } else {
- bv.bv_val = op->o_dn;
- bv.bv_len = strlen( bv.bv_val );
- }
- attr_merge( e, "creatorsname", bvals );
- attr_merge( e, "modifiersname", bvals );
-
- currenttime = slap_get_time();
- ldap_pvt_thread_mutex_lock( &gmtime_mutex );
- ltm = gmtime( ¤ttime );
- strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm );
- ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
-
- bv.bv_val = buf;
- bv.bv_len = strlen( bv.bv_val );
- attr_merge( e, "createtimestamp", bvals );
- attr_merge( e, "modifytimestamp", bvals );
-
- return LDAP_SUCCESS;
-}
-#endif
#include "ldap_pvt.h"
#include "slap.h"
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
-char *
-at_canonical_name( const char * a_type )
-{
- AttributeType *atp;
-
- atp=at_find(a_type);
-
- if ( atp == NULL ) {
- return (char *) a_type;
-
- } else if ( atp->sat_names
- && atp->sat_names[0] && (*(atp->sat_names[0]) != '\0') )
- {
- return atp->sat_names[0];
-
- } else if (atp->sat_oid && (*atp->sat_oid != '\0')) {
- return atp->sat_oid;
- }
-
- return (char *) a_type;
-}
-
-#define DEFAULT_SYNTAX SYNTAX_CIS
-
-/*
- * attr_syntax - return the syntax of attribute type
- */
-
-int
-attr_syntax( const char *type )
-{
- AttributeType *sat;
-
- sat = at_find(type);
- if ( sat ) {
- return( sat->sat_syntax_compat );
- }
-
- return( DEFAULT_SYNTAX );
-}
-
-/*
- * attr_syntax_config - process an attribute syntax config line
- */
-
-void
-at_config(
- const char *fname,
- int lineno,
- int argc,
- char **argv
-)
-{
- char *save;
- LDAP_ATTRIBUTE_TYPE *at;
- int lasti;
- int code;
- const char *err;
-
- if ( argc < 2 ) {
- Debug( LDAP_DEBUG_ANY,
-"%s: line %d: missing name in \"attribute <name>+ <syntax>\" (ignored)\n",
- fname, lineno, 0 );
- return;
- }
-
- at = (LDAP_ATTRIBUTE_TYPE *)
- ch_calloc( 1, sizeof(LDAP_ATTRIBUTE_TYPE) );
-
-#define SYNTAX_DS_OID "1.3.6.1.4.1.1466.115.121.1.15"
-#define SYNTAX_DSCE_OID "2.5.13.5"
-#define SYNTAX_IA5_OID "1.3.6.1.4.1.1466.115.121.1.26"
-#define SYNTAX_IA5CE_OID "1.3.6.1.4.1.1466.109.114.1"
-#define SYNTAX_DN_OID "1.3.6.1.4.1.1466.115.121.1.12"
-#define SYNTAX_TEL_OID "1.3.6.1.4.1.1466.115.121.1.50"
-#define SYNTAX_BIN_OID "1.3.6.1.4.1.1466.115.121.1.40" /* octetString */
-
- lasti = argc - 1;
- if ( strcasecmp( argv[lasti], "caseignorestring" ) == 0 ||
- strcasecmp( argv[lasti], "cis" ) == 0 ) {
- at->at_syntax_oid = SYNTAX_DS_OID;
- at->at_equality_oid = "2.5.13.2";
- at->at_ordering_oid = "2.5.13.3";
- at->at_substr_oid = "2.5.13.4";
-
- } else if ( strcasecmp( argv[lasti], "telephone" ) == 0 ||
- strcasecmp( argv[lasti], "tel" ) == 0 ) {
- at->at_syntax_oid = SYNTAX_TEL_OID;
- at->at_equality_oid = "2.5.13.20";
- at->at_substr_oid = "2.5.13.21";
-
- } else if ( strcasecmp( argv[lasti], "dn" ) == 0 ) {
- at->at_syntax_oid = SYNTAX_DN_OID;
- at->at_equality_oid = "2.5.13.1";
-
- } else if ( strcasecmp( argv[lasti], "caseexactstring" ) == 0 ||
- strcasecmp( argv[lasti], "ces" ) == 0 ) {
- at->at_syntax_oid = SYNTAX_DS_OID;
- at->at_equality_oid = SYNTAX_DSCE_OID;
- at->at_ordering_oid = "2.5.13.6";
- at->at_substr_oid = "2.5.13.7";
-
- } else if ( strcasecmp( argv[lasti], "binary" ) == 0 ||
- strcasecmp( argv[lasti], "bin" ) == 0 ) {
- /* bin -> octetString, not binary! */
- at->at_syntax_oid = SYNTAX_BIN_OID;
- at->at_equality_oid = "2.5.13.17";
-
- } else {
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: unknown syntax \"%s\" in attribute line (ignored)\n",
- fname, lineno, argv[lasti] );
- Debug( LDAP_DEBUG_ANY,
- "possible syntaxes are \"cis\", \"ces\", \"tel\", \"dn\", or \"bin\"\n",
- 0, 0, 0 );
- free( (AttributeType *) at );
- return;
- }
-
- save = argv[lasti];
- argv[lasti] = NULL;
- at->at_names = charray_dup( argv );
- argv[lasti] = save;
-
- code = at_add( at, &err );
- if ( code ) {
- fprintf( stderr, "%s: line %d: %s %s\n",
- fname, lineno, scherr2str(code), err);
- exit( EXIT_FAILURE );
- }
-
- ldap_memfree(at);
-}
-
-int
-at_fake_if_needed(
- const char *name
-)
-{
- char *argv[3];
-
- if ( at_find( name ) ) {
- return 0;
- } else {
- argv[0] = (char*) name;
- argv[1] = "cis";
- argv[2] = NULL;
- at_config( "implicit", 0, 2, argv );
- return 0;
- }
-}
-
-#endif
int is_at_syntax(
AttributeType *at,
struct aindexrec *air;
char *tmpname;
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- /*
- * The name may actually be an AttributeDescription, i.e. it may
- * contain options.
- */
- /* Treat any attribute type with option as an unknown attribute type */
- char *p = strchr( name, ';' );
- if ( p ) {
- tmpname = ch_malloc( p-name+1 );
- strncpy( tmpname, name, p-name );
- tmpname[p-name] = '\0';
- } else
-#endif
{
tmpname = (char *)name;
}
sat = (AttributeType *) ch_calloc( 1, sizeof(AttributeType) );
memcpy( &sat->sat_atype, at, sizeof(LDAP_ATTRIBUTE_TYPE));
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
sat->sat_cname = cname;
-#endif
if ( at->at_sup_oid ) {
AttributeType *supsat = at_find(at->at_sup_oid);
*/
if ( sat->sat_sup ) {
sat->sat_syntax = sat->sat_sup->sat_syntax;
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- sat->sat_syntax_compat = sat->sat_sup->sat_syntax_compat;
-#endif
sat->sat_equality = sat->sat_sup->sat_equality;
sat->sat_ordering = sat->sat_sup->sat_ordering;
sat->sat_substr = sat->sat_sup->sat_substr;
return SLAP_SCHERR_SYN_NOT_FOUND;
}
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- if ( !strcmp(at->at_syntax_oid, SYNTAX_DS_OID) ) {
- if ( at->at_equality_oid && (
- !strcmp(at->at_equality_oid, SYNTAX_DSCE_OID) ) )
- {
- sat->sat_syntax_compat = SYNTAX_CES;
- } else {
- sat->sat_syntax_compat = SYNTAX_CIS;
- }
-
- } else if ( !strcmp(at->at_syntax_oid, SYNTAX_IA5_OID) ) {
- if ( at->at_equality_oid && (
- !strcmp(at->at_equality_oid, SYNTAX_IA5CE_OID) ) )
- {
- sat->sat_syntax_compat = SYNTAX_CES;
- } else {
- sat->sat_syntax_compat = SYNTAX_CIS;
- }
-
- } else if ( !strcmp(at->at_syntax_oid, SYNTAX_DN_OID ) ) {
- sat->sat_syntax_compat = SYNTAX_CIS | SYNTAX_DN;
-
- } else if ( !strcmp(at->at_syntax_oid, SYNTAX_TEL_OID ) ) {
- sat->sat_syntax_compat = SYNTAX_CIS | SYNTAX_TEL;
-
- } else if ( !strcmp(at->at_syntax_oid, SYNTAX_BIN_OID ) ) {
- sat->sat_syntax_compat = SYNTAX_BIN;
-
- } else {
- sat->sat_syntax_compat = DEFAULT_SYNTAX;
- }
-#endif
} else if ( sat->sat_syntax == NULL ) {
return SLAP_SCHERR_ATTR_INCOMPLETE;
struct berval *vals[2];
AttributeType *at;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *ad_attributeTypes = slap_schema.si_ad_attributeTypes;
-#else
- char *ad_attributeTypes = "attributeTypes";
-#endif
vals[0] = &val;
vals[1] = NULL;
void
attr_free( Attribute *a )
{
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
ad_free( a->a_desc, 1 );
-#else
- free( a->a_type );
-#endif
ber_bvecfree( a->a_vals );
free( a );
}
tmp->a_vals = NULL;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
tmp->a_desc = ad_dup( a->a_desc );
-#else
- tmp->a_type = ch_strdup( a->a_type );
- tmp->a_syntax = a->a_syntax;
-#endif
tmp->a_next = NULL;
return tmp;
return tmp;
}
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
-/*
- * attr_normalize - normalize an attribute name (make it all lowercase)
- */
-
-char *
-attr_normalize( char *s )
-{
- assert( s != NULL );
-
- return( ldap_pvt_str2lower( s ) );
-}
-
-/*
- * attr_merge_fast - merge the given type and value with the list of
- * attributes in attrs. called from str2entry(), where we can make some
- * assumptions to make things faster.
- * returns 0 everything went ok
- * -1 trouble
- */
-
-int
-attr_merge_fast(
- Entry *e,
- const char *type,
- struct berval **vals,
- int nvals,
- int naddvals,
- int *maxvals,
- Attribute ***a
-)
-{
- if ( *a == NULL ) {
- for ( *a = &e->e_attrs; **a != NULL; *a = &(**a)->a_next ) {
- if ( strcasecmp( (**a)->a_type, type ) == 0 ) {
- break;
- }
- }
- }
-
- if ( **a == NULL ) {
- **a = (Attribute *) ch_malloc( sizeof(Attribute) );
- (**a)->a_vals = NULL;
- (**a)->a_type = attr_normalize( ch_strdup( type ) );
- (**a)->a_syntax = attr_syntax( type );
- (**a)->a_next = NULL;
- }
-
- return( value_add_fast( &(**a)->a_vals, vals, nvals, naddvals,
- maxvals ) );
-}
-#endif
/*
int
attr_merge(
Entry *e,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *desc,
-#else
- const char *type,
-#endif
struct berval **vals )
{
Attribute **a;
for ( a = &e->e_attrs; *a != NULL; a = &(*a)->a_next ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
if ( ad_cmp( (*a)->a_desc, desc ) == 0 )
-#else
- if ( strcasecmp( (*a)->a_type, type ) == 0 )
-#endif
{
break;
}
if ( *a == NULL ) {
*a = (Attribute *) ch_malloc( sizeof(Attribute) );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
(*a)->a_desc = ad_dup( desc );
-#else
- (*a)->a_type = attr_normalize( ch_strdup( type ) );
- (*a)->a_syntax = attr_syntax( type );
-#endif
(*a)->a_vals = NULL;
(*a)->a_next = NULL;
}
return( value_add( &(*a)->a_vals, vals ) );
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
/*
* attrs_find - find attribute(s) by AttributeDescription
* returns next attribute which is subtype of provided description.
return( NULL );
}
-#endif
/*
* attr_find - find attribute by type
Attribute *
attr_find(
Attribute *a,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *desc
-#else
- const char *type
-#endif
)
{
for ( ; a != NULL; a = a->a_next ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
if ( ad_cmp( a->a_desc, desc ) == 0 )
-#else
- if ( strcasecmp( a->a_type, type ) == 0 )
-#endif
{
return( a );
}
int
attr_delete(
Attribute **attrs,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *desc
-#else
- const char *type
-#endif
)
{
Attribute **a;
for ( a = attrs; *a != NULL; a = &(*a)->a_next ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
if ( ad_cmp( (*a)->a_desc, desc ) == 0 )
-#else
- if ( strcasecmp( (*a)->a_type, type ) == 0 )
-#endif
{
Attribute *save = *a;
*a = (*a)->a_next;
#include "slap.h"
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
void
ava_free(
return LDAP_SUCCESS;
}
-#else
-
-void
-ava_free(
- Ava *ava,
- int freeit
-)
-{
- ch_free( (char *) ava->ava_type );
- ch_free( (char *) ava->ava_value.bv_val );
- if ( freeit ) {
- ch_free( (char *) ava );
- }
-}
-
-int
-get_ava(
- BerElement *ber,
- Ava *ava,
- const char **text
-)
-{
- if ( ber_scanf( ber, "{ao}", &ava->ava_type, &ava->ava_value )
- == LBER_ERROR ) {
- Debug( LDAP_DEBUG_ANY, " get_ava ber_scanf\n", 0, 0, 0 );
- *text = "Error decoding attribute value assertion";
- return SLAPD_DISCONNECT;
- }
-
- attr_normalize( ava->ava_type );
- value_normalize( ava->ava_value.bv_val, attr_syntax( ava->ava_type ) );
-
- return LDAP_SUCCESS;
-}
-
-#endif
Operation *op,
const char *dn,
const char *ndn,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeAssertion *ava
-#else
- Ava *ava
-#endif
)
{
return dnssrv_back_request( be, conn, op, dn, ndn,
Filter *filter, const char *filterstr,
char **attrs, int attrsonly ));
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
extern int dnssrv_back_compare LDAP_P((BackendDB *bd,
Connection *conn, Operation *op,
const char *dn, const char *ndn, AttributeAssertion *ava ));
-#else
-extern int dnssrv_back_compare LDAP_P((BackendDB *bd,
- Connection *conn, Operation *op,
- const char *dn, const char *ndn, Ava *ava ));
-#endif
extern int dnssrv_back_modify LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
struct berval val;
struct berval *vals[2];
Entry *e = ch_calloc( 1, sizeof(Entry) );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *ad_objectClass
= slap_schema.si_ad_objectClass;
AttributeDescription *ad_ref = slap_schema.si_ad_ref;
-#else
- const char ad_objectClass = "objectClass";
- const char ad_ref = "ref";
-#endif
e->e_dn = strdup( dn );
e->e_ndn = strdup( ndn );
attr_merge( e, ad_objectClass, vals );
{
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *ad = NULL;
const char *text;
rc = slap_str2ad( "dc", &ad, &text );
-#else
- rc = LDAP_SUCCESS;
- const char *ad = "dc";
-#endif
if( rc == LDAP_SUCCESS ) {
char *p;
}
{
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *ad = NULL;
const char *text;
rc = slap_str2ad( "associatedDomain", &ad, &text );
-#else
- rc = LDAP_SUCCESS;
- const char *ad = "associatedDomain";
-#endif
if( rc == LDAP_SUCCESS ) {
val.bv_val = domain;
for (i=0, a=e->e_attrs; a; i++, a=a->a_next) {
attrs[i] = (LDAPMod *)ch_malloc(sizeof(LDAPMod));
attrs[i]->mod_op = LDAP_MOD_BVALUES;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
attrs[i]->mod_type = a->a_desc->ad_cname->bv_val;
-#else
- attrs[i]->mod_type = a->a_type;
-#endif
attrs[i]->mod_vals.modv_bvals = a->a_vals;
}
Operation *op,
const char *dn,
const char *ndn,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeAssertion *ava
-#else
- Ava *ava
-#endif
)
{
struct ldapinfo *li = (struct ldapinfo *) be->be_private;
return( -1 );
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
ldap_compare_s( lc->ld, dn, ava->aa_desc->ad_cname->bv_val, ava->aa_value->bv_val );
-#else
- ldap_compare_s( lc->ld, dn, ava->ava_type, ava->ava_value.bv_val );
-#endif
return( ldap_back_op_result( lc, op ) );
}
Filter *filter, const char *filterstr,
char **attrs, int attrsonly ));
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
extern int ldap_back_compare LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
const char *dn, const char *ndn,
AttributeAssertion *ava ));
-#else
-extern int ldap_back_compare LDAP_P((BackendDB *bd,
- Connection *conn, Operation *op,
- const char *dn, const char *ndn,
- Ava *ava ));
-#endif
extern int ldap_back_modify LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
extern int ldap_back_abandon LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op, int msgid ));
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
extern int ldap_back_group LDAP_P(( BackendDB *bd,
Entry *target,
const char* gr_ndn,
const char* op_ndn,
ObjectClass* group_oc,
AttributeDescription* group_at));
-#else
-extern int ldap_back_group LDAP_P(( BackendDB *bd,
- Entry *target,
- const char* gr_ndn, const char* op_ndn,
- const char* group_oc,
- const char* group_at));
-#endif
LDAP_END_DECL
BerElement *ber = NULL;
Attribute *attr, **attrp;
struct berval *dummy = NULL;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
char *text;
-#endif
ent.e_dn = ldap_get_dn(lc->ld, e);
ent.e_ndn = ch_strdup( ent.e_dn);
if (attr == NULL)
continue;
attr->a_next = 0;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
slap_str2ad(a, &attr->a_desc, &text);
-#else
- attr->a_type = ch_strdup(a);
- attr->a_syntax = attr_syntax(a);
-#endif
attr->a_vals = ldap_get_values_len(lc->ld, e, a);
if (!attr->a_vals)
attr->a_vals = &dummy;
for (;ent.e_attrs;) {
attr=ent.e_attrs;
ent.e_attrs = attr->a_next;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
ad_free(attr->a_desc, 1);
-#else
- free(attr->a_type);
-#endif
if (attr->a_vals != &dummy)
ber_bvecfree(attr->a_vals);
free(attr);
int rootlock = 0;
int rc;
const char *text = NULL;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *children = slap_schema.si_ad_children;
-#else
- static const char *children = "children";
-#endif
Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_add: %s\n", e->e_dn, 0, 0);
const char **errmsg )
{
Attribute *a;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *aliasedObjectName = slap_schema.si_ad_aliasedObjectName;
-#else
- static const char *aliasedObjectName = "aliasedObjectName";
-#endif
a = attr_find( e->e_attrs, aliasedObjectName );
for ( i = 0; attrs[i] != NULL; i++ ) {
AttrInfo *a;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *ad;
const char *text;
-#endif
if( strcasecmp( attrs[i], "default" ) == 0 ) {
li->li_defaultmask = mask;
a = (AttrInfo *) ch_malloc( sizeof(AttrInfo) );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
ad = NULL;
rc = slap_str2ad( attrs[i], &ad, &text );
a->ai_desc = ch_strdup( ad->ad_cname->bv_val );
ad_free( ad, 1 );
#endif
-#else
- a->ai_desc = ch_strdup( attrs[i] );
-#endif
a->ai_indexmask = mask;
AUTH_DAT ad;
#endif
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *password = slap_schema.si_ad_userPassword;
AttributeDescription *entry = slap_schema.si_ad_entry;
-#else
- static const char *password = "userpassword";
- static const char *entry = "entry";
-#endif
Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_bind: dn: %s\n", dn, 0, 0);
Operation *op,
const char *dn,
const char *ndn,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeAssertion *ava
-#else
- Ava *ava
-#endif
)
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
goto return_results;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
if ( ! access_allowed( be, conn, op, e,
ava->aa_desc, ava->aa_value, ACL_COMPARE ) )
-#else
- if ( ! access_allowed( be, conn, op, e,
- ava->ava_type, &ava->ava_value, ACL_COMPARE ) )
-#endif
{
send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
NULL, NULL, NULL, NULL );
rc = LDAP_NO_SUCH_ATTRIBUTE;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
for(a = attrs_find( e->e_attrs, ava->aa_desc );
a != NULL;
a = attrs_find( a->a_next, ava->aa_desc ))
-#else
- if ((a = attr_find( e->e_attrs, ava->ava_type )) != NULL )
-#endif
{
rc = LDAP_COMPARE_FALSE;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
if ( value_find( ava->aa_desc, a->a_vals, ava->aa_value ) == 0 )
-#else
- if ( value_find( a->a_vals, &ava->ava_value, a->a_syntax, 1 ) == 0 )
-#endif
{
rc = LDAP_COMPARE_TRUE;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
break;
-#endif
}
}
int rootlock = 0;
int rc = -1;
int manageDSAit = get_manageDSAit( op );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *children = slap_schema.si_ad_children;
-#else
- static const char *children = "children";
-#endif
Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_delete: %s\n", dn, 0, 0);
Filter *filter, const char *filterstr,
char **attrs, int attrsonly ));
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
extern int ldbm_back_compare LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
const char *dn, const char *ndn,
AttributeAssertion *ava ));
-#else
-extern int ldbm_back_compare LDAP_P((BackendDB *bd,
- Connection *conn, Operation *op,
- const char *dn, const char *ndn,
- Ava *ava ));
-#endif
extern int ldbm_back_modify LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
extern int ldbm_back_abandon LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op, ber_int_t msgid ));
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
extern int ldbm_back_group LDAP_P(( BackendDB *bd,
Entry *target,
const char* gr_ndn,
const char* op_ndn,
ObjectClass* group_oc,
AttributeDescription* group_at));
-#else
-extern int ldbm_back_group LDAP_P(( BackendDB *bd,
- Entry *target,
- const char* gr_ndn, const char* op_ndn,
- const char* group_oc,
- const char* group_at));
-#endif
/* hooks for slap tools */
extern Entry* ldbm_tool_entry_get LDAP_P(( BackendDB *be, ID id ));
extern ID ldbm_tool_entry_put LDAP_P(( BackendDB *be, Entry *e ));
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
extern int ldbm_tool_index_attr LDAP_P(( BackendDB *be,
AttributeDescription* desc ));
extern int ldbm_tool_index_change LDAP_P(( BackendDB *be,
AttributeDescription* desc,
struct berval **bv, ID id, int op ));
-#else
-extern int ldbm_tool_index_attr LDAP_P(( BackendDB *be,
- char* type ));
-extern int ldbm_tool_index_change LDAP_P(( BackendDB *be,
- char* type,
- struct berval **bv, ID id, int op ));
-#endif
extern int ldbm_tool_sync LDAP_P(( BackendDB *be ));
#include "slap.h"
#include "back-ldbm.h"
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
static ID_BLOCK *presence_candidates(
Backend *be,
AttributeDescription *desc );
Backend *be,
Filter *flist,
int ftype );
-#else
-static ID_BLOCK *presence_candidates( Backend *be, char *type );
-static ID_BLOCK *equality_candidates( Backend *be, Ava *ava );
-static ID_BLOCK *approx_candidates( Backend *be, Ava *ava );
-static ID_BLOCK *list_candidates( Backend *be, Filter *flist, int ftype );
-static ID_BLOCK *substring_candidates( Backend *be, Filter *f );
-static ID_BLOCK *substring_comp_candidates( Backend *be, char *type,
- struct berval *val, int prepost );
-#endif
ID_BLOCK *
filter_candidates(
case LDAP_FILTER_EQUALITY:
Debug( LDAP_DEBUG_FILTER, "\tEQUALITY\n", 0, 0, 0 );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
result = equality_candidates( be, f->f_ava );
-#else
- result = equality_candidates( be, &f->f_ava );
-#endif
break;
case LDAP_FILTER_APPROX:
Debug( LDAP_DEBUG_FILTER, "\tAPPROX\n", 0, 0, 0 );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
result = approx_candidates( be, f->f_ava );
-#else
- result = approx_candidates( be, &f->f_ava );
-#endif
break;
case LDAP_FILTER_SUBSTRINGS:
static ID_BLOCK *
presence_candidates(
Backend *be,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *desc
-#else
- char *desc
-#endif
)
{
ID_BLOCK *idl;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
DBCache *db;
int rc;
char *dbname;
slap_index mask;
struct berval *prefix;
-#endif
Debug( LDAP_DEBUG_TRACE, "=> presence_candidates\n", 0, 0, 0 );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
idl = idl_allids( be );
rc = index_param( be, desc, LDAP_FILTER_PRESENT,
ldbm_cache_close( be, db );
-#else
- idl = index_read( be, desc, SLAP_INDEX_PRESENT, NULL );
-#endif
Debug( LDAP_DEBUG_TRACE, "<= presence_candidates %ld\n",
idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
static ID_BLOCK *
equality_candidates(
Backend *be,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeAssertion *ava
-#else
- Ava *ava
-#endif
)
{
ID_BLOCK *idl;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
DBCache *db;
int i;
int rc;
struct berval *prefix;
struct berval **keys = NULL;
MatchingRule *mr;
-#endif
Debug( LDAP_DEBUG_TRACE, "=> equality_candidates\n", 0, 0, 0 );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
idl = idl_allids( be );
rc = index_param( be, ava->aa_desc, LDAP_FILTER_EQUALITY,
ldbm_cache_close( be, db );
-#else
- idl = index_read( be, ava->ava_type, SLAP_INDEX_EQUALITY,
- ava->ava_value.bv_val );
-#endif
Debug( LDAP_DEBUG_TRACE, "<= equality_candidates %ld\n",
idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
static ID_BLOCK *
approx_candidates(
Backend *be,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeAssertion *ava
-#else
- Ava *ava
-#endif
)
{
ID_BLOCK *idl;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
DBCache *db;
int i;
int rc;
struct berval *prefix;
struct berval **keys = NULL;
MatchingRule *mr;
-#else
- char *w, *c;
- ID_BLOCK *tmp;
-#endif
Debug( LDAP_DEBUG_TRACE, "=> approx_candidates\n", 0, 0, 0 );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
idl = idl_allids( be );
rc = index_param( be, ava->aa_desc, LDAP_FILTER_EQUALITY,
ldbm_cache_close( be, db );
-#else
- idl = NULL;
- for ( w = first_word( ava->ava_value.bv_val );
- w != NULL;
- w = next_word( w ) )
- {
- c = phonetic( w );
- if ( (tmp = index_read( be, ava->ava_type, SLAP_INDEX_APPROX, c ))
- == NULL ) {
- free( c );
- idl_free( idl );
- Debug( LDAP_DEBUG_TRACE, "<= approx_candidates NULL\n",
- 0, 0, 0 );
- return( NULL );
- }
- free( c );
-
- if ( idl == NULL ) {
- idl = tmp;
- } else {
- idl = idl_intersection( be, idl, tmp );
- }
- }
-
-#endif
Debug( LDAP_DEBUG_TRACE, "<= approx_candidates %ld\n",
idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
return( idl );
)
{
ID_BLOCK *idl;
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- int i;
- ID_BLOCK *tmp, *tmp2;
-#endif
Debug( LDAP_DEBUG_TRACE, "=> substring_candidates\n", 0, 0, 0 );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
idl = idl_allids( be );
-#else
- idl = NULL;
-
- /* initial */
- if ( f->f_sub_initial != NULL ) {
- if ( f->f_sub_initial->bv_len < SUBLEN - 1 ) {
- idl = idl_allids( be );
- } else if ( (idl = substring_comp_candidates( be, f->f_sub_type,
- f->f_sub_initial, '^' )) == NULL ) {
- return( NULL );
- }
- }
-
- /* final */
- if ( f->f_sub_final != NULL ) {
- if ( f->f_sub_final->bv_len < SUBLEN - 1 ) {
- tmp = idl_allids( be );
- } else if ( (tmp = substring_comp_candidates( be, f->f_sub_type,
- f->f_sub_final, '$' )) == NULL ) {
- idl_free( idl );
- return( NULL );
- }
-
- if ( idl == NULL ) {
- idl = tmp;
- } else {
- tmp2 = idl;
- idl = idl_intersection( be, idl, tmp );
- idl_free( tmp );
- idl_free( tmp2 );
- }
- }
-
- if( f->f_sub_any != NULL ) {
- for ( i = 0; f->f_sub_any[i] != NULL; i++ ) {
- if ( f->f_sub_any[i]->bv_len < SUBLEN ) {
- tmp = idl_allids( be );
- } else if ( (tmp = substring_comp_candidates( be, f->f_sub_type,
- f->f_sub_any[i], 0 )) == NULL ) {
- idl_free( idl );
- return( NULL );
- }
-
- if ( idl == NULL ) {
- idl = tmp;
- } else {
- tmp2 = idl;
- idl = idl_intersection( be, idl, tmp );
- idl_free( tmp );
- idl_free( tmp2 );
- }
- }
- }
-#endif
Debug( LDAP_DEBUG_TRACE, "<= substring_candidates %ld\n",
idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
return( idl );
}
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
-static ID_BLOCK *
-substring_comp_candidates(
- Backend *be,
- char *type,
- struct berval *bv,
- int prepost
-)
-{
- int i, len;
- ID_BLOCK *idl, *tmp, *tmp2;
- char *p;
- char buf[SUBLEN + 1];
- char *val;
-
- Debug( LDAP_DEBUG_TRACE, "=> substring_comp_candidates\n", 0, 0, 0 );
-
- val = bv->bv_val;
- len = bv->bv_len;
- idl = NULL;
-
- /* prepend ^ for initial substring */
- if ( prepost == '^' ) {
- buf[0] = '^';
- for ( i = 0; i < SUBLEN - 1; i++ ) {
- buf[i + 1] = val[i];
- }
- buf[SUBLEN] = '\0';
-
- if ( (idl = index_read( be, type, SLAP_INDEX_SUBSTR, buf )) == NULL ) {
- return( NULL );
- }
- } else if ( prepost == '$' ) {
- p = val + len - SUBLEN + 1;
- for ( i = 0; i < SUBLEN - 1; i++ ) {
- buf[i] = p[i];
- }
- buf[SUBLEN - 1] = '$';
- buf[SUBLEN] = '\0';
-
- if ( (idl = index_read( be, type, SLAP_INDEX_SUBSTR, buf )) == NULL ) {
- return( NULL );
- }
- }
-
- for ( p = val; p < (val + len - SUBLEN + 1); p++ ) {
- for ( i = 0; i < SUBLEN; i++ ) {
- buf[i] = p[i];
- }
- buf[SUBLEN] = '\0';
-
- if ( (tmp = index_read( be, type, SLAP_INDEX_SUBSTR, buf )) == NULL ) {
- idl_free( idl );
- return( NULL );
- }
-
- if ( idl == NULL ) {
- idl = tmp;
- } else {
- tmp2 = idl;
- idl = idl_intersection( be, idl, tmp );
- idl_free( tmp );
- idl_free( tmp2 );
- }
-
- /* break if no candidates */
- if( idl == NULL ) {
- break;
- }
-
- /* if we're down to two (or less) matches, stop searching */
- if( ID_BLOCK_NIDS(idl) < 3 ) {
- Debug( LDAP_DEBUG_TRACE, "substring_comp_candiates: "
- "down to a %ld matches, stopped search\n",
- (long) ID_BLOCK_NIDS(idl), 0, 0 );
- break;
- }
- }
-
- Debug( LDAP_DEBUG_TRACE, "<= substring_comp_candidates %ld\n",
- idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
- return( idl );
-}
-#endif
Entry *target,
const char *gr_ndn,
const char *op_ndn,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
ObjectClass *group_oc,
AttributeDescription *group_at
-#else
- const char *group_oc,
- const char *group_at
-#endif
)
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
Attribute *attr;
struct berval bv;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
const char *group_oc_name = NULL;
const char *group_at_name = group_at->ad_cname->bv_val;
} else {
group_oc_name = group_oc->soc_oid;
}
-#else
- const char *ad_objectClass = "objectclass";
- const char *group_oc_name = group_oc;
- const char *group_at_name = group_at;
-#endif
Debug( LDAP_DEBUG_ARGS,
"=> ldbm_back_group: gr dn: \"%s\"\n",
rc = 1;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
if( is_entry_alias( e ) ) {
Debug( LDAP_DEBUG_ACL,
"<= ldbm_back_group: group is an alias\n", 0, 0, 0 );
goto return_results;
}
-#else
- if ((attr = attr_find(e->e_attrs, ad_objectClass)) == NULL) {
- Debug( LDAP_DEBUG_ACL,
- "<= ldbm_back_group: failed to find objectClass\n", 0, 0, 0 );
- goto return_results;
- }
-
- bv.bv_val = "ALIAS";
- bv.bv_len = sizeof("ALIAS")-1;
-
- if ( value_find(attr->a_vals, &bv, attr->a_syntax, 1) == 0) {
- Debug( LDAP_DEBUG_ACL,
- "<= ldbm_back_group: group is an alias\n", 0, 0, 0 );
- goto return_results;
- }
-
- bv.bv_val = "REFERRAL";
- bv.bv_len = sizeof("REFERRAL")-1;
-
- if ( value_find(attr->a_vals, &bv, attr->a_syntax, 1) == 0) {
- Debug( LDAP_DEBUG_ACL,
- "<= ldbm_back_group: group is a referral\n",
- 0, 0, 0 );
- goto return_results;
- }
-
- bv.bv_val = (char *) group_oc_name;
- bv.bv_len = strlen( bv.bv_val );
-
- if (value_find(attr->a_vals, &bv, attr->a_syntax, 1) != 0) {
- Debug( LDAP_DEBUG_ACL,
- "<= ldbm_back_group: failed to find %s in objectClass\n",
- group_oc_name, 0, 0 );
- goto return_results;
- }
-
- if ((attr = attr_find(e->e_attrs, group_at)) == NULL) {
- Debug( LDAP_DEBUG_ACL,
- "<= ldbm_back_group: failed to find %s\n",
- group_at_name, 0, 0 );
- goto return_results;
- }
-
- Debug( LDAP_DEBUG_ACL,
- "<= ldbm_back_group: found objectClass %s and %s\n",
- group_oc_name, group_at_name, 0 );
-
- bv.bv_val = (char *) op_ndn;
- bv.bv_len = strlen( op_ndn );
-
- if( value_find( attr->a_vals, &bv, attr->a_syntax, 1) != 0 )
- {
- Debug( LDAP_DEBUG_ACL,
- "<= ldbm_back_group: \"%s\" not in \"%s\": %s\n",
- op_ndn, gr_ndn, group_at_name );
- goto return_results;
- }
-#endif
Debug( LDAP_DEBUG_ACL,
static ID_BLOCK* idl_dup( ID_BLOCK *idl );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
static void cont_alloc( Datum cont, Datum key )
{
ldbm_datum_init( cont );
{
ch_free( cont.dptr );
}
-#endif
/* Allocate an ID_BLOCK with room for nids ids */
ID_BLOCK *
ID_BLOCK *idl;
ID_BLOCK **tmp;
int i, nids;
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- char *kstr;
-#endif
idl = idl_fetch_one( be, db, key );
tmp = (ID_BLOCK **) ch_malloc( (i + 1) * sizeof(ID_BLOCK *) );
/* read in all the blocks */
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
cont_alloc( data, key );
-#else
- kstr = (char *) ch_malloc( key.dsize + SLAP_INDEX_CONT_SIZE );
-#endif
nids = 0;
for ( i = 0; !ID_BLOCK_NOID(idl, i); i++ ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
cont_id( data, ID_BLOCK_ID(idl, i) );
-#else
- sprintf( kstr, "%c%ld%s", SLAP_INDEX_CONT_PREFIX,
- ID_BLOCK_ID(idl, i), key.dptr );
-
- data.dptr = kstr;
- data.dsize = strlen( kstr ) + 1;
-#endif
if ( (tmp[i] = idl_fetch_one( be, db, data )) == NULL ) {
Debug( LDAP_DEBUG_ANY,
nids += ID_BLOCK_NIDS(tmp[i]);
}
tmp[i] = NULL;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
cont_free( data );
-#else
- free( kstr );
-#endif
idl_free( idl );
/* allocate space for the big block */
}
/* write block with new key */
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
cont_id( bkey, ID_BLOCK_ID(b, 0) );
-#else
- sprintf( bkey.dptr, "%c%ld%s", SLAP_INDEX_CONT_PREFIX,
- ID_BLOCK_ID(b, 0), hkey.dptr );
- bkey.dsize = strlen( bkey.dptr ) + 1;
-#endif
if ( (rc = idl_store( be, db, bkey, b )) != 0 ) {
Debug( LDAP_DEBUG_ANY,
int i, j, first, rc;
ID_BLOCK *idl, *tmp, *tmp2, *tmp3;
Datum k2;
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- char *kstr;
-
- ldbm_datum_init( k2 );
-#endif
if ( (idl = idl_fetch_one( be, db, key )) == NULL ) {
#ifdef LDBM_DEBUG
/* store it */
rc = idl_store( be, db, key, idl );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
cont_alloc( k2, key );
cont_id( k2, ID_BLOCK_ID(tmp, 0) );
-#else
- /* store the first id block */
- kstr = (char *) ch_malloc( key.dsize + SLAP_INDEX_CONT_SIZE );
- sprintf( kstr, "%c%ld%s", SLAP_INDEX_CONT_PREFIX,
- ID_BLOCK_ID(tmp, 0), key.dptr );
-
- k2.dptr = kstr;
- k2.dsize = strlen( kstr ) + 1;
-#endif
rc = idl_store( be, db, k2, tmp );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
cont_id( k2, ID_BLOCK_ID(tmp2, 0) );
-#else
- /* store the second id block */
- sprintf( kstr, "%c%ld%s", SLAP_INDEX_CONT_PREFIX,
- ID_BLOCK_ID(tmp2, 0), key.dptr );
- k2.dptr = kstr;
- k2.dsize = strlen( kstr ) + 1;
-#endif
rc = idl_store( be, db, k2, tmp2 );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
cont_free( k2 );
-#else
- free( kstr );
-#endif
idl_free( tmp );
idl_free( tmp2 );
}
/* get the block */
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
cont_alloc( k2, key );
cont_id( k2, ID_BLOCK_ID(idl, i) );
-#else
- kstr = (char *) ch_malloc( key.dsize + SLAP_INDEX_CONT_SIZE );
- sprintf( kstr, "%c%ld%s", SLAP_INDEX_CONT_PREFIX,
- ID_BLOCK_ID(idl, i), key.dptr );
- k2.dptr = kstr;
- k2.dsize = strlen( kstr ) + 1;
-#endif
if ( (tmp = idl_fetch_one( be, db, k2 )) == NULL ) {
Debug( LDAP_DEBUG_ANY, "nonexistent continuation block (%s)\n",
k2.dptr, 0, 0 );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
cont_free( k2 );
-#else
- free( kstr );
-#endif
idl_free( idl );
return( -1 );
}
/* is there a next block? */
if ( !first && !ID_BLOCK_NOID(idl, i + 1) ) {
/* read it in */
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
cont_alloc( k2, key );
cont_id( k2, ID_BLOCK_ID(idl, i) );
-#else
- k2.dptr = (char *) ch_malloc( key.dsize + SLAP_INDEX_CONT_SIZE );
- sprintf( k2.dptr, "%c%ld%s", SLAP_INDEX_CONT_PREFIX,
- ID_BLOCK_ID(idl, i + 1), key.dptr );
- k2.dsize = strlen( k2.dptr ) + 1;
-#endif
if ( (tmp2 = idl_fetch_one( be, db, k2 )) == NULL ) {
Debug( LDAP_DEBUG_ANY,
"idl_fetch_one (%s) returns NULL\n",
k2.dptr, 0, 0 );
/* split the original block */
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
cont_free( k2 );
-#else
- free( k2.dptr );
-#endif
goto split;
}
*/
rc = idl_insert( &tmp, id, db->dbc_maxids );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
k3.dptr = ch_malloc(k2.dsize);
k3.dsize = k2.dsize;
memcpy(k3.dptr, k2.dptr, k3.dsize);
-#else
- k3.dptr = strdup( kstr );
- k3.dsize = strlen( kstr ) + 1;
-#endif
if ( (rc = idl_store( be, db, k3, tmp )) != 0 ) {
Debug( LDAP_DEBUG_ANY,
"idl_store of (%s) returns %d\n", k3.dptr, rc, 0 );
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
free( k3.dptr );
-#else
- free( kstr );
- kstr = k2.dptr;
-#endif
id = id2;
/* This new id will necessarily be inserted
id, 0, 0 );
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
assert( 0 ); /* not yet implemented */
-#else
- free( kstr );
-#endif
idl_free( tmp );
idl_free( tmp2 );
idl_free( idl );
/* delete all indirect blocks */
for ( j = 0; !ID_BLOCK_NOID(idl, j); j++ ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
cont_id( k2, ID_BLOCK_ID(idl, j) );
-#else
- sprintf( kstr, "%c%ld%s", SLAP_INDEX_CONT_PREFIX,
- ID_BLOCK_ID(idl, j), key.dptr );
- k2.dptr = kstr;
- k2.dsize = strlen( kstr ) + 1;
-#endif
rc = ldbm_cache_delete( db, k2 );
}
idl = idl_allids( be );
rc = idl_store( be, db, key, idl );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
cont_free( k2 );
-#else
- free( kstr );
-#endif
idl_free( idl );
idl_free( tmp );
return( rc );
rc = idl_store( be, db, key, tmp );
/* store the first id block */
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
cont_id( k2, ID_BLOCK_ID(tmp2, 0) );
-#else
- sprintf( kstr, "%c%ld%s", SLAP_INDEX_CONT_PREFIX,
- ID_BLOCK_ID(tmp2, 0), key.dptr );
- k2.dptr = kstr;
- k2.dsize = strlen( kstr ) + 1;
-#endif
rc = idl_store( be, db, k2, tmp2 );
/* store the second id block */
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
cont_id( k2, ID_BLOCK_ID(tmp3, 0) );
-#else
- sprintf( kstr, "%c%ld%s", SLAP_INDEX_CONT_PREFIX,
- ID_BLOCK_ID(tmp3, 0), key.dptr );
- k2.dptr = kstr;
- k2.dsize = strlen( kstr ) + 1;
-#endif
rc = idl_store( be, db, k2, tmp3 );
idl_free( tmp2 );
break;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
cont_free( k2 );
-#else
- free( kstr );
-#endif
idl_free( tmp );
idl_free( idl );
return( rc );
ID_BLOCK *idl;
unsigned i;
int j, nids;
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- char *kstr;
-#endif
if ( (idl = idl_fetch_one( be, db, key ) ) == NULL )
{
for ( nids = 0; !ID_BLOCK_NOID(idl, nids); nids++ )
; /* NULL */
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
cont_alloc( data, key );
-#else
- kstr = (char *) ch_malloc( key.dsize + SLAP_INDEX_CONT_SIZE );
-#endif
for ( j = 0; !ID_BLOCK_NOID(idl, j); j++ )
{
ID_BLOCK *tmp;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
cont_id( data, ID_BLOCK_ID(idl, j) );
-#else
- ldbm_datum_init( data );
- sprintf( kstr, "%c%ld%s", SLAP_INDEX_CONT_PREFIX,
- ID_BLOCK_ID(idl, j), key.dptr );
- data.dptr = kstr;
- data.dsize = strlen( kstr ) + 1;
-#endif
if ( (tmp = idl_fetch_one( be, db, data )) == NULL ) {
Debug( LDAP_DEBUG_ANY,
idl_store( be, db, key, idl );
}
idl_free( tmp );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
cont_free( data );
-#else
- free( kstr );
-#endif
idl_free( idl );
return 0;
}
idl_free( tmp );
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
cont_free( data );
-#else
- free( kstr );
-#endif
idl_free( idl );
return -1;
}
#include "slap.h"
#include "back-ldbm.h"
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
static index_mask(
Backend *be,
AttributeDescription *desc,
return LDAP_SUCCESS;
}
-#else
-int index_change_values(
- Backend *be,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
- AttributeDescription *desc,
-#else
- char *desc,
-#endif
- struct berval **vals,
- ID id,
- unsigned int op
-);
-
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
-static int change_value(Backend *be,
- DBCache *db,
- char *type,
- int indextype,
- char *val,
- ID id,
- int
- (*idl_func)(Backend *, DBCache *, Datum, ID));
-#endif
-#endif
int
index_entry(
Attribute *ap
)
{
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- struct berval bv;
- struct berval *bvals[2];
-#endif
Debug( LDAP_DEBUG_TRACE, "=> index_entry_%s( %ld, \"%s\" )\n",
op == SLAP_INDEX_ADD_OP ? "add" : "del",
e->e_id, e->e_dn );
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- /*
- * dn index entry - make it look like an attribute so it works
- * with index_change_values() call
- */
-
- bv.bv_val = ch_strdup( e->e_ndn );
- bv.bv_len = strlen( bv.bv_val );
- bvals[0] = &bv;
- bvals[1] = NULL;
-
- /* add the dn to the indexes */
- {
- char *dn = ch_strdup("dn");
- index_change_values( be, dn, bvals, e->e_id, op );
- free( dn );
- }
-
- free( bv.bv_val );
-#endif
/* add each attribute to the indexes */
for ( ap; ap != NULL; ap = ap->a_next ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
index_values( be, ap->a_desc, ap->a_vals, e->e_id, op );
-#else
- index_change_values( be, ap->a_type, ap->a_vals, e->e_id, op );
-#endif
}
Debug( LDAP_DEBUG_TRACE, "<= index_entry_%s( %ld, \"%s\" ) success\n",
return LDAP_SUCCESS;
}
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
-
-ID_BLOCK *
-index_read(
- Backend *be,
- char *type,
- int indextype,
- char *val
-)
-{
- DBCache *db;
- Datum key;
- ID_BLOCK *idl;
- int indexmask;
- char prefix;
- char *realval, *tmpval;
- char buf[BUFSIZ];
-
- char *at_cn;
-
- ldbm_datum_init( key );
-
- prefix = slap_index2prefix( indextype );
- Debug( LDAP_DEBUG_TRACE, "=> index_read(\"%c%s\"->\"%s\")\n",
- prefix, type, val );
-
- attr_mask( be->be_private, type, &indexmask );
- if ( ! (indextype & indexmask) ) {
- idl = idl_allids( be );
- Debug( LDAP_DEBUG_TRACE,
- "<= index_read %ld candidates (allids - not indexed)\n",
- idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
- return( idl );
- }
-
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
- at_cn = at_canonical_name( at_find( type ) );
-#else
- attr_normalize( type );
- at_cn = at_canonical_name( type );
-#endif
-
- if ( at_cn == NULL ) {
- Debug( LDAP_DEBUG_ANY,
- "<= index_read no canonical name for type \"%s\"\n",
- type != NULL ? type : "(NULL)", 0, 0 );
- return( NULL );
- }
-
- if ( (db = ldbm_cache_open( be, at_cn, LDBM_SUFFIX, LDBM_WRCREAT ))
- == NULL ) {
- Debug( LDAP_DEBUG_ANY,
- "<= index_read NULL (could not open %s%s)\n",
- at_cn, LDBM_SUFFIX, 0 );
- return( NULL );
- }
-
- realval = val;
- tmpval = NULL;
- if ( prefix != UNKNOWN_PREFIX ) {
- unsigned int len = strlen( val );
-
- if ( (len + 2) < sizeof(buf) ) {
- realval = buf;
- } else {
- /* value + prefix + null */
- tmpval = (char *) ch_malloc( len + 2 );
- realval = tmpval;
- }
-
- realval[0] = prefix;
- strcpy( &realval[1], val );
- }
-
- key.dptr = realval;
- key.dsize = strlen( realval ) + 1;
-
- idl = idl_fetch( be, db, key );
- if ( tmpval != NULL ) {
- free( tmpval );
- }
-
- ldbm_cache_close( be, db );
-
- Debug( LDAP_DEBUG_TRACE, "<= index_read %ld candidates\n",
- idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
- return( idl );
-}
-
-/* Add or remove stuff from index files */
-
-static int
-change_value(
- Backend *be,
- DBCache *db,
- char *type,
- int indextype,
- char *val,
- ID id,
- int (*idl_func)(Backend *, DBCache *, Datum, ID)
-)
-{
- int rc;
- Datum key;
- char *tmpval = NULL;
- char *realval = val;
- char buf[BUFSIZ];
-
- char prefix = slap_index2prefix( indextype );
-
- ldbm_datum_init( key );
-
- Debug( LDAP_DEBUG_TRACE,
- "=> change_value( \"%c%s\", op=%s )\n",
- prefix, val, (idl_func == idl_insert_key ? "ADD":"DELETE") );
-
- if ( prefix != UNKNOWN_PREFIX ) {
- unsigned int len = strlen( val );
-
- if ( (len + 2) < sizeof(buf) ) {
- realval = buf;
- } else {
- /* value + prefix + null */
- tmpval = (char *) ch_malloc( len + 2 );
- realval = tmpval;
- }
- realval[0] = prefix;
- strcpy( &realval[1], val );
- }
-
- key.dptr = realval;
- key.dsize = strlen( realval ) + 1;
-
- rc = idl_func( be, db, key, id );
-
- if ( tmpval != NULL ) {
- free( tmpval );
- }
-
- ldap_pvt_thread_yield();
-
- Debug( LDAP_DEBUG_TRACE, "<= change_value %d\n", rc, 0, 0 );
-
- return( rc );
-
-}
-
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
-static
-#endif
-int
-index_change_values(
- Backend *be,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
- AttributeDescription *desc,
-#else
- char *desc,
-#endif
- struct berval **vals,
- ID id,
- unsigned int op
-)
-{
- char *val, *p, *code, *w;
- unsigned i, j, len;
- int indexmask, syntax;
- char buf[SUBLEN + 1];
- char vbuf[BUFSIZ];
- char *bigbuf;
- DBCache *db;
-
- int (*idl_funct)(Backend *,
- DBCache *,
- Datum, ID);
- char *at_cn; /* Attribute canonical name */
- int mode;
-
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
- char *type = desc->ad_cname->bv_val;
-#else
- char *type = desc;
-#endif
-
- if( vals == NULL ) {
- Debug( LDAP_DEBUG_TRACE,
- "=> index_change_values( %s, NULL, %ld, op=%s )\n",
- type, id, ((op == SLAP_INDEX_ADD_OP) ? "ADD" : "DELETE" ) );
- return 0;
- }
-
- Debug( LDAP_DEBUG_TRACE,
- "=> index_change_values( \"%s\", %ld, op=%s )\n",
- type, id, ((op == SLAP_INDEX_ADD_OP) ? "ADD" : "DELETE" ) );
-
-
- if (op == SLAP_INDEX_ADD_OP) {
- /* Add values */
- idl_funct = idl_insert_key;
- mode = LDBM_WRCREAT;
-
- } else {
- /* Delete values */
- idl_funct = idl_delete_key;
- mode = LDBM_WRITER;
- }
-
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- attr_normalize(type);
-#endif
- attr_mask( be->be_private, desc, &indexmask );
-
- if ( indexmask == 0 ) {
- return( 0 );
- }
-
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
- at_cn = at_canonical_name( at_find( type ) );
-#else
- syntax = attr_syntax( type );
- at_cn = at_canonical_name( type );
-#endif
-
- if ( at_cn == NULL ) {
- Debug( LDAP_DEBUG_ANY,
- "<= index_change_values no canonical name for type \"%s\"\n",
- type != NULL ? type : "(NULL)", 0, 0 );
- return( -1 );
- }
-
- if ( (db = ldbm_cache_open( be, at_cn, LDBM_SUFFIX, mode ))
- == NULL ) {
- Debug( LDAP_DEBUG_ANY,
- "<= index_change_values (couldn't open(%s%s),md=%s)\n",
- at_cn, LDBM_SUFFIX,
- ((mode==LDBM_WRCREAT)?"LDBM_WRCREAT":"LDBM_WRITER") );
- return( -1 );
- }
-
- /*
- * presence index entry
- */
- if ( indexmask & SLAP_INDEX_PRESENT ) {
- change_value( be, db, at_cn, SLAP_INDEX_PRESENT,
- "*", id, idl_funct );
- }
-
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- if ( syntax & SYNTAX_BIN ) {
- goto done;
- }
-#endif
-
- for ( i = 0; vals[i] != NULL; i++ ) {
- Debug( LDAP_DEBUG_TRACE,
- "index_change_values syntax 0x%x\n",
- syntax, 0, 0 );
-
- bigbuf = NULL;
- len = vals[i]->bv_len;
-
- /* value + null */
- if ( len + 2 > sizeof(vbuf) ) {
- bigbuf = (char *) ch_malloc( len + 1 );
- val = bigbuf;
- } else {
- val = vbuf;
- }
- (void) memcpy( val, vals[i]->bv_val, len );
- val[len] = '\0';
-
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- value_normalize( val, syntax );
-#endif
-
- /* value_normalize could change the length of val */
- len = strlen( val );
-
- /*
- * equality index entry
- */
- if ( indexmask & SLAP_INDEX_EQUALITY ) {
- change_value( be, db, at_cn, SLAP_INDEX_EQUALITY,
- val, id, idl_funct);
- }
-
- /*
- * approximate index entry
- */
- if ( indexmask & SLAP_INDEX_APPROX ) {
- for ( w = first_word( val ); w != NULL;
- w = next_word( w ) ) {
- if ( (code = phonetic( w )) != NULL ) {
- change_value( be,
- db,
- at_cn,
- SLAP_INDEX_APPROX,
- code,
- id,
- idl_funct );
- free( code );
- }
- }
- }
-
- /*
- * substrings index entry
- */
- if ( indexmask & SLAP_INDEX_SUBSTR ) {
- /* leading and trailing */
- if ( len > SUBLEN - 2 ) {
- buf[0] = '^';
- for ( j = 0; j < SUBLEN - 1; j++ ) {
- buf[j + 1] = val[j];
- }
- buf[SUBLEN] = '\0';
-
- change_value( be, db, at_cn, SLAP_INDEX_SUBSTR,
- buf, id, idl_funct );
-
- p = val + len - SUBLEN + 1;
- for ( j = 0; j < SUBLEN - 1; j++ ) {
- buf[j] = p[j];
- }
- buf[SUBLEN - 1] = '$';
- buf[SUBLEN] = '\0';
-
- change_value( be, db, at_cn, SLAP_INDEX_SUBSTR,
- buf, id, idl_funct );
- }
-
- /* any */
- for ( p = val; p < (val + len - SUBLEN + 1); p++ ) {
- for ( j = 0; j < SUBLEN; j++ ) {
- buf[j] = p[j];
- }
- buf[SUBLEN] = '\0';
-
- change_value( be, db, at_cn, SLAP_INDEX_SUBSTR,
- buf, id, idl_funct );
- }
- }
-
- if ( bigbuf != NULL ) {
- free( bigbuf );
- }
- }
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
-done:
-#endif
- ldbm_cache_close( be, db );
- return LDAP_SUCCESS;
-}
-#endif
bi->bi_tool_entry_get = ldbm_tool_entry_get;
bi->bi_tool_entry_put = ldbm_tool_entry_put;
bi->bi_tool_index_attr = ldbm_tool_index_attr;
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- bi->bi_tool_index_change = ldbm_tool_index_change;
-#endif
bi->bi_tool_sync = ldbm_tool_sync;
#ifdef HAVE_CYRUS_SASL
int i;
Attribute *a;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
/* char *desc = mod->sm_desc->ad_cname->bv_val; */
MatchingRule *mr = mod->sm_desc->ad_type->sat_equality;
return LDAP_INAPPROPRIATE_MATCHING;
}
-#else
- /* char *desc = mod->mod_type; */
-#endif
a = attr_find( e->e_attrs, mod->sm_desc );
/* check if the values we're adding already exist */
if ( a != NULL ) {
for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
int rc;
int j;
const char *text = NULL;
}
ber_bvfree( asserted );
-#else
- if ( value_find( a->a_vals, mod->sm_bvalues[i],
- a->a_syntax, 3 ) == 0 ) {
- return( LDAP_TYPE_OR_VALUE_EXISTS );
- }
-#endif
}
}
{
int i, j, k, found;
Attribute *a;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
char *desc = mod->sm_desc->ad_cname->bv_val;
MatchingRule *mr = mod->sm_desc->ad_type->sat_equality;
if( mr == NULL || !mr->smr_match ) {
return LDAP_INAPPROPRIATE_MATCHING;
}
-#else
- char *desc = mod->mod_type;
-#endif
/* delete the entire attribute */
if ( mod->sm_bvalues == NULL ) {
/* find each value to delete */
for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
int rc;
const char *text = NULL;
&text );
if( rc != LDAP_SUCCESS ) return rc;
-#endif
found = 0;
for ( j = 0; a->a_vals[j] != NULL; j++ ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
int match;
int rc = value_match( &match, mod->sm_desc, mr,
a->a_vals[j], asserted, &text );
if( rc == LDAP_SUCCESS && match != 0 )
-#else
- if ( value_cmp( mod->mod_bvalues[i], a->a_vals[j],
- a->a_syntax, 3 ) != 0 )
-#endif
{
continue;
}
"removing entire attribute %s\n",
desc, 0, 0 );
if ( attr_delete( &e->e_attrs, mod->sm_desc ) ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
ber_bvfree( asserted );
-#endif
return LDAP_NO_SUCH_ATTRIBUTE;
}
}
break;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
ber_bvfree( asserted );
-#endif
/* looked through them all w/o finding it */
if ( ! found ) {
const char *newSuperior
)
{
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *children = slap_schema.si_ad_children;
-#else
- static const char *children = "children";
-#endif
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
char *p_dn = NULL, *p_ndn = NULL;
char *new_dn = NULL, *new_ndn = NULL;
add_bv.bv_val = new_rdn_val;
add_bv.bv_len = strlen(new_rdn_val);
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
{
int rc;
goto return_results;
}
}
-#else
- mod[0].sml_type = new_rdn_type;
-#endif
mod[0].sml_bvalues = add_bvals;
mod[0].sml_op = SLAP_MOD_SOFTADD;
mod[0].sml_next = NULL;
del_bv.bv_val = old_rdn_val;
del_bv.bv_len = strlen(old_rdn_val);
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
{
int rc;
goto return_results;
}
}
-#else
- mod[1].sml_type = old_rdn_type;
-#endif
mod[0].sml_next = &mod[1];
mod[1].sml_bvalues = del_bvals;
mod[1].sml_op = LDAP_MOD_DELETE;
char *dn;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *entry = slap_schema.si_ad_entry;
-#else
- static const char *entry = "entry";
-#endif
assert( reqoid != NULL );
assert( strcmp( LDAP_EXOP_X_MODIFY_PASSWD, reqoid ) == 0 );
vals[0] = hash;
vals[1] = NULL;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
ml.sml_desc = slap_schema.si_ad_userPassword;
-#else
- ml.sml_type = ch_strdup("userPassword");
-#endif
ml.sml_bvalues = vals;
ml.sml_op = LDAP_MOD_REPLACE;
ml.sml_next = NULL;
rc = ldbm_modify_internal( be,
conn, op, op->o_ndn, &ml, e, text );
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- ch_free(ml.ml_type);
-#endif
}
if( rc == LDAP_SUCCESS ) {
/*
* index.c
*/
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
extern int
index_param LDAP_P((
Backend *be,
struct berval **vals,
ID id,
int op ));
-#endif
int index_entry LDAP_P(( Backend *be, int r, Entry *e, Attribute *ap ));
#define index_entry_add(be,e,ap) index_entry((be),SLAP_INDEX_ADD_OP,(e),(ap))
#define index_entry_del(be,e,ap) index_entry((be),SLAP_INDEX_DELETE_OP,(e),(ap))
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
-int index_change_values LDAP_P((
- Backend *be,
- char *desc,
- struct berval **vals,
- ID id,
- unsigned int op
-));
-ID_BLOCK * index_read LDAP_P(( Backend *be,
- char *desc, int indextype, char *val ));
-#endif
/*
* key.c
)
{
ID_BLOCK *candidates;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
candidates = filter_candidates( be, filter );
-#else
- Filter rf, rf_or, af, af_or, lf, lf_and;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
- AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
-#endif
-
- Debug(LDAP_DEBUG_TRACE, "search_candidates: base=\"%s\" s=%d d=%d\n",
- e->e_ndn, scope, deref );
-#endif
-
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- if( !manageDSAit ) {
- /* match referrals */
- rf.f_next = NULL;
- rf.f_choice = LDAP_FILTER_OR;
- rf.f_or = &rf_or;
- rf.f_or->f_choice = LDAP_FILTER_EQUALITY;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
- rf.f_or->f_av_desc = ad_objectClass;
- rf.f_or->f_av_value = ber_bvstrdup("REFERRAL");
-#else
- rf.f_or->f_avtype = ch_strdup( "objectclass" );
- rf.f_or->f_avvalue.bv_val = ch_strdup( "REFERRAL" );
- rf.f_or->f_avvalue.bv_len = sizeof("REFERRAL")-1;
-#endif
- rf.f_or->f_next = filter;
- filter = &rf;
- } else {
- rf.f_or = NULL;
- }
-
- if( deref & LDAP_DEREF_SEARCHING ) {
- /* match aliases */
- af.f_next = NULL;
- af.f_choice = LDAP_FILTER_OR;
- af.f_or = &af_or;
- af.f_or->f_choice = LDAP_FILTER_EQUALITY;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
- af.f_or->f_av_desc = objectClass;
- af.f_or->f_av_value = ber_bvstrdup("ALIAS");
-#else
- af.f_or->f_avtype = ch_strdup( "objectclass" );
- af.f_or->f_avvalue.bv_val = ch_strdup( "ALIAS" );
- af.f_or->f_avvalue.bv_len = sizeof("ALIAS")-1;
-#endif
- af.f_or->f_next = filter;
- filter = ⁡
- } else {
- af.f_or = NULL;
- }
-
- if ( scope == LDAP_SCOPE_SUBTREE ) {
- lf.f_next = NULL;
- lf.f_choice = LDAP_FILTER_AND;
- lf.f_and = &lf_and;
- lf.f_and->f_choice = SLAPD_FILTER_DN_SUBTREE;
- lf.f_and->f_dn = e->e_ndn;
- lf.f_and->f_next = filter;
- filter = &lf;
-
- } else if ( scope == LDAP_SCOPE_ONELEVEL ) {
- lf.f_next = NULL;
- lf.f_choice = LDAP_FILTER_AND;
- lf.f_and = &lf_and;
- lf.f_and->f_choice = SLAPD_FILTER_DN_ONE;
- lf.f_and->f_dn = e->e_ndn;
- lf.f_and->f_next = filter;
- filter = &lf;
- }
-
- candidates = filter_candidates( be, filter );
-
- /* free dynamically allocated bits */
- if( af.f_or != NULL ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
- ber_bvfree( af.f_or->f_av_value );
-#else
- free( af.f_or->f_avtype );
- free( af.f_or->f_avvalue.bv_val );
-#endif
- }
-
- if( rf.f_or != NULL ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
- ber_bvfree( rf.f_or->f_av_value );
-#else
- free( rf.f_or->f_avtype );
- free( rf.f_or->f_avvalue.bv_val );
-#endif
- }
-
-#endif
return( candidates );
}
int ldbm_tool_index_attr(
BackendDB *be,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *desc
-#else
- char* type
-#endif
)
{
static DBCache *db = NULL;
slap_index indexmask;
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- char *desc;
-#endif
char *at_cname;
assert( slapMode & SLAP_TOOL_MODE );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
at_cname = desc->ad_cname->bv_val;
-#else
- attr_normalize( type );
- at_cname = desc = at_canonical_name( type );
-
- if( desc == NULL ) {
- Debug( LDAP_DEBUG_ANY,
- "<= index_attr NULL (attribute type %s has no canonical name)\n",
- type, 0, 0 );
- return 0;
- }
-#endif
assert( desc != NULL );
attr_mask( be->be_private, at_cname, &indexmask );
int ldbm_tool_index_change(
BackendDB *be,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *desc,
-#else
- char* desc,
-#endif
struct berval **bv,
ID id,
int op )
{
assert( slapMode & SLAP_TOOL_MODE );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
index_values( be, desc, bv, id, op );
-#else
- index_change_values( be,
- desc, bv, id, op );
-#endif
return 0;
}
char *matched = NULL;
char *user = NULL;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
-#else
- static char *ad_objectClass = "objectClass";
-#endif
tlimit = (tlimit > be->be_timelimit || tlimit < 1) ? be->be_timelimit
: tlimit;
if( scope != LDAP_SCOPE_ONELEVEL ) {
char *type;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *desc = NULL;
-#else
- char *desc;
-#endif
/* Create an entry corresponding to the base DN */
e = (Entry *) ch_calloc(1, sizeof(Entry));
type = rdn_attr_type(rdn);
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
{
int rc;
const char *text;
goto done;
}
}
-#else
- desc = type;
-#endif
attr_merge( e, desc, vals );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
ad_free( desc, 1 );
-#endif
free(rdn);
rdn = NULL;
struct berval val;
struct berval *vals[2];
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
int rc;
const char *text;
rc = slap_str2ad( "description", &ad_description, &text );
if(rc != LDAP_SUCCESS) return NULL;
-#else
- static char *ad_objectClass = "objectClass";
- static char *ad_cn = "cn";
- static char *ad_sn = "sn";
- static char *ad_uid = "uid";
- static char *ad_description = "description";
-#endif
vals[0] = &val;
vals[1] = NULL;
Entry *target,
const char *gr_ndn,
const char *op_ndn,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
ObjectClass *group_oc,
AttributeDescription *group_at
-#else
- const char *group_oc,
- const char *group_at
-#endif
)
{
if( strcmp( target->e_ndn, gr_ndn ) != 0 ) {
Entry *e )
{
Attribute *a = ch_malloc( sizeof( Attribute ) );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
a->a_desc = ad_dup( slap_schema.si_ad_subschemaSubentry );
-#else
- a->a_type = ch_strdup("subschemasubentry");
- a->a_syntax = SYNTAX_DN | SYNTAX_CIS;
-#endif
/* Should be backend specific */
a->a_vals = ch_malloc( 2 * sizeof( struct berval * ) );
char *dn = NULL, *ndn=NULL;
struct berval desc;
struct berval value;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
struct berval *nvalue;
AttributeAssertion ava;
-#else
- Ava ava;
-#endif
Backend *be;
int rc = LDAP_SUCCESS;
const char *text = NULL;
goto cleanup;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
ava.aa_desc = NULL;
rc = slap_bv2ad( &desc, &ava.aa_desc, &text );
if( rc != LDAP_SUCCESS ) {
Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d CMP dn=\"%s\" attr=\"%s\"\n",
op->o_connid, op->o_opid, dn, ava.aa_desc->ad_cname, 0 );
-#else
- ava.ava_type = desc.bv_val;
- ava.ava_value = value;
- attr_normalize( ava.ava_type );
- value_normalize( ava.ava_value.bv_val, attr_syntax( ava.ava_type ) );
-
- Debug( LDAP_DEBUG_ARGS, "do_compare: dn (%s) attr (%s) value (%s)\n",
- dn, ava.ava_type, ava.ava_value.bv_val );
-
- Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d CMP dn=\"%s\" attr=\"%s\"\n",
- op->o_connid, op->o_opid, dn, ava.ava_type, 0 );
-#endif
/*
free( ndn );
free( desc.bv_val );
free( value.bv_val );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
if( ava.aa_desc != NULL ) {
ad_free( ava.aa_desc, 1 );
}
-#endif
return rc;
}
p = strchr(saveline,'(');
parse_oc( fname, lineno, p, cargv );
} else {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
Debug( LDAP_DEBUG_ANY,
"%s: line %d: old objectclass format not supported.\n",
fname, lineno, 0 );
-#else
- parse_oc_old( be, fname, lineno, cargc, cargv );
-#endif
}
/* specify an attribute type */
p = strchr(saveline,'(');
parse_at( fname, lineno, p, cargv );
} else {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
Debug( LDAP_DEBUG_ANY,
"%s: line %d: old attribute type format not supported.\n",
fname, lineno, 0 );
-#else
- at_config( fname, lineno, cargc - 1,
- &cargv[1] );
-#endif
}
/* turn on/off schema checking */
char *type;
struct berval value;
struct berval *vals[2];
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *ad;
const char *text;
-#else
- int nvals = 0;
- int maxvals = 0;
- char ptype[64]; /* fixed size buffer */
-#endif
char *next;
/*
/* dn + attributes */
vals[0] = &value;
vals[1] = NULL;
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- ptype[0] = '\0';
-#endif
next = s;
while ( (s = ldif_getline( &next )) != NULL ) {
continue;
}
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- if ( strcasecmp( type, ptype ) != 0 ) {
- strncpy( ptype, type, sizeof(ptype) - 1 );
- nvals = 0;
- maxvals = 0;
- a = NULL;
- }
-
-#endif
if ( strcasecmp( type, "dn" ) == 0 ) {
free( type );
continue;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
ad = NULL;
rc = slap_str2ad( type, &ad, &text );
rc = attr_merge( e, ad, vals );
ad_free( ad, 1 );
-#else
- rc = attr_merge_fast( e, type, vals, nvals, 1, &maxvals, &a );
-#endif
if( rc != 0 ) {
Debug( LDAP_DEBUG_TRACE,
free( type );
free( value.bv_val );
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- nvals++;
-#endif
}
/* check to make sure there was a dn: line */
/* put "<type>:[:] <value>" line for each value */
for ( i = 0; a->a_vals[i] != NULL; i++ ) {
bv = a->a_vals[i];
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
tmplen = a->a_desc->ad_cname->bv_len;
-#else
- tmplen = strlen( a->a_type );
-#endif
MAKE_SPACE( LDIF_SIZE_NEEDED( tmplen, bv->bv_len ));
ldif_sput( (char **) &ecur, LDIF_PUT_VALUE,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
a->a_desc->ad_cname->bv_val,
-#else
- a->a_type,
-#endif
bv->bv_val, bv->bv_len );
}
}
case LDAP_FILTER_EQUALITY:
Debug( LDAP_DEBUG_FILTER, "EQUALITY\n", 0, 0, 0 );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
err = get_ava( ber, &f->f_ava, SLAP_MR_EQUALITY, text );
-#else
- err = get_ava( ber, &f->f_ava, text );
-#endif
if ( err != LDAP_SUCCESS ) {
break;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
assert( f->f_ava != NULL );
*fstr = ch_malloc( sizeof("(=)")
f->f_av_desc->ad_cname->bv_val,
f->f_av_value->bv_val );
-#else
- *fstr = ch_malloc( sizeof("(=)")
- + strlen( f->f_avtype )
- + f->f_avvalue.bv_len);
- sprintf( *fstr, "(%s=%s)", f->f_avtype,
- f->f_avvalue.bv_val );
-#endif
break;
case LDAP_FILTER_SUBSTRINGS:
case LDAP_FILTER_GE:
Debug( LDAP_DEBUG_FILTER, "GE\n", 0, 0, 0 );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
err = get_ava( ber, &f->f_ava, SLAP_MR_ORDERING, text );
-#else
- err = get_ava( ber, &f->f_ava, text );
-#endif
if ( err != LDAP_SUCCESS ) {
break;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
*fstr = ch_malloc( sizeof("(>=)")
+ f->f_av_desc->ad_cname->bv_len
+ f->f_av_value->bv_len );
f->f_av_desc->ad_cname->bv_val,
f->f_av_value->bv_val );
-#else
- *fstr = ch_malloc( sizeof("(>=)")
- + strlen( f->f_avtype )
- + f->f_avvalue.bv_len);
- sprintf( *fstr, "(%s>=%s)", f->f_avtype,
- f->f_avvalue.bv_val );
-#endif
break;
case LDAP_FILTER_LE:
Debug( LDAP_DEBUG_FILTER, "LE\n", 0, 0, 0 );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
err = get_ava( ber, &f->f_ava, SLAP_MR_ORDERING, text );
-#else
- err = get_ava( ber, &f->f_ava, text );
-#endif
if ( err != LDAP_SUCCESS ) {
break;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
*fstr = ch_malloc( sizeof("(<=)")
+ f->f_av_desc->ad_cname->bv_len
+ f->f_av_value->bv_len );
f->f_av_desc->ad_cname->bv_val,
f->f_av_value->bv_val );
-#else
- *fstr = ch_malloc( sizeof("(<=)")
- + strlen( f->f_avtype )
- + f->f_avvalue.bv_len);
- sprintf( *fstr, "(%s<=%s)", f->f_avtype,
- f->f_avvalue.bv_val );
-#endif
break;
case LDAP_FILTER_PRESENT: {
break;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
f->f_desc = NULL;
err = slap_bv2ad( &type, &f->f_desc, text );
sprintf( *fstr, "(%s=*)",
f->f_desc->ad_cname->bv_val );
-#else
- f->f_type = type.bv_val;
- err = LDAP_SUCCESS;
- attr_normalize( f->f_type );
- *fstr = ch_malloc( sizeof("(=*)")
- + strlen( f->f_type ) );
- sprintf( *fstr, "(%s=*)", f->f_type );
-#endif
} break;
case LDAP_FILTER_APPROX:
Debug( LDAP_DEBUG_FILTER, "APPROX\n", 0, 0, 0 );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
err = get_ava( ber, &f->f_ava, SLAP_MR_EQUALITY_APPROX, text );
-#else
- err = get_ava( ber, &f->f_ava, text );
-#endif
if ( err != LDAP_SUCCESS ) {
break;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
*fstr = ch_malloc( sizeof("(~=)")
+ f->f_av_desc->ad_cname->bv_len
+ f->f_av_value->bv_len );
f->f_av_desc->ad_cname->bv_val,
f->f_av_value->bv_val );
-#else
- *fstr = ch_malloc( sizeof("(~=)")
- + strlen( f->f_avtype )
- + f->f_avvalue.bv_len);
- sprintf( *fstr, "(%s~=%s)", f->f_avtype,
- f->f_avvalue.bv_val );
-#endif
break;
case LDAP_FILTER_AND:
struct berval *value;
char *last;
struct berval type;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
struct berval *nvalue;
-#else
- int syntax;
-#endif
*text = "error decoding filter";
Debug( LDAP_DEBUG_FILTER, "begin get_substring_filter\n", 0, 0, 0 );
return SLAPD_DISCONNECT;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
f->f_sub = ch_calloc( 1, sizeof(SubstringsAssertion) );
f->f_sub_desc = NULL;
rc = slap_bv2ad( &type, &f->f_sub_desc, text );
*fstr = ch_strdup( "(undefined)" );
return LDAP_SUCCESS;
}
-#else
- f->f_sub_type = type.bv_val;
- attr_normalize( f->f_sub_type );
-
- /* should get real syntax and see if we have a substring matching rule */
- syntax = attr_syntax( f->f_sub_type );
-#endif
f->f_sub_initial = NULL;
f->f_sub_any = NULL;
f->f_sub_final = NULL;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
if( fstr ) {
*fstr = ch_malloc( sizeof("(=" /*)*/) +
f->f_sub_desc->ad_cname->bv_len );
sprintf( *fstr, "(%s=" /*)*/, f->f_sub_desc->ad_cname->bv_val );
}
-#else
- if( fstr ) {
- *fstr = ch_malloc( strlen( f->f_sub_type ) + 3 );
- sprintf( *fstr, "(%s=" /*)*/, f->f_sub_type );
- }
-#endif
for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT;
tag = ber_next_element( ber, &len, last ) )
{
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
unsigned usage;
-#endif
rc = ber_scanf( ber, "O", &value );
if ( rc == LBER_ERROR ) {
goto return_error;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
switch ( tag ) {
case LDAP_SUBSTRING_INITIAL:
usage = SLAP_MR_SUBSTR_INITIAL;
}
value = nvalue;
-#else
-
- /* we should call a substring syntax normalization routine */
- value_normalize( value->bv_val, syntax );
- /* this is bogus, value_normalize should take a berval */
- value->bv_len = strlen( value->bv_val );
-#endif
rc = LDAP_PROTOCOL_ERROR;
*fstr = NULL;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
ad_free( f->f_sub_desc, 1 );
-#else
- ch_free( f->f_sub_type );
-#endif
ber_bvfree( f->f_sub_initial );
ber_bvecfree( f->f_sub_any );
ber_bvfree( f->f_sub_final );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
ch_free( f->f_sub );
-#endif
return rc;
}
}
switch ( f->f_choice ) {
case LDAP_FILTER_PRESENT:
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
ad_free( f->f_desc, 1 );
-#else
- if ( f->f_type != NULL ) {
- free( f->f_type );
- }
-#endif
break;
case LDAP_FILTER_EQUALITY:
case LDAP_FILTER_GE:
case LDAP_FILTER_LE:
case LDAP_FILTER_APPROX:
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
ava_free( f->f_ava, 1 );
-#else
- ava_free( &f->f_ava, 0 );
-#endif
break;
case LDAP_FILTER_SUBSTRINGS:
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
ad_free( f->f_sub_desc, 1 );
if ( f->f_sub_initial != NULL ) {
ber_bvfree( f->f_sub_initial );
if ( f->f_sub_final != NULL ) {
ber_bvfree( f->f_sub_final );
}
-#else
- if ( f->f_sub_type != NULL ) {
- free( f->f_sub_type );
- }
- if ( f->f_sub_initial != NULL ) {
- ber_bvfree( f->f_sub_initial );
- }
- ber_bvecfree( f->f_sub_any );
- if ( f->f_sub_final != NULL ) {
- ber_bvfree( f->f_sub_final );
- }
-#endif
break;
case LDAP_FILTER_AND:
switch ( f->f_choice ) {
case LDAP_FILTER_EQUALITY:
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
fprintf( stderr, "(%s=%s)",
f->f_av_desc->ad_cname->bv_val,
f->f_av_value->bv_val );
-#else
- fprintf( stderr, "(%s=%s)",
- f->f_ava.ava_type,
- f->f_ava.ava_value.bv_val );
-#endif
break;
case LDAP_FILTER_GE:
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
fprintf( stderr, "(%s>=%s)",
f->f_av_desc->ad_cname->bv_val,
f->f_av_value->bv_val );
-#else
- fprintf( stderr, "(%s>=%s)",
- f->f_ava.ava_type,
- f->f_ava.ava_value.bv_val );
-#endif
break;
case LDAP_FILTER_LE:
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
fprintf( stderr, "(%s<=%s)",
f->f_ava->aa_desc->ad_cname->bv_val,
f->f_ava->aa_value->bv_val );
-#else
- fprintf( stderr, "(%s<=%s)",
- f->f_ava.ava_type,
- f->f_ava.ava_value.bv_val );
-#endif
break;
case LDAP_FILTER_APPROX:
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
fprintf( stderr, "(%s~=%s)",
f->f_ava->aa_desc->ad_cname->bv_val,
f->f_ava->aa_value->bv_val );
-#else
- fprintf( stderr, "(%s~=%s)",
- f->f_ava.ava_type,
- f->f_ava.ava_value.bv_val );
-#endif
break;
case LDAP_FILTER_SUBSTRINGS:
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
fprintf( stderr, "(%s=" /*)*/,
f->f_sub_desc->ad_cname->bv_val );
-#else
- fprintf( stderr, "(%s=" /*)*/,
- f->f_sub_type );
-#endif
if ( f->f_sub_initial != NULL ) {
fprintf( stderr, "%s",
f->f_sub_initial->bv_val );
break;
case LDAP_FILTER_PRESENT:
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
fprintf( stderr, "(%s=*)",
f->f_desc->ad_cname->bv_val );
-#else
- fprintf( stderr, "(%s=*)",
- f->f_type );
-#endif
break;
case LDAP_FILTER_AND:
#include <ac/socket.h>
#include <ac/string.h>
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
-#include <ac/regex.h>
-#endif
#include "slap.h"
static int test_substring_filter( Backend *be,
Connection *conn, Operation *op,
Entry *e, Filter *f);
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
static int test_ava_filter( Backend *be,
Connection *conn, Operation *op,
Entry *e, AttributeAssertion *ava, int type );
static int test_presence_filter( Backend *be,
Connection *conn, Operation *op,
Entry *e, AttributeDescription *desc );
-#else
-static int test_ava_filter(Backend *be,
- Connection *conn, Operation *op,
- Entry *e, Ava *ava, int type);
-static int test_approx_filter(Backend *be,
- Connection *conn, Operation *op,
- Entry *e, Ava *ava);
-static int test_presence_filter(Backend *be,
- Connection *conn, Operation *op,
- Entry *e, char *type);
-#endif
/*
Debug( LDAP_DEBUG_FILTER, "=> test_filter\n", 0, 0, 0 );
switch ( f->f_choice ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
case SLAPD_FILTER_COMPUTED:
Debug( LDAP_DEBUG_FILTER, " COMPUTED %s (%d)\n",
f->f_result == LDAP_COMPARE_FALSE ? "false" :
f->f_result, 0 );
rc = f->f_result;
break;
-#endif
case LDAP_FILTER_EQUALITY:
Debug( LDAP_DEBUG_FILTER, " EQUALITY\n", 0, 0, 0 );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
rc = test_ava_filter( be, conn, op, e, f->f_ava,
LDAP_FILTER_EQUALITY );
-#else
- rc = test_ava_filter( be, conn, op, e, &f->f_ava,
- LDAP_FILTER_EQUALITY );
-#endif
break;
case LDAP_FILTER_SUBSTRINGS:
break;
case LDAP_FILTER_GE:
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
rc = test_ava_filter( be, conn, op, e, f->f_ava,
LDAP_FILTER_GE );
-#else
- Debug( LDAP_DEBUG_FILTER, " GE\n", 0, 0, 0 );
- rc = test_ava_filter( be, conn, op, e, &f->f_ava,
- LDAP_FILTER_GE );
-#endif
break;
case LDAP_FILTER_LE:
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
rc = test_ava_filter( be, conn, op, e, f->f_ava,
LDAP_FILTER_LE );
-#else
- Debug( LDAP_DEBUG_FILTER, " LE\n", 0, 0, 0 );
- rc = test_ava_filter( be, conn, op, e, &f->f_ava,
- LDAP_FILTER_LE );
-#endif
break;
case LDAP_FILTER_PRESENT:
Debug( LDAP_DEBUG_FILTER, " PRESENT\n", 0, 0, 0 );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
rc = test_presence_filter( be, conn, op, e, f->f_desc );
-#else
- rc = test_presence_filter( be, conn, op, e, f->f_type );
-#endif
break;
case LDAP_FILTER_APPROX:
Debug( LDAP_DEBUG_FILTER, " APPROX\n", 0, 0, 0 );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
rc = test_ava_filter( be, conn, op, e, f->f_ava,
LDAP_FILTER_APPROX );
-#else
- rc = test_approx_filter( be, conn, op, e, &f->f_ava );
-#endif
break;
case LDAP_FILTER_AND:
Connection *conn,
Operation *op,
Entry *e,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeAssertion *ava,
-#else
- Ava *ava,
-#endif
int type
)
{
int i;
Attribute *a;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
if ( be != NULL && ! access_allowed( be, conn, op, e,
ava->aa_desc, ava->aa_value, ACL_SEARCH ) )
-#else
-
- if ( be != NULL && ! access_allowed( be, conn, op, e,
- ava->ava_type, &ava->ava_value, ACL_SEARCH ) )
-#endif
{
return LDAP_INSUFFICIENT_ACCESS;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
for(a = attrs_find( e->e_attrs, ava->aa_desc );
a != NULL;
a = attrs_find( a->a_next, ava->aa_desc ) )
-#else
- a = attr_find( e->e_attrs, ava->ava_type );
- if ( a != NULL )
-#endif
{
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
MatchingRule *mr;
switch ( type ) {
if( mr == NULL ) {
continue;
}
-#else
- if ( a->a_syntax == 0 ) {
- a->a_syntax = attr_syntax( ava->ava_type );
- }
-#endif
for ( i = 0; a->a_vals[i] != NULL; i++ ) {
int ret;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
int rc;
const char *text;
if( rc != LDAP_SUCCESS ) {
return rc;
}
-#else
- ret = value_cmp( a->a_vals[i], &ava->ava_value, a->a_syntax,
- 3 );
-#endif
switch ( type ) {
case LDAP_FILTER_EQUALITY:
Connection *conn,
Operation *op,
Entry *e,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *desc
-#else
- char *desc
-#endif
)
{
if ( be != NULL && ! access_allowed( be, conn, op, e,
return LDAP_INSUFFICIENT_ACCESS;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
return attrs_find( e->e_attrs, desc ) != NULL
-#else
- return attr_find( e->e_attrs, desc ) != NULL
-#endif
? LDAP_COMPARE_TRUE : LDAP_COMPARE_FALSE;
}
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
-static int
-test_approx_filter(
- Backend *be,
- Connection *conn,
- Operation *op,
- Entry *e,
- Ava *ava
-)
-{
- char *w1, *w2, *c1, *c2;
- int i;
- Attribute *a;
-
- if ( be != NULL && ! access_allowed( be, conn, op, e,
- ava->ava_type, NULL, ACL_SEARCH ) )
- {
- return LDAP_INSUFFICIENT_ACCESS;
- }
-
- a = attr_find( e->e_attrs, ava->ava_type );
- if ( a != NULL ) {
- /* for each value in the attribute */
- for ( i = 0; a->a_vals[i] != NULL; i++ ) {
- /*
- * try to match words in the filter value in order
- * in the attribute value.
- */
-
- w2 = a->a_vals[i]->bv_val;
- /* for each word in the filter value */
- for ( w1 = first_word( ava->ava_value.bv_val ); w1 != NULL;
- w1 = next_word( w1 ) ) {
- if ( (c1 = phonetic( w1 )) == NULL ) {
- break;
- }
-
- /*
- * for each word in the attribute value from
- * where we left off...
- */
- for ( w2 = first_word( w2 ); w2 != NULL;
- w2 = next_word( w2 ) ) {
- c2 = phonetic( w2 );
- if ( strcmp( c1, c2 ) == 0 ) {
- free( c2 );
- break;
- }
- free( c2 );
- }
- free( c1 );
-
- /*
- * if we stopped because we ran out of words
- * before making a match, go on to the next
- * value. otherwise try to keep matching
- * words in this value from where we left off.
- */
- if ( w2 == NULL ) {
- break;
- } else {
- w2 = next_word( w2 );
- }
- }
- /*
- * if we stopped because we ran out of words we
- * have a match.
- */
- if ( w1 == NULL ) {
- return LDAP_COMPARE_TRUE;
- }
- }
- }
-
- return LDAP_COMPARE_FALSE;
-}
-#endif
static int
test_filter_and(
return rtn;
}
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
-static void
-strcpy_regex( char *d, char *s )
-{
- for ( ; *s; s++ ) {
- switch ( *s ) {
- case '^':
- case '.':
- case '[':
- case ']': /* ? */
- case '$':
- case '(':
- case ')': /* ? */
- case '|':
- case '*':
- case '+':
- case '?':
- case '{':
- case '}': /* ? */
- case '\\':
- *d++ = '\\';
- /* FALL */
- default:
- *d++ = *s;
- }
- }
- *d = '\0';
-}
-#endif
static int
test_substring_filter(
)
{
Attribute *a;
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- int i, rc;
- char *p, *end, *realval, *tmp;
- char pat[BUFSIZ];
- char buf[BUFSIZ];
- struct berval *val;
- regex_t re;
-#endif
Debug( LDAP_DEBUG_FILTER, "begin test_substring_filter\n", 0, 0, 0 );
return LDAP_INSUFFICIENT_ACCESS;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
for(a = attrs_find( e->e_attrs, f->f_sub_desc );
a != NULL;
a = attrs_find( a->a_next, f->f_sub_desc ) )
-#else
- a = attr_find( e->e_attrs, f->f_sub_type );
- if ( a != NULL )
-#endif
{
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
int i;
MatchingRule *mr = a->a_desc->ad_type->sat_substr;
return LDAP_COMPARE_TRUE;
}
}
-#else
- if ( a->a_syntax & SYNTAX_BIN ) {
- Debug( LDAP_DEBUG_FILTER, "test_substring_filter bin attr\n",
- 0, 0, 0 );
- return LDAP_INAPPROPRIATE_MATCHING;
- }
-
- /*
- * construct a regular expression corresponding to the
- * filter and let regex do the work
- */
-
- pat[0] = '\0';
- p = pat;
- end = pat + sizeof(pat) - 2; /* leave room for null */
- if ( f->f_sub_initial != NULL ) {
- strcpy( p, "^" );
- p = strchr( p, '\0' );
- /* 2 * in case every char is special */
- if ( p + 2 * f->f_sub_initial->bv_len > end ) {
- Debug( LDAP_DEBUG_ANY, "not enough pattern space\n",
- 0, 0, 0 );
- return LDAP_OTHER;
- }
- strcpy_regex( p, f->f_sub_initial->bv_val );
- p = strchr( p, '\0' );
- }
- if ( f->f_sub_any != NULL ) {
- for ( i = 0; f->f_sub_any[i] != NULL; i++ ) {
- /* ".*" + value */
- if ( p + 2 * f->f_sub_any[i]->bv_len + 2 > end ) {
- Debug( LDAP_DEBUG_ANY,
- "not enough pattern space\n", 0, 0, 0 );
- return LDAP_OTHER;
- }
- strcpy( p, ".*" );
- p = strchr( p, '\0' );
- strcpy_regex( p, f->f_sub_any[i]->bv_val );
- p = strchr( p, '\0' );
- }
- }
- if ( f->f_sub_final != NULL ) {
- /* ".*" + value */
- if ( p + 2 * f->f_sub_final->bv_len + 2 > end ) {
- Debug( LDAP_DEBUG_ANY, "not enough pattern space\n",
- 0, 0, 0 );
- return( -1 );
- }
- strcpy( p, ".*" );
- p = strchr( p, '\0' );
- strcpy_regex( p, f->f_sub_final->bv_val );
- p = strchr( p, '\0' );
- strcpy( p, "$" );
- }
-
- /* compile the regex */
- Debug( LDAP_DEBUG_FILTER, "test_substring_filter: regcomp pat: %s\n",
- pat, 0, 0 );
- if ((rc = regcomp(&re, pat, REG_EXTENDED|REG_NOSUB))) {
- char error[512];
-
- regerror(rc, &re, error, sizeof(error));
- Debug( LDAP_DEBUG_ANY, "regcomp failed (%s) %s\n",
- p, error, 0 );
- return LDAP_OTHER;
- }
-
- /* for each value in the attribute see if regex matches */
- for ( i = 0; a->a_vals[i] != NULL; i++ ) {
- val = a->a_vals[i];
- tmp = NULL;
- if ( val->bv_len < sizeof(buf) ) {
- strcpy( buf, val->bv_val );
- realval = buf;
- } else {
- tmp = (char *) ch_malloc( val->bv_len + 1 );
- strcpy( tmp, val->bv_val );
- realval = tmp;
- }
-
- value_normalize( realval, a->a_syntax );
-
- rc = !regexec(&re, realval, 0, NULL, 0);
-
- if ( tmp != NULL ) {
- free( tmp );
- }
- if ( rc == 1 ) {
- regfree(&re);
- return LDAP_COMPARE_TRUE;
- }
- }
-
- regfree(&re);
-#endif
}
Debug( LDAP_DEBUG_FILTER, "end test_substring_filter 1\n", 0, 0, 0 );
#include "slap.h"
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
-static int add_modified_attrs( Operation *op, Modifications **modlist );
-#endif
int
do_modify(
(*modtail)->ml_op = mop;
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- attr_normalize( (*modtail)->ml_type );
-#endif
modtail = &(*modtail)->ml_next;
}
#endif
{
int update = be->be_update_ndn != NULL;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
const char *text;
rc = slap_modlist2mods( modlist, update, &mods, &text );
NULL, text, NULL, NULL );
goto cleanup;
}
-#else
- mods = modlist;
- modlist = NULL;
-#endif
if ( (be->be_lastmod == ON || (be->be_lastmod == UNDEFINED &&
global_lastmod == ON)) && !update )
{
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
Modifications **modstail;
for( modstail = &mods;
*modstail != NULL;
/* empty */
}
rc = slap_mods_opattrs( op, modstail, &text );
-#else
- char *text = "no-user-modification attribute type";
- rc = add_modified_attrs( op, &mods );
-#endif
if( rc != LDAP_SUCCESS ) {
send_ldap_result( conn, op, rc,
return rc;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
/*
* convert a raw list of modifications to internal format
* Do basic attribute type checking and syntax validation.
return LDAP_SUCCESS;
}
-#else
-static int
-add_modified_attrs( Operation *op, Modifications **modlist )
-{
- char buf[22];
- struct berval bv;
- struct berval *bvals[2];
- Modifications *m;
- struct tm *ltm;
- time_t currenttime;
-
- bvals[0] = &bv;
- bvals[1] = NULL;
-
- /* remove any attempts by the user to modify these attrs */
- for ( m = *modlist; m != NULL; m = m->ml_next ) {
- if ( oc_check_op_no_usermod_attr( m->ml_type ) ) {
- return LDAP_CONSTRAINT_VIOLATION;
- }
- }
-
- if ( op->o_dn == NULL || op->o_dn[0] == '\0' ) {
- bv.bv_val = SLAPD_ANONYMOUS;
- bv.bv_len = sizeof(SLAPD_ANONYMOUS)-1;
- } else {
- bv.bv_val = op->o_dn;
- bv.bv_len = strlen( bv.bv_val );
- }
- m = (Modifications *) ch_calloc( 1, sizeof(Modifications) );
- m->ml_type = ch_strdup( "modifiersname" );
- m->ml_op = LDAP_MOD_REPLACE;
- m->ml_bvalues = (struct berval **) ch_calloc(2, sizeof(struct berval *));
- m->ml_bvalues[0] = ber_bvdup( &bv );
- m->ml_next = *modlist;
- *modlist = m;
-
- currenttime = slap_get_time();
- ldap_pvt_thread_mutex_lock( &gmtime_mutex );
- ltm = gmtime( ¤ttime );
- strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm );
- ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
-
- bv.bv_val = buf;
- bv.bv_len = strlen( bv.bv_val );
- m = (Modifications *) ch_calloc( 1, sizeof(Modifications) );
- m->ml_type = ch_strdup( "modifytimestamp" );
- m->ml_op = LDAP_MOD_REPLACE;
- m->ml_bvalues = (struct berval **) ch_calloc(2, sizeof(struct berval *));
- m->ml_bvalues[0] = ber_bvdup( &bv );
- m->ml_next = *modlist;
- *modlist = m;
-
- return LDAP_SUCCESS;
-}
-#endif
void
slap_mod_free(
int freeit
)
{
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
ad_free( mod->sm_desc, 1 );
-#else
- if (mod->sm_desc) {
- free( mod->sm_desc );
- }
-#endif
if ( mod->sm_bvalues != NULL )
ber_bvecfree( mod->sm_bvalues );
struct berval *vals[2];
MatchingRule *mr;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *ad_matchingRules = slap_schema.si_ad_matchingRules;
-#else
- char *ad_matchingRules = "matchingRules";
-#endif
vals[0] = &val;
vals[1] = NULL;
int is_entry_objectclass(
Entry* e,
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
ObjectClass *oc
-#else
- const char* oc
-#endif
)
{
Attribute *attr;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
int i;
AttributeDescription *objectClass = slap_schema.si_ad_objectClass;
assert(!( e == NULL || oc == NULL ));
-#else
- struct berval bv;
- static const char *objectClass = "objectclass";
- assert(!( e == NULL || oc == NULL || *oc == '\0' ));
-#endif
if( e == NULL || oc == NULL
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- || *oc == '\0'
-#endif
) {
return 0;
}
return 0;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
for( i=0; attr->a_vals[i]; i++ ) {
ObjectClass *objectClass = oc_find( attr->a_vals[i]->bv_val );
return 0;
-#else
- bv.bv_val = (char *) oc;
- bv.bv_len = strlen( bv.bv_val );
-
- if( value_find(attr->a_vals, &bv, attr->a_syntax, 1) != 0) {
- /* entry is not of this objectclass */
- return 0;
- }
-
- return 1;
-#endif
-}
-
-
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- /* these shouldn't be hardcoded */
-
-static char *oc_op_usermod_attrs[] = {
- /*
- * these are operational attributes which are
- * not defined as NO-USER_MODIFICATION and
- * which slapd supports modification of.
- *
- * Currently none.
- * Likely candidate, "OpenLDAPaci"
- */
- NULL
-};
-
-static char *oc_op_attrs[] = {
- /*
- * these are operational attributes
- * most could be user modifiable
- */
- "objectClasses",
- "attributeTypes",
- "matchingRules",
- "matchingRuleUse",
- "dITStructureRules",
- "dITContentRules",
- "nameForms",
- "ldapSyntaxes",
- "namingContexts",
- "supportedExtension",
- "supportedControl",
- "supportedSASLMechanisms",
- "supportedLDAPversion",
- "subschemaSubentry", /* NO USER MOD */
- NULL
-
-};
-
-/* this list should be extensible */
-static char *oc_op_no_usermod_attrs[] = {
- /*
- * Operational and 'no user modification' attributes
- * which are STORED in the directory server.
- */
-
- /* RFC2252, 3.2.1 */
- "creatorsName",
- "createTimestamp",
- "modifiersName",
- "modifyTimestamp",
-
- NULL
-};
-
-
-/*
- * check to see if attribute is 'operational' or not.
- */
-int
-oc_check_op_attr( const char *type )
-{
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- return charray_inlist( oc_op_attrs, type )
- || charray_inlist( oc_op_usermod_attrs, type )
- || charray_inlist( oc_op_no_usermod_attrs, type );
-#else
- AttributeType *at = at_find( type );
-
- if( at == NULL ) return 0;
-
- return at->sat_usage != LDAP_SCHEMA_USER_APPLICATIONS;
-#endif
-}
-
-/*
- * check to see if attribute can be user modified or not.
- */
-int
-oc_check_op_usermod_attr( const char *type )
-{
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- return charray_inlist( oc_op_usermod_attrs, type );
-#else
- /* not (yet) in schema */
- return 0;
-#endif
}
-/*
- * check to see if attribute is 'no user modification' or not.
- */
-int
-oc_check_op_no_usermod_attr( const char *type )
-{
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- return charray_inlist( oc_op_no_usermod_attrs, type );
-#else
- AttributeType *at = at_find( type );
-
- if( at == NULL ) return 0;
- return at->sat_no_user_mod;
-#endif
-}
-#endif
struct oindexrec {
struct berval *vals[2];
ObjectClass *oc;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *ad_objectClasses = slap_schema.si_ad_objectClasses;
-#else
- char *ad_objectClasses = "objectClasses";
-#endif
vals[0] = &val;
vals[1] = NULL;
LDAP_BEGIN_DECL
LIBSLAPD_F( int ) schema_init_done;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
LIBSLAPD_F( struct slap_internal_schema ) slap_schema;
LIBSLAPD_F (int) slap_str2ad LDAP_P((
LIBSLAPD_F (int) ad_inlist LDAP_P((
AttributeDescription *desc,
char **attrs ));
-#else
-#define ad_inlist(d,a) charray_inlist(a,d)
-#endif
/*
* acl.c
*/
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
LIBSLAPD_F (int) access_allowed LDAP_P((
Backend *be, Connection *conn, Operation *op,
Entry *e, AttributeDescription *desc, struct berval *val,
slap_access_t access ));
-#else
-LIBSLAPD_F (int) access_allowed LDAP_P((
- Backend *be, Connection *conn, Operation *op,
- Entry *e, const char *attr, struct berval *val,
- slap_access_t access ));
-#endif
LIBSLAPD_F (int) acl_check_modlist LDAP_P((
Backend *be, Connection *conn, Operation *op,
Entry *e, Modifications *ml ));
LIBSLAPD_F (int) at_schema_info LDAP_P(( Entry *e ));
LIBSLAPD_F (int) at_add LDAP_P(( LDAP_ATTRIBUTE_TYPE *at, const char **err ));
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
LIBSLAPD_F (int) is_at_subtype LDAP_P((
AttributeType *sub,
AttributeType *super ));
const char *oid ));
# define at_canonical_name(at) ((at)->sat_cname)
-#else
-LIBSLAPD_F (int) at_fake_if_needed LDAP_P(( const char *name ));
-LIBSLAPD_F (char *) at_canonical_name LDAP_P(( const char * a_type ));
-#endif
/*
LIBSLAPD_F (void) attr_free LDAP_P(( Attribute *a ));
LIBSLAPD_F (Attribute *) attr_dup LDAP_P(( Attribute *a ));
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
LIBSLAPD_F (int) attr_merge LDAP_P(( Entry *e,
AttributeDescription *desc,
struct berval **vals ));
LIBSLAPD_F (Attribute *) attrs_find LDAP_P(( Attribute *a, AttributeDescription *desc ));
LIBSLAPD_F (Attribute *) attr_find LDAP_P(( Attribute *a, AttributeDescription *desc ));
LIBSLAPD_F (int) attr_delete LDAP_P(( Attribute **attrs, AttributeDescription *desc ));
-#else
-LIBSLAPD_F (char *) attr_normalize LDAP_P(( char *s ));
-LIBSLAPD_F (int) attr_merge LDAP_P(( Entry *e, const char *type,
- struct berval **vals ));
-LIBSLAPD_F (int) attr_merge_fast LDAP_P(( Entry *e, const char *type,
- struct berval **vals, int nvals, int naddvals, int *maxvals,
- Attribute ***a ));
-LIBSLAPD_F (Attribute *) attr_find LDAP_P(( Attribute *a, const char *type ));
-LIBSLAPD_F (int) attr_delete LDAP_P(( Attribute **attrs, const char *type ));
-LIBSLAPD_F (int) attr_syntax LDAP_P(( const char *type ));
-#endif
LIBSLAPD_F (void) attrs_free LDAP_P(( Attribute *a ));
LIBSLAPD_F (Attribute *) attrs_dup LDAP_P(( Attribute *a ));
/*
* ava.c
*/
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
LIBSLAPD_F (int) get_ava LDAP_P((
BerElement *ber,
AttributeAssertion **ava,
LIBSLAPD_F (void) ava_free LDAP_P((
AttributeAssertion *ava,
int freeit ));
-#else
-LIBSLAPD_F (int) get_ava LDAP_P((
- BerElement *ber,
- Ava *ava,
- const char **text ));
-LIBSLAPD_F (void) ava_free LDAP_P(( Ava *ava, int freeit ));
-#endif
/*
* backend.c
LIBSLAPD_F (int) backend_connection_init LDAP_P((Connection *conn));
LIBSLAPD_F (int) backend_connection_destroy LDAP_P((Connection *conn));
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
LIBSLAPD_F (int) backend_group LDAP_P((Backend *be,
Entry *target,
const char *gr_ndn,
ObjectClass *group_oc,
AttributeDescription *group_at
));
-#else
-LIBSLAPD_F (int) backend_group LDAP_P((Backend *be,
- Entry *target,
- const char *gr_ndn,
- const char *op_ndn,
- const char *group_oc,
- const char *group_at
-));
-#endif
LIBSLAPD_F (Attribute *) backend_operational( Backend *, Entry * );
LIBSLAPD_F( void ) slap_mods_free LDAP_P(( Modifications *mods ));
LIBSLAPD_F( void ) slap_modlist_free LDAP_P(( LDAPModList *ml ));
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
LIBSLAPD_F( int ) slap_modlist2mods(
LDAPModList *ml,
int update,
Operation *op,
Modifications **modlist,
const char **text );
-#endif
/*
* module.c
* schema.c
*/
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
-LIBSLAPD_F (int) oc_check_op_attr LDAP_P(( const char *type ));
-LIBSLAPD_F (int) oc_check_op_usermod_attr LDAP_P(( const char *type ));
-LIBSLAPD_F (int) oc_check_op_no_usermod_attr LDAP_P(( const char *type ));
-#endif
LIBSLAPD_F (ObjectClass *) oc_find LDAP_P((
const char *ocname));
LIBSLAPD_F (int) schema_info LDAP_P(( Entry **entry, const char **text ));
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
LIBSLAPD_F (int) is_entry_objectclass LDAP_P((
Entry *, ObjectClass *oc ));
#define is_entry_alias(e) is_entry_objectclass((e), slap_schema.si_oc_alias)
#define is_entry_referral(e) is_entry_objectclass((e), slap_schema.si_oc_referral)
-#else
-LIBSLAPD_F (int) is_entry_objectclass LDAP_P((
- Entry *, const char* objectclass ));
-#define is_entry_alias(e) is_entry_objectclass((e), "ALIAS")
-#define is_entry_referral(e) is_entry_objectclass((e), "REFERRAL")
-#endif
/*
* schema_check.c
*/
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
int oc_check_allowed(
AttributeType *type,
struct berval **oclist );
-#endif
LIBSLAPD_F (int) entry_schema_check LDAP_P((
Entry *e, Attribute *attrs,
const char** text ));
/*
* value.c
*/
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
LIBSLAPD_F (int) value_normalize LDAP_P((
AttributeDescription *ad,
unsigned usage,
AttributeDescription *ad,
struct berval **values,
struct berval *value ));
-#else
-LIBSLAPD_F (int) value_add_fast LDAP_P(( struct berval ***vals, struct berval **addvals, int nvals, int naddvals, int *maxvals ));
-LIBSLAPD_F (void) value_normalize LDAP_P(( char *s, int syntax ));
-LIBSLAPD_F (int) value_cmp LDAP_P(( struct berval *v1, struct berval *v2, int syntax, int normalize ));
-LIBSLAPD_F (int) value_find LDAP_P(( struct berval **vals, struct berval *v, int syntax, int normalize ));
-#endif
LIBSLAPD_F (int) value_add LDAP_P(( struct berval ***vals, struct berval **addvals ));
/*
ml = change;
for ( ; ml != NULL; ml = ml->sml_next ) {
char *type;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
type = ml->sml_desc->ad_cname->bv_val;
-#else
- type = ml->sml_type;
-#endif
switch ( ml->sml_op ) {
case LDAP_MOD_ADD:
fprintf( fp, "add: %s\n", type );
struct berval **refs;
unsigned i, j;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *ad_ref = slap_schema.si_ad_ref;
-#else
- static const char *ad_ref = "ref";
-#endif
attr = attr_find( e->e_attrs, ad_ref );
int userattrs;
int opattrs;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *ad_entry = slap_schema.si_ad_entry;
-#else
- static const char *ad_entry = "entry";
-#endif
Debug( LDAP_DEBUG_TRACE, "=> send_search_entry: \"%s\"\n", e->e_dn, 0, 0 );
: charray_inlist( attrs, LDAP_ALL_OPERATIONAL_ATTRIBUTES );
for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *desc = a->a_desc;
char *type = desc->ad_cname->bv_val;
-#else
- char *desc = a->a_type;
- char *type = a->a_type;
-#endif
if ( attrs == NULL ) {
/* all addrs request, skip operational attributes */
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
if( is_at_operational( desc->ad_type ) )
-#else
- if( oc_check_op_attr( desc ) )
-#endif
{
continue;
}
} else {
/* specific addrs requested */
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
if ( is_at_operational( desc->ad_type ) )
-#else
- if ( oc_check_op_attr( desc ) )
-#endif
{
if( !opattrs && !ad_inlist( desc, attrs ) ) {
continue;
aa = backend_operational( be, e );
for (a = aa ; a == NULL; a = a->a_next ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *desc = a->a_desc;
-#else
- char *desc = a->a_type;
-#endif
if ( attrs == NULL ) {
/* all addrs request, skip operational attributes */
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
if( is_at_operational( desc->ad_type ) )
-#else
- if( oc_check_op_attr( desc ) )
-#endif
{
continue;
}
} else {
/* specific addrs requested */
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
if( is_at_operational( desc->ad_type ) )
-#else
- if( oc_check_op_attr( desc ) )
-#endif
{
if( !opattrs && !ad_inlist( desc, attrs ) )
{
int rc;
int bytes;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *ad_ref = slap_schema.si_ad_ref;
AttributeDescription *ad_entry = slap_schema.si_ad_entry;
-#else
- static const char *ad_ref = "ref";
- static const char *ad_entry = "entry";
-#endif
Debug( LDAP_DEBUG_TRACE, "=> send_search_reference (%s)\n", e->e_dn, 0, 0 );
struct berval *vals[2];
int i, j;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
AttributeDescription *ad_namingContexts = slap_schema.si_ad_namingContexts;
AttributeDescription *ad_supportedControl = slap_schema.si_ad_supportedControl;
AttributeDescription *ad_supportedLDAPVersion = slap_schema.si_ad_supportedLDAPVersion;
AttributeDescription *ad_supportedSASLMechanisms = slap_schema.si_ad_supportedSASLMechanisms;
AttributeDescription *ad_ref = slap_schema.si_ad_ref;
-#else
- char *ad_objectClass = "objectClass";
- char *ad_namingContexts = "namingContexts";
- char *ad_supportedControl = "supportedControl";
- char *ad_supportedExtension = "supportedExtension";
- char *ad_supportedLDAPVersion = "supportedLDAPVersion";
- char *ad_supportedSASLMechanisms = "supportedSASLMechanisms";
- char *ad_ref = "ref";
-#endif
vals[0] = &val;
vals[1] = NULL;
int
schema_info( Entry **entry, const char **text )
{
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
-#else
- char *ad_objectClass = "objectClass";
-#endif
Entry *e;
struct berval val;
attr_merge( e, ad_objectClass, vals );
{
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
int rc;
AttributeDescription *desc = NULL;
-#else
- char *desc;
-#endif
char *rdn = ch_strdup( SLAPD_SCHEMA_DN );
val.bv_val = strchr( rdn, '=' );
*val.bv_val = '\0';
val.bv_len = strlen( ++val.bv_val );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
rc = slap_str2ad( rdn, &desc, text );
if( rc != LDAP_SUCCESS ) {
*text = "improperly configured subschema subentry";
return LDAP_OTHER;
}
-#else
- desc = rdn;
-#endif
attr_merge( e, desc, vals );
free( rdn );
#include "slap.h"
#include "ldap_pvt.h"
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
-static int oc_check_allowed(char *type, struct berval **oclist);
-#endif
static char * oc_check_required(Entry *e, struct berval *ocname);
/*
ObjectClass *oc;
int i;
int ret;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
-#else
- static const char *ad_objectClass = "objectclass";
-#endif
int extensible = 0;
if( !global_schemacheck ) return LDAP_SUCCESS;
break;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
if( oc == slap_schema.si_oc_extensibleObject )
-#else
- if( !strcmp( aoc->a_vals[i]->bv_val, "extensibleObject" ) == 0 )
-#endif
{
extensible=1;
}
/* check that each attr in the entry is allowed by some oc */
for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
ret = oc_check_allowed( a->a_desc->ad_type, aoc->a_vals );
-#else
- ret = oc_check_allowed( a->a_type, aoc->a_vals );
-#endif
if ( ret != 0 ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
char *type = a->a_desc->ad_cname->bv_val;
-#else
- char *type = a->a_type;
-#endif
Debug( LDAP_DEBUG_ANY,
"Entry (%s), attr \"%s\" not allowed\n",
e->e_dn, type, 0 );
at = oc->soc_required[i];
/* see if it's in the entry */
for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
if( a->a_desc->ad_type == at ) {
break;
}
-#else
- char **pp;
-
- if ( at->sat_oid &&
- strcmp( a->a_type, at->sat_oid ) == 0 ) {
- break;
- }
- pp = at->sat_names;
- if ( pp == NULL ) {
- /* Empty name list => not found */
- a = NULL;
- break;
- }
- while ( *pp ) {
- if ( strcasecmp( a->a_type, *pp ) == 0 ) {
- break;
- }
- pp++;
- }
- if ( *pp ) {
- break;
- }
-#endif
}
/* not there => schema violation */
if ( a == NULL ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
return at->sat_cname;
-#else
- if ( at->sat_names && at->sat_names[0] ) {
- return at->sat_names[0];
- } else {
- return at->sat_oid;
- }
-#endif
}
}
return( NULL );
}
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
-static
-#endif
int oc_check_allowed(
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeType *at,
-#else
- char *type,
-#endif
struct berval **ocl )
{
ObjectClass *oc;
int i, j;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
Debug( LDAP_DEBUG_TRACE,
"oc_check_allowed type \"%s\"\n",
at->sat_cname, 0, 0 );
return LDAP_SUCCESS;
}
-#else
- AttributeType *at;
- char **pp;
- char *p;
- char *t;
-
- Debug( LDAP_DEBUG_TRACE,
- "oc_check_allowed type \"%s\"\n", type, 0, 0 );
-
- /* always allow objectclass attribute */
- if ( strcasecmp( type, "objectclass" ) == 0 ) {
- return LDAP_SUCCESS;
- }
-#endif
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
/*
* All operational attributions are allowed by schema rules.
*/
if( is_at_operational(at) ) {
return LDAP_SUCCESS;
}
-#else
- /*
- * The "type" we have received is actually an AttributeDescription.
- * Let's find out the corresponding type.
- */
- p = strchr( type, ';' );
- if ( p ) {
- t = ch_malloc( p-type+1 );
- strncpy( t, type, p-type );
- t[p-type] = '\0';
- Debug( LDAP_DEBUG_TRACE,
- "oc_check_allowed type \"%s\" from \"%s\"\n",
- t, type, 0 );
-
- } else
- {
- t = type;
- }
-
- /*
- * All operational attributions are allowed by schema rules.
- */
- if ( oc_check_op_attr( t ) ) {
- return LDAP_SUCCESS;
- }
-#endif
/* check that the type appears as req or opt in at least one oc */
for ( i = 0; ocl[i] != NULL; i++ ) {
for ( j = 0; oc->soc_required != NULL &&
oc->soc_required[j] != NULL; j++ )
{
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
if( at == oc->soc_required[j] ) {
return LDAP_SUCCESS;
}
-#else
- at = oc->soc_required[j];
- if ( at->sat_oid &&
- strcmp(at->sat_oid, t ) == 0 ) {
- if ( t != type )
- ldap_memfree( t );
- return LDAP_SUCCESS;
- }
- pp = at->sat_names;
- if ( pp == NULL )
- continue;
- while ( *pp ) {
- if ( strcasecmp( *pp, t ) == 0 ) {
- if ( t != type )
- ldap_memfree( t );
- return LDAP_SUCCESS;
- }
- pp++;
- }
-#endif
}
/* does it allow the type? */
for ( j = 0; oc->soc_allowed != NULL &&
oc->soc_allowed[j] != NULL; j++ )
{
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
if( at == oc->soc_allowed[j] ) {
return LDAP_SUCCESS;
}
-#else
- at = oc->soc_allowed[j];
- if ( at->sat_oid &&
- strcmp( at->sat_oid, t ) == 0 ) {
- if ( t != type )
- ldap_memfree( t );
- return LDAP_SUCCESS;
- }
- pp = at->sat_names;
- if ( pp == NULL )
- continue;
- while ( *pp ) {
- if ( strcasecmp( *pp, t ) == 0 ||
- strcmp( *pp, "*" ) == 0 ) {
- if ( t != type )
- ldap_memfree( t );
- return LDAP_SUCCESS;
- }
- pp++;
- }
-#endif
}
/* maybe the next oc allows it */
}
}
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- if ( t != type )
- ldap_memfree( t );
-#endif
/* not allowed by any oc */
return LDAP_OBJECT_CLASS_VIOLATION;
return LDAP_SUCCESS;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
static int
caseExactIA5SubstringsMatch(
int *matchp,
*matchp = match;
return LDAP_SUCCESS;
}
-#endif
static int
caseIgnoreIA5Match(
return LDAP_SUCCESS;
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
static char *strcasechr( const char *str, int c )
{
char *lower = strchr( str, TOLOWER(c) );
*matchp = match;
return LDAP_SUCCESS;
}
-#endif
/* Index generation function */
int caseIgnoreIA5Indexer(
* 2.5.13.44 attributeIntegrityMatch
*/
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
-#define caseIgnoreIA5SubstringsMatch NULL
-#define caseExactIA5SubstringsMatch NULL
-#endif
/* recycled matching functions */
#define caseIgnoreMatch caseIgnoreIA5Match
int schema_init_done = 0;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
struct slap_internal_schema slap_schema;
static int
{ NULL, NULL, 0 }
};
-#endif
int
schema_prep( void )
{
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
int i;
-#endif
/* we should only be called once after schema_init() was called */
assert( schema_init_done == 1 );
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
for( i=0; oc_map[i].ssom_name; i++ ) {
ObjectClass ** ocp = (ObjectClass **)
&(((char *) &slap_schema)[oc_map[i].ssom_offset]);
(*adp)->ad_type->sat_equality->smr_match = ad_map[i].ssam_match;
}
}
-#endif
++schema_init_done;
return LDAP_SUCCESS;
int global_schemacheck = 1; /* schemacheck on is default */
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
-static void oc_usage_old(void) LDAP_GCCATTR((noreturn));
-#endif
static void oc_usage(void) LDAP_GCCATTR((noreturn));
static void at_usage(void) LDAP_GCCATTR((noreturn));
}
}
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
-void
-parse_oc_old(
- Backend *be,
- const char *fname,
- int lineno,
- int argc,
- char **argv
-)
-{
- int i;
- char last;
- LDAP_OBJECT_CLASS *oc;
- int code;
- const char *err;
- char **namep;
-
- oc = (LDAP_OBJECT_CLASS *) ch_calloc( 1, sizeof(LDAP_OBJECT_CLASS) );
- oc->oc_names = ch_calloc( 2, sizeof(char *) );
- oc->oc_names[0] = ch_strdup( argv[1] );
- oc->oc_names[1] = NULL;
-
- if ( strcasecmp( oc->oc_names[0], "top" ) ) {
- /*
- * no way to distinguish "auxiliary" from "structural"
- * This may lead to future problems.
- */
- oc->oc_kind = LDAP_SCHEMA_STRUCTURAL;
- }
- for ( i = 2; i < argc; i++ ) {
- /* required attributes */
- if ( strcasecmp( argv[i], "requires" ) == 0 ) {
- do {
- i++;
- if ( i < argc ) {
- char **s = str2charray( argv[i], "," );
- last = argv[i][strlen( argv[i] ) - 1];
- charray_merge( &oc->oc_at_oids_must, s );
- charray_free( s );
- }
- } while ( i < argc && last == ',' );
-
- /* optional attributes */
- } else if ( strcasecmp( argv[i], "allows" ) == 0 ) {
- do {
- i++;
- if ( i < argc ) {
- char **s = str2charray( argv[i], "," );
- last = argv[i][strlen( argv[i] ) - 1];
-
- charray_merge( &oc->oc_at_oids_may, s );
- charray_free( s );
- }
- } while ( i < argc && last == ',' );
-
- } else {
- fprintf( stderr,
- "%s: line %d: expecting \"requires\" or \"allows\" got \"%s\"\n",
- fname, lineno, argv[i] );
- oc_usage_old();
- }
- }
-
- /*
- * There was no requirement in the old schema that all attributes
- * types were defined before use and they would just default to
- * SYNTAX_CIS. To support this, we need to make attribute types
- * out of thin air.
- */
- if ( oc->oc_at_oids_must ) {
- for( namep = oc->oc_at_oids_must; *namep ; namep++ ) {
- code = at_fake_if_needed( *namep );
- if ( code ) {
- fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
- fname, lineno, scherr2str(code), *namep);
- exit( EXIT_FAILURE );
- }
- }
- }
- if ( oc->oc_at_oids_may ) {
- for( namep = oc->oc_at_oids_may; *namep; namep++ ) {
- code = at_fake_if_needed( *namep );
- if ( code ) {
- fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
- fname, lineno, scherr2str(code), *namep);
- exit( EXIT_FAILURE );
- }
- }
- }
-
- code = oc_add(oc,&err);
- if ( code ) {
- fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
- fname, lineno, scherr2str(code), err);
- exit( EXIT_FAILURE );
- }
- ldap_memfree(oc);
-}
-#endif
/* OID Macros */
exit( EXIT_FAILURE );
}
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
-static void
-oc_usage_old( void )
-{
- fprintf( stderr, "<oc clause> ::= objectclass <ocname>\n" );
- fprintf( stderr, " [ requires <attrlist> ]\n" );
- fprintf( stderr, " [ allows <attrlist> ]\n" );
- exit( EXIT_FAILURE );
-}
-#endif
static void
at_usage( void )
if ( attrs != NULL ) {
for ( i = 0; attrs[i] != NULL; i++ ) {
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- attr_normalize( attrs[i] );
-#endif
Debug( LDAP_DEBUG_ARGS, " %s", attrs[i], 0, 0 );
}
}
} MatchingRule;
typedef struct slap_attribute_type {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
char *sat_cname;
-#endif
LDAP_ATTRIBUTE_TYPE sat_atype;
struct slap_attribute_type *sat_sup;
struct slap_attribute_type **sat_subtypes;
MatchingRule *sat_ordering;
MatchingRule *sat_substr;
Syntax *sat_syntax;
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- /* The next one is created to help in the transition */
- int sat_syntax_compat;
-#endif
struct slap_attribute_type *sat_next;
#define sat_oid sat_atype.at_oid
#define sat_names sat_atype.at_names
} ObjectClass;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
/*
* represents a recognized attribute description ( type + options )
*/
struct berval *ma_value; /* required */
} MatchingRuleAssertion;
-#else
-
-/*
- * represents an attribute value assertion (i.e., attr;option=value)
- */
-typedef struct slap_ava {
- char *ava_type; /* attribute description */
- struct berval ava_value;
-} Ava;
-
-/*
- * represents an matching rule assertion
- */
-typedef struct slap_mra {
- char *mra_rule; /* optional */
- char *mra_type; /* attribute description -- optional */
- int mra_dnattrs;
- struct berval *mra_value;
-} Mra;
-
-#endif
/*
* represents a search filter
/* precomputed result */
ber_int_t f_un_result;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
/* DN */
char *f_un_dn;
#define f_mr_desc f_un.f_un_mra->ma_desc
#define f_mr_value f_un.f_un_mra->ma_value
#define f_mr_dnaddrs f_un.f_un_mra->ma_dnattrs
-#else
- /* present */
- char *f_un_type;
-
- /* equality, lessorequal, greaterorequal, approx */
- Ava f_un_ava;
-
- /* extensible */
- Mra f_un_fra;
-
- /* substrings */
- struct sub {
- char *f_un_sub_type;
-
- struct berval *f_un_sub_initial;
- struct berval **f_un_sub_any;
- struct berval *f_un_sub_final;
- } f_un_sub;
-
-#define f_dn f_un.f_un_type /* used for DN indices */
-#define f_type f_un.f_un_type
-#define f_desc f_type
-#define f_ava f_un.f_un_ava
-#define f_avtype f_un.f_un_ava.ava_type
-#define f_avvalue f_un.f_un_ava.ava_value
-#define f_mra f_un.f_un_mra
-#define f_mrtype f_un.f_un_mra.mra_type
-#define f_mrvalue f_un.f_un_mra.mra_value
-#define f_mrdnaddrs f_un.f_un_mra.mra_dnattrs
-#define f_sub f_un.f_un_sub
-#define f_sub_type f_un.f_un_sub.f_un_sub_type
-#define f_sub_desc f_sub_type
-#define f_sub_initial f_un.f_un_sub.f_un_sub_initial
-#define f_sub_any f_un.f_un_sub.f_un_sub_any
-#define f_sub_final f_un.f_un_sub.f_un_sub_final
-#endif
/* and, or, not */
struct slap_filter *f_un_complex;
* represents an attribute (description + values)
*/
typedef struct slap_attr {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *a_desc;
-#else
- char *a_type; /* description */
- int a_syntax;
-#endif
struct berval **a_vals;
struct slap_attr *a_next;
} Attribute;
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
-/*
- * the attr_syntax() routine returns one of these values
- * telling what kind of syntax an attribute supports.
- */
-#define SYNTAX_CIS 0x01 /* case insensitive string */
-#define SYNTAX_CES 0x02 /* case sensitive string */
-#define SYNTAX_BIN 0x04 /* binary data */
-#define SYNTAX_TEL 0x08 /* telephone number string */
-#define SYNTAX_DN 0x10 /* dn string */
-#endif
/*
* the id used in the indexes to refer to an entry
/*
* A list of LDAPMods
*/
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
typedef struct slap_mod {
int sm_op;
AttributeDescription *sm_desc;
struct berval **sm_bvalues;
} Modification;
-#else
-#define Modification LDAPMod
-#define sm_op mod_op
-#define sm_desc mod_type
-#define sm_bvalues mod_bvalues
-#endif
typedef struct slap_mod_list {
Modification sml_mod;
#define sml_op sml_mod.sm_op
#define sml_desc sml_mod.sm_desc
#define sml_bvalues sml_mod.sm_bvalues
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
-#define sml_type sml_mod.sm_desc
-#endif
struct slap_mod_list *sml_next;
} Modifications;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
typedef struct slap_ldap_modlist {
LDAPMod ml_mod;
struct slap_ldap_modlist *ml_next;
#define ml_values ml_mod.mod_values
#define ml_bvalues ml_mod.mod_bvalues
} LDAPModList;
-#else
-#define LDAPModList Modifications
-#define ml_mod sml_mod
-#define ml_op sml_mod.mod_op
-#define ml_type sml_mod.mod_type
-#define ml_values sml_mod.mod_values
-#define ml_bvalues sml_mod.mod_bvalues
-#define ml_next sml_next
-#endif
/*
* represents an access control list
slap_access_mask_t a_mask;
char *a_dn_pat;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *a_dn_at;
-#else
- char *a_dn_at;
-#endif
int a_dn_self;
char *a_peername_pat;
char *a_sockurl_pat;
#ifdef SLAPD_ACI_ENABLED
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *a_aci_at;
-#else
- char *a_aci_at;
-#endif
#endif
/* ACL Groups */
char *a_group_pat;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
ObjectClass *a_group_oc;
AttributeDescription *a_group_at;
-#else
- char *a_group_oc;
- char *a_group_at;
-#endif
struct slap_access *a_next;
} Access;
int slimit, int tlimit,
Filter *f, const char *filterstr,
char **attrs, int attrsonly));
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
int (*bi_op_compare)LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
const char *dn, const char *ndn,
AttributeAssertion *ava));
-#else
- int (*bi_op_compare)LDAP_P((BackendDB *bd,
- struct slap_conn *c, struct slap_op *o,
- const char *dn, const char *ndn,
- Ava *ava));
-#endif
int (*bi_op_modify) LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
const char *dn, const char *ndn, Modifications *m));
/* Auxilary Functions */
int (*bi_entry_release_rw) LDAP_P((BackendDB *bd, Entry *e, int rw));
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
int (*bi_acl_group) LDAP_P((Backend *bd,
Entry *e, const char *bdn, const char *edn,
ObjectClass *group_oc,
AttributeDescription *group_at ));
-#else
- int (*bi_acl_group) LDAP_P((Backend *bd,
- Entry *e, const char *bdn, const char *edn,
- const char *group_oc,
- const char *group_at ));
-#endif
int (*bi_connection_init) LDAP_P((BackendDB *bd,
struct slap_conn *c));
ID (*bi_tool_entry_next) LDAP_P(( BackendDB *be ));
Entry* (*bi_tool_entry_get) LDAP_P(( BackendDB *be, ID id ));
ID (*bi_tool_entry_put) LDAP_P(( BackendDB *be, Entry *e ));
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
int (*bi_tool_index_attr) LDAP_P(( BackendDB *be,
AttributeDescription *desc ));
int (*bi_tool_index_change) LDAP_P(( BackendDB *be,
AttributeDescription *desc,
struct berval **bv, ID id, int op ));
-#else
- int (*bi_tool_index_attr) LDAP_P(( BackendDB *be,
- char* type ));
- int (*bi_tool_index_change) LDAP_P(( BackendDB *be,
- char* type,
- struct berval **bv, ID id, int op ));
-#endif
int (*bi_tool_sync) LDAP_P(( BackendDB *be ));
#ifdef HAVE_CYRUS_SASL
Filter *f;
char *s;
char *value, savechar;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
int rc;
const char *text;
-#endif
Debug( LDAP_DEBUG_FILTER, "str2simple \"%s\"\n", str, 0, 0 );
f->f_choice = LDAP_FILTER_PRESENT;
} else {
f->f_choice = LDAP_FILTER_SUBSTRINGS;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
f->f_sub = ch_calloc( 1, sizeof( SubstringsAssertion ) );
rc = slap_str2ad( str, &f->f_sub_desc, &text );
if( rc != LDAP_SUCCESS ) {
*(value-1) = '=';
return NULL;
}
-#else
- f->f_sub_type = ch_strdup( str );
-#endif
if ( str2subvals( value, f ) != 0 ) {
filter_free( f );
*(value-1) = '=';
}
if ( f->f_choice == LDAP_FILTER_PRESENT ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
rc = slap_str2ad( str, &f->f_desc, &text );
if( rc != LDAP_SUCCESS ) {
filter_free( f );
*(value-1) = '=';
return NULL;
}
-#else
- f->f_type = ch_strdup( str );
-#endif
} else {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
char *tmp;
f->f_ava = ch_calloc( 1, sizeof( AttributeAssertion ) );
tmp = ch_strdup( value );
ldap_pvt_filter_value_unescape( tmp );
f->f_av_value = ber_bvstr( tmp );
-#else
- f->f_avtype = ch_strdup( str );
- f->f_avvalue.bv_val = ch_strdup( value );
- ldap_pvt_filter_value_unescape( f->f_avvalue.bv_val );
- f->f_avvalue.bv_len = strlen( value );
-#endif
}
*s = savechar;
struct berval *vals[2];
Syntax *syn;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *ad_ldapSyntaxes = slap_schema.si_ad_ldapSyntaxes;
-#else
- char *ad_ldapSyntaxes = "ldapSyntaxes";
-#endif
vals[0] = &val;
vals[1] = NULL;
main( int argc, char **argv )
{
char *type;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription *desc;
const char *text;
-#else
- char *desc;
-#endif
ID id;
int rc = EXIT_SUCCESS;
exit( EXIT_FAILURE );
}
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
type = argv[argc - 1];
rc = slap_str2ad( type, &desc, &text );
progname, text );
exit( EXIT_FAILURE );
}
-#else
- desc = type = attr_normalize( argv[argc - 1] );
-#endif
if ( !be->be_index_attr( be, desc ) ) {
fprintf( stderr, "attribute type \"%s\": no indices to generate\n",
id, e->e_dn );
}
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
- if( strcasecmp( type, "dn" ) == 0 )
- {
- struct berval **values;
- struct berval bv;
- struct berval *bvals[2];
-
- bv.bv_val = e->e_ndn;
- bv.bv_len = strlen( bv.bv_val );
- bvals[0] = &bv;
- bvals[1] = NULL;
-
- values = bvals;
-
- if ( be->be_index_change( be,
- desc, values, id, SLAP_INDEX_ADD_OP ) )
- {
- rc = EXIT_FAILURE;
-
- if( !continuemode ) {
- entry_free( e );
- break;
- }
- }
-
- } else
-#endif
{
Attribute *attr;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
for( attr = attrs_find( e->e_attrs, desc );
attr != NULL;
attr = attrs_find( attr->a_next, desc ) )
-#else
- if (( attr = attr_find( e->e_attrs, type )) != NULL )
-#endif
{
if ( be->be_index_change( be,
return LDAP_SUCCESS;
}
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
-int
-value_add_fast(
- struct berval ***vals,
- struct berval **addvals,
- int nvals,
- int naddvals,
- int *maxvals
-)
-{
- int need, i, j;
-
- if ( *maxvals == 0 ) {
- *maxvals = 1;
- }
- need = nvals + naddvals + 1;
- while ( *maxvals < need ) {
- *maxvals *= 2;
- *vals = (struct berval **) ch_realloc( (char *) *vals,
- *maxvals * sizeof(struct berval *) );
- }
-
- for ( i = 0, j = 0; i < naddvals; i++ ) {
- if ( addvals[i]->bv_len > 0 ) {
- (*vals)[nvals + j] = ber_bvdup( addvals[i] );
- if( (*vals)[nvals + j] != NULL ) j++;
- }
- }
- (*vals)[nvals + j] = NULL;
-
- return( 0 );
-}
-#endif
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
int
value_normalize(
AttributeDescription *ad,
return LDAP_SUCCESS;
}
-#else
-void
-value_normalize(
- char *s,
- int syntax
-)
-{
- char *d, *save;
-
- if ( ! (syntax & SYNTAX_CIS) ) {
- return;
- }
-
- if ( syntax & SYNTAX_DN ) {
- (void) dn_normalize( s );
- return;
- }
-
- save = s;
- for ( d = s; *s; s++ ) {
- if ( (syntax & SYNTAX_TEL) && (*s == ' ' || *s == '-') ) {
- continue;
- }
- *d++ = TOUPPER( (unsigned char) *s );
- }
- *d = '\0';
-}
-#endif
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
int
value_match(
int *match,
return rc;
}
-#else
-int
-value_cmp(
- struct berval *v1,
- struct berval *v2,
- int syntax,
- int normalize /* 1 => arg 1; 2 => arg 2; 3 => both */
-)
-{
- int rc;
-
- if ( normalize & 1 ) {
- v1 = ber_bvdup( v1 );
- value_normalize( v1->bv_val, syntax );
- }
- if ( normalize & 2 ) {
- v2 = ber_bvdup( v2 );
- value_normalize( v2->bv_val, syntax );
- }
-
- switch ( syntax ) {
- case SYNTAX_CIS:
- case (SYNTAX_CIS | SYNTAX_TEL):
- case (SYNTAX_CIS | SYNTAX_DN):
- rc = strcasecmp( v1->bv_val, v2->bv_val );
- break;
-
- case SYNTAX_CES:
- rc = strcmp( v1->bv_val, v2->bv_val );
- break;
-
- default: /* Unknown syntax */
- case SYNTAX_BIN:
- rc = (v1->bv_len == v2->bv_len
- ? memcmp( v1->bv_val, v2->bv_val, v1->bv_len )
- : v1->bv_len > v2->bv_len ? 1 : -1);
- break;
- }
- if ( normalize & 1 ) {
- ber_bvfree( v1 );
- }
- if ( normalize & 2 ) {
- ber_bvfree( v2 );
- }
-
- return( rc );
-}
-#endif
-
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
int value_find(
AttributeDescription *ad,
struct berval **vals,
struct berval *val )
-#else
-int
-value_find(
- struct berval **vals,
- struct berval *v,
- int syntax,
- int normalize )
-#endif
{
int i;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
int rc;
struct berval *nval = NULL;
MatchingRule *mr = ad->ad_type->sat_equality;
return LDAP_INAPPROPRIATE_MATCHING;
}
}
-#endif
for ( i = 0; vals[i] != NULL; i++ ) {
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
int match;
const char *text;
nval == NULL ? val : nval, &text );
if( rc == LDAP_SUCCESS && match == 0 )
-#else
- if ( value_cmp( vals[i], v, syntax, normalize ) == 0 )
-#endif
{
return LDAP_SUCCESS;
}