Commit 86bd1384 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Additional -DSLAPD_SCHEMA_NOT_COMPAT changes

Not hidden "NULLDN" to "<anonymous>" in modify stats
parent 655c0bda
......@@ -256,7 +256,8 @@ add_created_attrs( Operation *op, Entry *e )
if ( op->o_dn == NULL || op->o_dn[0] == '\0' ) {
bv.bv_val = "<anonymous>";
bv.bv_len = strlen( bv.bv_val );
bv.bv_len = sizeof("<anonymous>")-1;
;
} else {
bv.bv_val = op->o_dn;
bv.bv_len = strlen( bv.bv_val );
......
......@@ -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 = "<anonymous>";
bv.bv_len = strlen( bv.bv_val );
bv.bv_len = sizeof("<anonymous>")-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
......
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment