]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
Allow NULL modlist in modrdn
authorHoward Chu <hyc@openldap.org>
Sat, 22 Dec 2018 17:00:34 +0000 (09:00 -0800)
committerHoward Chu <hyc@openldap.org>
Sat, 22 Dec 2018 17:00:34 +0000 (09:00 -0800)
For compat with MSAD which doesn't add the naming attribute to
the entry during a rename

servers/slapd/back-bdb/modrdn.c
servers/slapd/back-mdb/modrdn.c
servers/slapd/back-sql/modrdn.c

index 038444fa653b0cebbb90d519cec2cd3438971ed2..b47285bcf6e8d79315a99c93d4f6b85819f9b3d4 100644 (file)
@@ -76,7 +76,8 @@ bdb_modrdn( Operation *op, SlapReply *rs )
        if( 0 ) {
 retry: /* transaction retry */
                if ( dummy.e_attrs ) {
-                       attrs_free( dummy.e_attrs );
+                       if ( dummy.e_attrs != e->e_attrs )
+                               attrs_free( dummy.e_attrs );
                        dummy.e_attrs = NULL;
                }
                if (e != NULL) {
@@ -537,8 +538,6 @@ retry:      /* transaction retry */
                goto return_results;
        }
 
-       assert( op->orr_modlist != NULL );
-
        if( op->o_preread ) {
                if( preread_ctrl == NULL ) {
                        preread_ctrl = &ctrls[num_ctrls++];
@@ -615,24 +614,25 @@ retry:    /* transaction retry */
 
        dummy.e_attrs = e->e_attrs;
 
-       /* modify entry */
-       rs->sr_err = bdb_modify_internal( op, lt2, op->orr_modlist, &dummy,
-               &rs->sr_text, textbuf, textlen );
-       if( rs->sr_err != LDAP_SUCCESS ) {
-               Debug(LDAP_DEBUG_TRACE,
-                       "<=- " LDAP_XSTRING(bdb_modrdn)
-                       ": modify failed: %s (%d)\n",
-                       db_strerror(rs->sr_err), rs->sr_err, 0 );
-               if ( ( rs->sr_err == LDAP_INSUFFICIENT_ACCESS ) && opinfo.boi_err ) {
-                       rs->sr_err = opinfo.boi_err;
-               }
-               if ( dummy.e_attrs == e->e_attrs ) dummy.e_attrs = NULL;
-               switch( rs->sr_err ) {
-               case DB_LOCK_DEADLOCK:
-               case DB_LOCK_NOTGRANTED:
-                       goto retry;
+       if( op->orr_modlist != NULL ) {
+               /* modify entry */
+               rs->sr_err = bdb_modify_internal( op, lt2, op->orr_modlist, &dummy,
+                       &rs->sr_text, textbuf, textlen );
+               if( rs->sr_err != LDAP_SUCCESS ) {
+                       Debug(LDAP_DEBUG_TRACE,
+                               "<=- " LDAP_XSTRING(bdb_modrdn)
+                               ": modify failed: %s (%d)\n",
+                               db_strerror(rs->sr_err), rs->sr_err, 0 );
+                       if ( ( rs->sr_err == LDAP_INSUFFICIENT_ACCESS ) && opinfo.boi_err ) {
+                               rs->sr_err = opinfo.boi_err;
+                       }
+                       switch( rs->sr_err ) {
+                       case DB_LOCK_DEADLOCK:
+                       case DB_LOCK_NOTGRANTED:
+                               goto retry;
+                       }
+                       goto return_results;
                }
-               goto return_results;
        }
 
        /* id2entry index */
@@ -708,8 +708,6 @@ retry:      /* transaction retry */
                } else {
                        rs->sr_err = LDAP_X_NO_OPERATION;
                        ltid = NULL;
-                       /* Only free attrs if they were dup'd.  */
-                       if ( dummy.e_attrs == e->e_attrs ) dummy.e_attrs = NULL;
                        goto return_results;
                }
 
@@ -754,7 +752,7 @@ retry:      /* transaction retry */
        if( num_ctrls ) rs->sr_ctrls = ctrls;
 
 return_results:
-       if ( dummy.e_attrs ) {
+       if ( dummy.e_attrs != e->e_attrs ) {
                attrs_free( dummy.e_attrs );
        }
        send_ldap_result( op, rs );
index d9a880f0aff68742f45fbee1203098c4c59e22b5..a83807dde5f1c46452c5fc6761dcd7cb45bd59d6 100644 (file)
@@ -411,8 +411,6 @@ mdb_modrdn( Operation       *op, SlapReply *rs )
                goto return_results;
        }
 
-       assert( op->orr_modlist != NULL );
-
        if( op->o_preread ) {
                if( preread_ctrl == NULL ) {
                        preread_ctrl = &ctrls[num_ctrls++];
@@ -468,16 +466,17 @@ mdb_modrdn( Operation     *op, SlapReply *rs )
 
        dummy.e_attrs = e->e_attrs;
 
-       /* modify entry */
-       rs->sr_err = mdb_modify_internal( op, txn, op->orr_modlist, &dummy,
-               &rs->sr_text, textbuf, textlen );
-       if( rs->sr_err != LDAP_SUCCESS ) {
-               Debug(LDAP_DEBUG_TRACE,
-                       "<=- " LDAP_XSTRING(mdb_modrdn)
-                       ": modify failed: %s (%d)\n",
-                       mdb_strerror(rs->sr_err), rs->sr_err, 0 );
-               if ( dummy.e_attrs == e->e_attrs ) dummy.e_attrs = NULL;
-               goto return_results;
+       if ( op->orr_modlist != NULL ) {
+               /* modify entry */
+               rs->sr_err = mdb_modify_internal( op, txn, op->orr_modlist, &dummy,
+                       &rs->sr_text, textbuf, textlen );
+               if( rs->sr_err != LDAP_SUCCESS ) {
+                       Debug(LDAP_DEBUG_TRACE,
+                               "<=- " LDAP_XSTRING(mdb_modrdn)
+                               ": modify failed: %s (%d)\n",
+                               mdb_strerror(rs->sr_err), rs->sr_err, 0 );
+                       goto return_results;
+               }
        }
 
        /* id2entry index */
@@ -546,8 +545,6 @@ mdb_modrdn( Operation       *op, SlapReply *rs )
                        mdb_txn_abort( txn );
                        rs->sr_err = LDAP_X_NO_OPERATION;
                        txn = NULL;
-                       /* Only free attrs if they were dup'd.  */
-                       if ( dummy.e_attrs == e->e_attrs ) dummy.e_attrs = NULL;
                        goto return_results;
 
                } else {
@@ -578,7 +575,7 @@ mdb_modrdn( Operation       *op, SlapReply *rs )
        if( num_ctrls ) rs->sr_ctrls = ctrls;
 
 return_results:
-       if ( dummy.e_attrs ) {
+       if ( dummy.e_attrs != e->e_attrs ) {
                attrs_free( dummy.e_attrs );
        }
        send_ldap_result( op, rs );
index 89c41656151ff9763c975c2c487cc34a8edd4c3a..cadd9ab6ec2c772e03e57e6317ded4c0efd00f5e 100644 (file)
@@ -378,17 +378,18 @@ backsql_modrdn( Operation *op, SlapReply *rs )
        }
        SQLFreeStmt( sth, SQL_DROP );
 
-       assert( op->orr_modlist != NULL );
-
        slap_mods_opattrs( op, &op->orr_modlist, 1 );
 
        assert( e_id.eid_oc != NULL );
        oc = e_id.eid_oc;
-       rs->sr_err = backsql_modify_internal( op, rs, dbh, oc, &e_id, op->orr_modlist );
-       slap_graduate_commit_csn( op );
-       if ( rs->sr_err != LDAP_SUCCESS ) {
-               e = &r;
-               goto done;
+
+       if ( op->orr_modlist != NULL ) {
+               rs->sr_err = backsql_modify_internal( op, rs, dbh, oc, &e_id, op->orr_modlist );
+               slap_graduate_commit_csn( op );
+               if ( rs->sr_err != LDAP_SUCCESS ) {
+                       e = &r;
+                       goto done;
+               }
        }
 
        if ( BACKSQL_CHECK_SCHEMA( bi ) ) {