From: Kurt Zeilenga Date: Mon, 7 Feb 2000 20:37:10 +0000 (+0000) Subject: Add Modification/Modifications structures for -DSLAPD_SCHEMA_NOT_COMPAT X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~3194 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=36b042331107d0d496479e8f5396876b77f139df;p=openldap Add Modification/Modifications structures for -DSLAPD_SCHEMA_NOT_COMPAT --- diff --git a/servers/slapd/acl.c b/servers/slapd/acl.c index f5c141bc4a..e026af3d2c 100644 --- a/servers/slapd/acl.c +++ b/servers/slapd/acl.c @@ -617,7 +617,7 @@ acl_check_modlist( Connection *conn, Operation *op, Entry *e, - LDAPModList *mlist + Modifications *mlist ) { int i; @@ -660,6 +660,9 @@ acl_check_modlist( * by ACL_WRITE checking as any found here are not provided * by the user */ +#ifdef SLAPD_SCHEMA_NOT_COMPAT + /* not yet implemented */ +#else if ( oc_check_op_no_usermod_attr( mlist->ml_type ) ) { Debug( LDAP_DEBUG_ACL, "NoUserMod Operational attribute:" " modify access granted\n", @@ -667,7 +670,7 @@ acl_check_modlist( continue; } - switch ( mlist->ml_op & ~LDAP_MOD_BVALUES ) { + switch ( mlist->ml_op ) { case LDAP_MOD_REPLACE: case LDAP_MOD_ADD: if ( mlist->ml_bvalues == NULL ) { @@ -703,6 +706,7 @@ acl_check_modlist( } break; } +#endif } return( 1 ); diff --git a/servers/slapd/back-bdb2/external.h b/servers/slapd/back-bdb2/external.h index dad989377a..230302d2bd 100644 --- a/servers/slapd/back-bdb2/external.h +++ b/servers/slapd/back-bdb2/external.h @@ -39,7 +39,7 @@ extern int bdb2_back_compare LDAP_P((BackendDB *bd, extern int bdb2_back_modify LDAP_P(( BackendDB *bd, Connection *conn, Operation *op, - char *dn, char *ndn, LDAPModList *ml )); + char *dn, char *ndn, Modifications *ml )); extern int bdb2_back_modrdn LDAP_P(( BackendDB *bd, Connection *conn, Operation *op, diff --git a/servers/slapd/back-bdb2/proto-back-bdb2.h b/servers/slapd/back-bdb2/proto-back-bdb2.h index d0b8614b42..2e16fd468a 100644 --- a/servers/slapd/back-bdb2/proto-back-bdb2.h +++ b/servers/slapd/back-bdb2/proto-back-bdb2.h @@ -144,7 +144,7 @@ ID bdb2i_idl_nextid LDAP_P(( ID_BLOCK *idl, ID *cursor )); */ int bdb2i_index_add_entry LDAP_P(( BackendDB *be, Entry *e )); -int bdb2i_index_add_mods LDAP_P(( BackendDB *be, LDAPModList *ml, ID id )); +int bdb2i_index_add_mods LDAP_P(( BackendDB *be, Modifications *ml, ID id )); ID_BLOCK * bdb2i_index_read LDAP_P(( BackendDB *be, char *type, int indextype, char *val )); int bdb2i_index_add_values LDAP_P(( BackendDB *be, char *type, struct berval **vals, ID id )); @@ -172,7 +172,7 @@ int bdb2i_add_values LDAP_P(( Entry *e, LDAPMod *mod, char *dn )); int bdb2i_delete_values LDAP_P(( Entry *e, LDAPMod *mod, char *dn )); int bdb2i_replace_values LDAP_P(( Entry *e, LDAPMod *mod, char *dn )); int bdb2i_back_modify_internal LDAP_P((Backend *be, Connection *conn, Operation *op, - char *dn, LDAPModList *mods, Entry *e)); + char *dn, Modifications *mods, Entry *e)); /* * nextid.c */ @@ -232,7 +232,7 @@ void bdb2i_check_default_attr_index_add LDAP_P(( Entry *e )); void bdb2i_check_default_attr_index_mod LDAP_P(( struct ldbminfo *li, - LDAPModList *modlist )); + Modifications *modlist )); ID bdb2i_get_nextid LDAP_P(( BackendDB *be )); int bdb2i_put_nextid LDAP_P(( BackendDB *be, ID id )); LDBM bdb2i_db_open LDAP_P(( char *name, int type, int rw, int mode, diff --git a/servers/slapd/back-ldap/external.h b/servers/slapd/back-ldap/external.h index 7493c816cd..2cdf751f5c 100644 --- a/servers/slapd/back-ldap/external.h +++ b/servers/slapd/back-ldap/external.h @@ -34,7 +34,7 @@ extern int ldap_back_compare LDAP_P((BackendDB *bd, extern int ldap_back_modify LDAP_P(( BackendDB *bd, Connection *conn, Operation *op, - char *dn, char *ndn, LDAPModList *ml )); + char *dn, char *ndn, Modifications *ml )); extern int ldap_back_modrdn LDAP_P(( BackendDB *bd, Connection *conn, Operation *op, diff --git a/servers/slapd/back-ldbm/external.h b/servers/slapd/back-ldbm/external.h index 9a7bb508e2..6b1e8c7466 100644 --- a/servers/slapd/back-ldbm/external.h +++ b/servers/slapd/back-ldbm/external.h @@ -57,7 +57,7 @@ extern int ldbm_back_compare LDAP_P((BackendDB *bd, extern int ldbm_back_modify LDAP_P(( BackendDB *bd, Connection *conn, Operation *op, - char *dn, char *ndn, LDAPModList *ml )); + char *dn, char *ndn, Modifications *ml )); extern int ldbm_back_modrdn LDAP_P(( BackendDB *bd, Connection *conn, Operation *op, diff --git a/servers/slapd/back-ldbm/index.c b/servers/slapd/back-ldbm/index.c index a554543cc2..cc7a453be1 100644 --- a/servers/slapd/back-ldbm/index.c +++ b/servers/slapd/back-ldbm/index.c @@ -80,16 +80,20 @@ index_add_entry( int index_add_mods( Backend *be, - LDAPModList *ml, + Modifications *ml, ID id ) { int rc; for ( ; ml != NULL; ml = ml->ml_next ) { - LDAPMod *mod = &ml->ml_mod; + Modification *mod = &ml->ml_mod; - switch ( mod->mod_op & ~LDAP_MOD_BVALUES ) { +#ifdef SLAPD_SCHEMA_NOT_COMPAT + /* not yet implemented */ + rc = -1; +#else + switch ( mod->mod_op ) { case LDAP_MOD_REPLACE: /* XXX: Delete old index data==>problem when this * gets called we lost values already! @@ -108,10 +112,14 @@ index_add_mods( id, SLAP_INDEX_DELETE_OP ); break; - case LDAP_MOD_SOFTADD: /* SOFTADD means index was there */ + case SLAP_MOD_SOFTADD: /* SOFTADD means index was there */ rc = 0; break; + + default: + rc = -1; } +#endif if ( rc != 0 ) { return( rc ); diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index f30a153a42..07c42cdf3c 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -28,13 +28,13 @@ int ldbm_modify_internal( Connection *conn, Operation *op, char *dn, - LDAPModList *modlist, + Modifications *modlist, Entry *e ) { int err; LDAPMod *mod; - LDAPModList *ml; + Modifications *ml; Attribute *a; Attribute *save_attrs; @@ -48,7 +48,7 @@ int ldbm_modify_internal( for ( ml = modlist; ml != NULL; ml = ml->ml_next ) { mod = &ml->ml_mod; - switch ( mod->mod_op & ~LDAP_MOD_BVALUES ) { + switch ( mod->mod_op ) { case LDAP_MOD_ADD: err = add_values( e, mod, op->o_ndn ); break; @@ -61,7 +61,7 @@ int ldbm_modify_internal( err = replace_values( e, mod, op->o_ndn ); break; - case LDAP_MOD_SOFTADD: + case SLAP_MOD_SOFTADD: /* Avoid problems in index_add_mods() * We need to add index if necessary. */ @@ -70,7 +70,7 @@ int ldbm_modify_internal( == LDAP_TYPE_OR_VALUE_EXISTS ) { err = LDAP_SUCCESS; - mod->mod_op = LDAP_MOD_SOFTADD; + mod->mod_op = SLAP_MOD_SOFTADD; } break; @@ -116,9 +116,7 @@ int ldbm_modify_internal( if( save_attrs != NULL ) { for ( ml = modlist; ml != NULL; ml = ml->ml_next ) { mod = &ml->ml_mod; - if( ( mod->mod_op & ~LDAP_MOD_BVALUES ) - == LDAP_MOD_REPLACE ) - { + if ( mod->mod_op == LDAP_MOD_REPLACE ) { /* Need to remove all values from indexes */ a = attr_find( save_attrs, mod->mod_type ); @@ -151,7 +149,7 @@ ldbm_back_modify( Operation *op, char *dn, char *ndn, - LDAPModList *modlist + Modifications *modlist ) { int rc; diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index 20eef3ef1b..6ac0728c23 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -67,7 +67,7 @@ ldbm_back_modrdn( struct berval *add_bvals[2]; /* Stores new rdn att */ struct berval del_bv; /* Stores old rdn att */ struct berval *del_bvals[2]; /* Stores old rdn att */ - LDAPModList mod[2]; /* Used to delete old rdn */ + Modifications mod[2]; /* Used to delete old rdn */ int manageDSAit = get_manageDSAit( op ); Debug( LDAP_DEBUG_TRACE, "==>ldbm_back_modrdn(newSuperior=%s)\n", @@ -356,10 +356,14 @@ ldbm_back_modrdn( add_bv.bv_val = new_rdn_val; add_bv.bv_len = strlen(new_rdn_val); +#ifdef SLAPD_SCHEMA_NOT_COMPAT + /* not yet implemented */ +#else mod[0].ml_type = new_rdn_type; mod[0].ml_bvalues = add_bvals; - mod[0].ml_op = LDAP_MOD_SOFTADD; + mod[0].ml_op = SLAP_MOD_SOFTADD; mod[0].ml_next = NULL; +#endif /* Remove old rdn value if required */ @@ -385,6 +389,9 @@ ldbm_back_modrdn( del_bv.bv_val = old_rdn_val; del_bv.bv_len = strlen(old_rdn_val); +#ifdef SLAPD_SCHEMA_NOT_COMPAT + /* not yet implemented */ +#else /* No need to normalize old_rdn_type, delete_values() * does that for us */ @@ -393,6 +400,7 @@ ldbm_back_modrdn( mod[1].ml_bvalues = del_bvals; mod[1].ml_op = LDAP_MOD_DELETE; mod[1].ml_next = NULL; +#endif Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: removing old_rdn_val=%s\n", diff --git a/servers/slapd/back-ldbm/passwd.c b/servers/slapd/back-ldbm/passwd.c index 6915b59cad..e5a6dbfe36 100644 --- a/servers/slapd/back-ldbm/passwd.c +++ b/servers/slapd/back-ldbm/passwd.c @@ -114,21 +114,29 @@ ldbm_back_exop_passwd( } { - LDAPModList ml; + Modifications ml; struct berval *vals[2]; vals[0] = hash; vals[1] = NULL; +#ifdef SLAPD_SCHEMA_NOT_COMPAT + /* not yet implemented */ +#else ml.ml_type = ch_strdup("userPassword"); ml.ml_bvalues = vals; - ml.ml_op = LDAP_MOD_REPLACE | LDAP_MOD_BVALUES; + ml.ml_op = LDAP_MOD_REPLACE; ml.ml_next = NULL; +#endif rc = ldbm_modify_internal( be, conn, op, op->o_ndn, &ml, e ); +#ifdef SLAPD_SCHEMA_NOT_COMPAT + /* not yet implemented */ +#else ch_free(ml.ml_type); +#endif } if( rc == LDAP_SUCCESS ) { diff --git a/servers/slapd/back-ldbm/proto-back-ldbm.h b/servers/slapd/back-ldbm/proto-back-ldbm.h index 37f660f984..5159732a49 100644 --- a/servers/slapd/back-ldbm/proto-back-ldbm.h +++ b/servers/slapd/back-ldbm/proto-back-ldbm.h @@ -132,7 +132,7 @@ ID idl_nextid LDAP_P(( ID_BLOCK *idl, ID *cursor )); */ int index_add_entry LDAP_P(( Backend *be, Entry *e )); -int index_add_mods LDAP_P(( Backend *be, LDAPModList *ml, ID id )); +int index_add_mods LDAP_P(( Backend *be, Modifications *ml, ID id )); ID_BLOCK * index_read LDAP_P(( Backend *be, char *type, int indextype, char *val )); /* Possible operations supported (op) by index_change_values() */ @@ -175,7 +175,7 @@ int replace_values LDAP_P(( Entry *e, LDAPMod *mod, char *dn )); /* returns LDAP error code indicating error OR SLAPD_ABANDON */ int ldbm_modify_internal LDAP_P((Backend *be, Connection *conn, Operation *op, - char *dn, LDAPModList *mods, Entry *e )); + char *dn, Modifications *mods, Entry *e )); #ifdef HAVE_CYRUS_SASL /* diff --git a/servers/slapd/back-perl/external.h b/servers/slapd/back-perl/external.h index aa9f243014..e8dfc5cd6b 100644 --- a/servers/slapd/back-perl/external.h +++ b/servers/slapd/back-perl/external.h @@ -34,7 +34,7 @@ extern int perl_back_compare LDAP_P((BackendDB *bd, extern int perl_back_modify LDAP_P(( BackendDB *bd, Connection *conn, Operation *op, - char *dn, char *ndn, LDAPModList *ml )); + char *dn, char *ndn, Modifications *ml )); extern int perl_back_modrdn LDAP_P(( BackendDB *bd, Connection *conn, Operation *op, diff --git a/servers/slapd/back-shell/external.h b/servers/slapd/back-shell/external.h index 9c850fb6f2..1b4fa56fb5 100644 --- a/servers/slapd/back-shell/external.h +++ b/servers/slapd/back-shell/external.h @@ -34,7 +34,7 @@ extern int shell_back_compare LDAP_P((BackendDB *bd, extern int shell_back_modify LDAP_P(( BackendDB *bd, Connection *conn, Operation *op, - char *dn, char *ndn, LDAPModList *ml )); + char *dn, char *ndn, Modifications *ml )); extern int shell_back_modrdn LDAP_P(( BackendDB *bd, Connection *conn, Operation *op, diff --git a/servers/slapd/back-tcl/external.h b/servers/slapd/back-tcl/external.h index ff79962782..d7202f3d4e 100644 --- a/servers/slapd/back-tcl/external.h +++ b/servers/slapd/back-tcl/external.h @@ -37,7 +37,7 @@ extern int tcl_back_compare LDAP_P ((BackendDB * bd, extern int tcl_back_modify LDAP_P ((BackendDB * bd, Connection * conn, Operation * op, - char *dn, char *ndn, LDAPModList * ml)); + char *dn, char *ndn, Modifications * ml)); extern int tcl_back_modrdn LDAP_P ((BackendDB * bd, Connection * conn, Operation * op, diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 98a3bda3bd..81b23325bf 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -26,9 +26,9 @@ #include "ldap_pvt.h" #include "slap.h" -static void modlist_free(LDAPModList *ml); +static void modlist_free(Modifications *ml); -static int add_modified_attrs( Operation *op, LDAPModList **modlist ); +static int add_modified_attrs( Operation *op, Modifications **modlist ); int do_modify( @@ -40,10 +40,10 @@ do_modify( char *last; ber_tag_t tag; ber_len_t len; - LDAPModList *modlist = NULL; - LDAPModList **modtail = &modlist; + Modifications *modlist = NULL; + Modifications **modtail = &modlist; #ifdef LDAP_DEBUG - LDAPModList *tmp; + Modifications *tmp; #endif Backend *be; int rc; @@ -103,8 +103,11 @@ do_modify( { ber_int_t mop; - (*modtail) = (LDAPModList *) ch_calloc( 1, sizeof(LDAPModList) ); + (*modtail) = (Modifications *) ch_calloc( 1, sizeof(Modifications) ); +#ifdef SLAPD_SCHEMA_NOT_COMPAT + /* not yet implemented */ +#else if ( ber_scanf( op->o_ber, "{i{a[V]}}", &mop, &(*modtail)->ml_type, &(*modtail)->ml_bvalues ) == LBER_ERROR ) @@ -114,6 +117,7 @@ do_modify( rc = -1; goto cleanup; } +#endif (*modtail)->ml_op = mop; @@ -152,6 +156,9 @@ do_modify( } *modtail = NULL; +#ifdef SLAPD_SCHEMA_NOT_COMPAT + /* not yet implemented */ +#else #ifdef LDAP_DEBUG Debug( LDAP_DEBUG_ARGS, "modifications:\n", 0, 0, 0 ); for ( tmp = modlist; tmp != NULL; tmp = tmp->ml_next ) { @@ -160,6 +167,7 @@ do_modify( ? "add" : (tmp->ml_op == LDAP_MOD_DELETE ? "delete" : "replace"), tmp->ml_type, 0 ); } +#endif #endif if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) { @@ -262,18 +270,21 @@ cleanup: } static int -add_modified_attrs( Operation *op, LDAPModList **modlist ) +add_modified_attrs( Operation *op, Modifications **modlist ) { char buf[22]; struct berval bv; struct berval *bvals[2]; - LDAPModList *m; + Modifications *m; struct tm *ltm; time_t currenttime; bvals[0] = &bv; bvals[1] = NULL; +#ifdef SLAPD_SCHEMA_NOT_COMPAT + /* not yet implemented */ +#else /* 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 ) ) { @@ -288,7 +299,7 @@ add_modified_attrs( Operation *op, LDAPModList **modlist ) bv.bv_val = op->o_dn; bv.bv_len = strlen( bv.bv_val ); } - m = (LDAPModList *) ch_calloc( 1, sizeof(LDAPModList) ); + 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 *)); @@ -304,24 +315,28 @@ add_modified_attrs( Operation *op, LDAPModList **modlist ) bv.bv_val = buf; bv.bv_len = strlen( bv.bv_val ); - m = (LDAPModList *) ch_calloc( 1, sizeof(LDAPModList) ); + 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; +#endif return LDAP_SUCCESS; } static void modlist_free( - LDAPModList *ml + Modifications *ml ) { - LDAPModList *next; + Modifications *next; +#ifdef SLAPD_SCHEMA_NOT_COMPAT + /* not yet implemented */ +#else for ( ; ml != NULL; ml = next ) { next = ml->ml_next; @@ -333,4 +348,5 @@ modlist_free( free( ml ); } +#endif } diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index d3360fd622..c83716784c 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -33,7 +33,7 @@ LIBSLAPD_F (int) acl_check_modlist LDAP_P(( Backend *be, Connection *conn, Operation *op, Entry *e, - LDAPModList *ml )); + Modifications *ml )); LIBSLAPD_F (void) acl_append( AccessControl **l, AccessControl *a ); diff --git a/servers/slapd/repl.c b/servers/slapd/repl.c index 7477e8406e..273286acbe 100644 --- a/servers/slapd/repl.c +++ b/servers/slapd/repl.c @@ -28,7 +28,7 @@ replog( void *change ) { - LDAPModList *ml; + Modifications *ml; Entry *e; struct replog_moddn *moddn; char *tmp; @@ -58,7 +58,10 @@ replog( fprintf( fp, "changetype: modify\n" ); ml = change; for ( ; ml != NULL; ml = ml->ml_next ) { - switch ( ml->ml_op & ~LDAP_MOD_BVALUES ) { +#ifdef SLAPD_SCHEMA_NOT_COMPAT + /* not yet implemented */ +#else + switch ( ml->ml_op ) { case LDAP_MOD_ADD: fprintf( fp, "add: %s\n", ml->ml_type ); break; @@ -92,6 +95,7 @@ replog( free( buf ); } +#endif fprintf( fp, "-\n" ); } break; diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 36f1649062..8e5c28fe97 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -53,7 +53,8 @@ LDAP_BEGIN_DECL * modrdn when the new rdn was already an attribute value itself. * JCG 05/1999 (gomez@engr.sgi.com) */ -#define LDAP_MOD_SOFTADD 0x1000 +#define SLAP_MOD_SOFTADD 0x1000 +#undef LDAP_MOD_BVALUES #define ON 1 #define OFF (-1) @@ -454,6 +455,34 @@ typedef struct slap_entry { void* e_private; } 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 +#endif + +typedef struct slap_mod_list { + Modification ml_mod; +#ifdef SLAPD_SCHEMA_NOT_COMPAT +#define ml_op ml_mod.sm_op +#define ml_desc ml_mod.sm_desc +#define ml_bvalues ml_mod.sm_bvalues +#else +#define ml_op ml_mod.mod_op +#define ml_type ml_mod.mod_type +#define ml_values ml_mod.mod_values +#define ml_bvalues ml_mod.mod_bvalues +#endif + struct slap_mod_list *ml_next; +} Modifications; + /* * represents an access control list */ @@ -589,18 +618,8 @@ typedef struct slap_acl { } AccessControl; /* - * A list of LDAPMods + * replog moddn param structure */ -typedef struct ldapmodlist { - struct ldapmod ml_mod; - struct ldapmodlist *ml_next; -#define ml_op ml_mod.mod_op -#define ml_type ml_mod.mod_type -#define ml_values ml_mod.mod_values -#define ml_bvalues ml_mod.mod_bvalues -} LDAPModList; - - struct replog_moddn { char *newrdn; int deloldrdn; @@ -802,7 +821,7 @@ struct slap_backend_info { #endif int (*bi_op_modify) LDAP_P((BackendDB *bd, struct slap_conn *c, struct slap_op *o, - char *dn, char *ndn, LDAPModList *m)); + char *dn, char *ndn, Modifications *m)); int (*bi_op_modrdn) LDAP_P((BackendDB *bd, struct slap_conn *c, struct slap_op *o, char *dn, char *ndn, char *newrdn, int deleteoldrdn,