]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#7080 Do not munge path twice
authorOndřej Kuzník <ondra@mistotebe.net>
Thu, 24 Oct 2024 14:59:37 +0000 (15:59 +0100)
committerQuanah Gibson-Mount <quanah@openldap.org>
Mon, 16 Dec 2024 17:01:26 +0000 (17:01 +0000)
servers/slapd/back-ldif/ldif.c

index 2364c1021134d4fde6abd84e8c314ed65232260c..1f3be63cd85718dbccd26c0dd3126ceef36a3eae 100644 (file)
@@ -1576,28 +1576,6 @@ ldif_back_delete( Operation *op, SlapReply *rs )
                goto done;
        }
 
-       rc = ndn2path( op, &op->o_req_ndn, &path, 0 );
-       if ( rc != LDAP_SUCCESS ) {
-               goto done;
-       }
-
-       ldif2dir_len( path );
-       ldif2dir_name( path );
-       if ( rmdir( path.bv_val ) < 0 ) {
-               switch ( errno ) {
-               case ENOTEMPTY:
-                       rc = LDAP_NOT_ALLOWED_ON_NONLEAF;
-                       break;
-               case ENOENT:
-                       /* is leaf, go on */
-                       break;
-               default:
-                       rc = LDAP_OTHER;
-                       rs->sr_text = "internal error (cannot delete subtree directory)";
-                       break;
-               }
-       }
-
        /* pre-read */
        if ( op->o_preread ) {
                Entry *e = NULL;
@@ -1620,6 +1598,29 @@ ldif_back_delete( Operation *op, SlapReply *rs )
                        }
                }
                entry_free( e );
+       } else {
+               rc = ndn2path( op, &op->o_req_ndn, &path, 0 );
+       }
+
+       if ( rc != LDAP_SUCCESS ) {
+               goto done;
+       }
+
+       ldif2dir_len( path );
+       ldif2dir_name( path );
+       if ( rmdir( path.bv_val ) < 0 ) {
+               switch ( errno ) {
+               case ENOTEMPTY:
+                       rc = LDAP_NOT_ALLOWED_ON_NONLEAF;
+                       break;
+               case ENOENT:
+                       /* is leaf, go on */
+                       break;
+               default:
+                       rc = LDAP_OTHER;
+                       rs->sr_text = "internal error (cannot delete subtree directory)";
+                       break;
+               }
        }
 
        if ( rc == LDAP_SUCCESS ) {