X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fslapmodify.c;h=fd578a68f2837c149ec6a2ea2585880a39993a62;hb=59e9ff6243465640956b58ad1756a3ede53eca7c;hp=83cb41c00dcc7e8bc32d7f7924a0974e53522fe7;hpb=46331f0216c4de9fa3aa26273f18b5be2afa6e18;p=openldap diff --git a/servers/slapd/slapmodify.c b/servers/slapd/slapmodify.c index 83cb41c00d..fd578a68f2 100644 --- a/servers/slapd/slapmodify.c +++ b/servers/slapd/slapmodify.c @@ -1,7 +1,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2014 The OpenLDAP Foundation. + * Copyright 1998-2018 The OpenLDAP Foundation. * Portions Copyright 1998-2003 Kurt D. Zeilenga. * Portions Copyright 2003 IBM Corporation. * All rights reserved. @@ -38,6 +38,8 @@ #include "slapcommon.h" +extern int slap_DN_strict; /* dn.c */ + static char csnbuf[ LDAP_PVT_CSNSTR_BUFSIZE ]; int @@ -98,9 +100,12 @@ slapmodify( int argc, char **argv ) lmax = 0; nextline = 0; - /* enforce schema checking unless not disabled */ + /* enforce schema checking unless not disabled and allow unknown + * attributes otherwise */ if ( (slapMode & SLAP_TOOL_NO_SCHEMA_CHECK) == 0) { SLAP_DBFLAGS(be) &= ~(SLAP_DBFLAG_NO_SCHEMA_CHECK); + } else { + slap_DN_strict = 0; } if( !dryrun && be->be_entry_open( be, 1 ) != 0 ) { @@ -185,7 +190,7 @@ slapmodify( int argc, char **argv ) request = "delete"; break; } - /* backend does not support delete, fallthrough */ + /* backend does not support delete, fallthru */ case LDAP_REQ_MODRDN: fprintf( stderr, "%s: request 0x%lx not supported (line=%lu)\n", @@ -280,13 +285,15 @@ slapmodify( int argc, char **argv ) rc = (id == NOID); if ( rc == LDAP_SUCCESS && lr.lr_op != LDAP_REQ_DELETE ) { e_orig = be->be_entry_get( be, id ); - e = entry_dup( e_orig ); + if ( e_orig ) + e = entry_dup( e_orig ); + rc = (e == NULL); } break; } if ( rc != LDAP_SUCCESS ) { - fprintf( stderr, "%s: no such entry \"%s\" in database (lineno=%d)\n", + fprintf( stderr, "%s: no such entry \"%s\" in database (lineno=%lu)\n", progname, ndn.bv_val, lineno ); rc = EXIT_FAILURE; goto cleanup; @@ -425,12 +432,13 @@ slapmodify( int argc, char **argv ) break; } + ber_bvarray_free( mods.sm_values ); + ber_bvarray_free( mods.sm_nvalues ); + if ( local_rc != LDAP_SUCCESS ) { fprintf( stderr, "%s: DN=\"%s\": unable to modify attr=%s\n", progname, e->e_dn, mods.sm_desc->ad_cname.bv_val ); rc = EXIT_FAILURE; - ber_bvarray_free( mods.sm_values ); - ber_bvarray_free( mods.sm_nvalues ); goto cleanup; } } @@ -479,8 +487,6 @@ slapmodify( int argc, char **argv ) a = attr_find( e->e_attrs, slap_schema.si_ad_entryUUID ); if ( a != NULL ) { - vals[0].bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) ); - vals[0].bv_val = uuidbuf; if ( a->a_vals != a->a_nvals ) { SLAP_FREE( a->a_nvals[0].bv_val ); SLAP_FREE( a->a_nvals ); @@ -491,6 +497,8 @@ slapmodify( int argc, char **argv ) a->a_nvals = NULL; a->a_numvals = 0; } + vals[0].bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) ); + vals[0].bv_val = uuidbuf; attr_merge_normalize_one( e, slap_schema.si_ad_entryUUID, vals, NULL ); a = attr_find( e->e_attrs, slap_schema.si_ad_creatorsName ); @@ -558,15 +566,14 @@ slapmodify( int argc, char **argv ) break; case LDAP_REQ_DELETE: - rc = be->be_entry_delete( be, id, &bvtext ); - e_orig = NULL; + rc = be->be_entry_delete( be, &ndn, &bvtext ); break; } if( rc != LDAP_SUCCESS ) { fprintf( stderr, "%s: could not %s entry dn=\"%s\" " - "(line=%lu): %s\n", progname, request, e->e_dn, + "(line=%lu): %s\n", progname, request, ndn.bv_val, lineno, bvtext.bv_val ); rc = EXIT_FAILURE; goto cleanup; @@ -576,11 +583,11 @@ slapmodify( int argc, char **argv ) if ( verbose ) fprintf( stderr, "%s: \"%s\" (%08lx)\n", - request, e->e_dn, (long) id ); + request, ndn.bv_val, (long) id ); } else { if ( verbose ) fprintf( stderr, "%s: \"%s\"\n", - request, e->e_dn ); + request, ndn.bv_val ); } cleanup:;