From 86bd13846f01e4434e9525428f4cc494ffd7f5bf Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Tue, 22 Feb 2000 19:26:15 +0000 Subject: [PATCH] Additional -DSLAPD_SCHEMA_NOT_COMPAT changes Not hidden "NULLDN" to "" in modify stats --- servers/slapd/add.c | 3 +- servers/slapd/modify.c | 91 ++++++++++++++++++++++++++++++++---------- servers/slapd/slap.h | 14 +++---- 3 files changed, 79 insertions(+), 29 deletions(-) diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 11069badee..cfc98574ee 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -256,7 +256,8 @@ add_created_attrs( Operation *op, Entry *e ) if ( op->o_dn == NULL || op->o_dn[0] == '\0' ) { bv.bv_val = ""; - bv.bv_len = strlen( bv.bv_val ); + bv.bv_len = sizeof("")-1; +; } else { bv.bv_val = op->o_dn; bv.bv_len = strlen( bv.bv_val ); diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 276fa7fb3e..97768318f2 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -27,6 +27,14 @@ #include "slap.h" static void modlist_free(LDAPModList *ml); +static void mods_free(Modifications *mods); + +#ifdef SLAPD_SCHEMA_NOT_COMPAT +/* static */ int modlist2mods( + LDAPModList *ml, + Modifications **mods, + char **text ); +#endif static int add_modified_attrs( Operation *op, Modifications **modlist ); @@ -42,10 +50,10 @@ do_modify( ber_len_t len; LDAPModList *modlist = NULL; LDAPModList **modtail = &modlist; - Modifications *mods = NULL; #ifdef LDAP_DEBUG - Modifications *tmp; + LDAPModList *tmp; #endif + Modifications *mods = NULL; Backend *be; int rc; @@ -158,24 +166,13 @@ do_modify( goto cleanup; } -#ifdef SLAPD_SCHEMA_NOT_COMPAT - /* not yet implemented */ -#else - mods = modlist; -#endif - #ifdef LDAP_DEBUG Debug( LDAP_DEBUG_ARGS, "modifications:\n", 0, 0, 0 ); - for ( tmp = mods; tmp != NULL; tmp = tmp->sml_next ) { -#ifdef SLAPD_SCHEMA_NOT_COMPAT - char *type = tmp->sml_desc.ad_cname->bv_val; -#else - char *type = tmp->sml_type; -#endif + for ( tmp = modlist; tmp != NULL; tmp = tmp->ml_next ) { Debug( LDAP_DEBUG_ARGS, "\t%s: %s\n", - tmp->sml_op == LDAP_MOD_ADD - ? "add" : (tmp->sml_op == LDAP_MOD_DELETE - ? "delete" : "replace"), type, 0 ); + tmp->ml_op == LDAP_MOD_ADD + ? "add" : (tmp->ml_op == LDAP_MOD_DELETE + ? "delete" : "replace"), tmp->ml_type, 0 ); } #endif @@ -231,6 +228,20 @@ do_modify( strcmp( be->be_update_ndn, op->o_ndn ) == 0 ) #endif { +#ifdef SLAPD_SCHEMA_NOT_COMPAT + char *text; + rc = modlist2mods( modlist, &mods, &text ); + + if( rc != LDAP_SUCCESS ) { + send_ldap_result( conn, op, rc, + NULL, text, NULL, NULL ); + goto cleanup; + } +#else + mods = modlist; + modlist = NULL; +#endif + if ( (be->be_lastmod == ON || (be->be_lastmod == UNDEFINED && global_lastmod == ON)) && be->be_update_ndn == NULL ) { @@ -272,12 +283,17 @@ cleanup: free( ndn ); if ( modlist != NULL ) modlist_free( modlist ); + if ( mods != NULL ) + mods_free( mods ); return rc; } static int add_modified_attrs( Operation *op, Modifications **modlist ) { +#ifdef SLAPD_SCHEMA_NOT_COMPAT + /* not yet implemented */ +#else char buf[22]; struct berval bv; struct berval *bvals[2]; @@ -288,9 +304,6 @@ add_modified_attrs( Operation *op, Modifications **modlist ) 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 ) ) { @@ -300,7 +313,7 @@ add_modified_attrs( Operation *op, Modifications **modlist ) if ( op->o_dn == NULL || op->o_dn[0] == '\0' ) { bv.bv_val = ""; - bv.bv_len = strlen( bv.bv_val ); + bv.bv_len = sizeof("")-1; } else { bv.bv_val = op->o_dn; bv.bv_len = strlen( bv.bv_val ); @@ -333,6 +346,42 @@ add_modified_attrs( Operation *op, Modifications **modlist ) return LDAP_SUCCESS; } +static void +mod_free( + Modification *mod, + int freeit +) +{ +#ifdef SLAPD_SCHEMA_NOT_COMPAT + ad_free( &mod->sm_desc, 0 ); +#else + if (mod->sm_desc) { + free( mod->sm_desc ); + } +#endif + + if ( mod->sm_bvalues != NULL ) + ber_bvecfree( mod->sm_bvalues ); + + if( freeit ) + free( mod ); +} + +static void +mods_free( + Modifications *ml +) +{ + Modifications *next; + + for ( ; ml != NULL; ml = next ) { + next = ml->sml_next; + + mod_free( &ml->sml_mod, 0 ); + free( ml ); + } +} + static void modlist_free( LDAPModList *ml diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index cc4e9e8cf8..aaf9a4520a 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -92,7 +92,7 @@ LDAP_BEGIN_DECL /* schema needed by slapd */ #define SLAPD_OID_DN_SYNTAX "1.3.6.1.4.1.1466.115.121.1.12" -#define SLAPD_OID_ACI_SYNTAX "1.3.6.1.4.1.4203.2.1" /* experimental */ +#define SLAPD_OID_ACI_SYNTAX "1.3.6.1.4.1.4203.666.2.1" /* experimental */ LIBSLAPD_F (int) slap_debug; @@ -478,19 +478,19 @@ typedef struct slap_mod { } Modification; #else #define Modification LDAPMod +#define sm_op mod_op +#define sm_desc mod_type +#define sm_type mod_type +#define sm_bvalues mod_bvalues #endif typedef struct slap_mod_list { Modification sml_mod; -#ifdef SLAPD_SCHEMA_NOT_COMPAT #define sml_op sml_mod.sm_op #define sml_desc sml_mod.sm_desc #define sml_bvalues sml_mod.sm_bvalues -#else -#define sml_op sml_mod.mod_op -#define sml_type sml_mod.mod_type -#define sml_values sml_mod.mod_values -#define sml_bvalues sml_mod.mod_bvalues +#ifndef SLAPD_SCHEMA_NOT_COMPAT +#define sml_type sml_mod.sm_type #endif struct slap_mod_list *sml_next; } Modifications; -- 2.39.5