mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Matthew Swift
14.34.2012 be2c14a6c751da319eeb4af36eeb5dea4c821acf
Initial fix for OPENDJ-249: dsreplication disable --disableAll error removing contents of "cn=admin data"

Disabling replication now avoids the self-disconnect by not deleting the administrator entry, so the command now completes successfully. However, it is erasing the entire contents of the ads truststore, including the server instance key. This is definitely not a good idea since the key may be required for reversible encryption.
3 files modified
49 ■■■■■ changed files
opends/src/ads/org/opends/admin/ads/ADSContext.java 34 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java 13 ●●●●● patch | view | raw | blame | history
opends/src/ads/org/opends/admin/ads/ADSContext.java
@@ -1187,7 +1187,12 @@
  {
    // Add the administration suffix
    createAdministrationSuffix(backendName);
    createAdminDataContainers();
  }
  // Create container entries.
  private void createAdminDataContainers() throws ADSContextException
  {
    // Create the DIT below the administration suffix
    if (!isExistingEntry(nameFromDN(getAdministrationSuffixDN())))
    {
@@ -1228,16 +1233,26 @@
    }
  }
  /**
   * Removes the administration data.
   * @throws ADSContextException if something goes wrong.
   *
   * @param removeAdministrators
   *          {@code true} if administrators should be removed. It may not be
   *          possible to remove administrators if the operation is being
   *          performed by one of the administrators because it will cause the
   *          administrator to be disconnected.
   * @throws ADSContextException
   *           if something goes wrong.
   */
  public void removeAdminData() throws ADSContextException
  public void removeAdminData(boolean removeAdministrators)
      throws ADSContextException
  {
    String[] dns = {getServerContainerDN(),
        getServerGroupContainerDN(),
        getInstanceKeysContainerDN(),
        getAdministratorContainerDN()};
        removeAdministrators ? getAdministratorContainerDN() : null };
    try
    {
      Control[] controls = new Control[] { new SubtreeDeleteControl() };
@@ -1246,10 +1261,13 @@
      {
        for (String dn : dns)
        {
          LdapName ldapName = nameFromDN(dn);
          if (isExistingEntry(ldapName))
          if (dn != null)
          {
            tmpContext.destroySubcontext(dn);
            LdapName ldapName = nameFromDN(dn);
            if (isExistingEntry(ldapName))
            {
              tmpContext.destroySubcontext(dn);
            }
          }
        }
      }
@@ -1267,9 +1285,7 @@
        }
      }
      // Recreate the container entries:
      createContainerEntry(getServerContainerDN());
      createContainerEntry(getServerGroupContainerDN());
      createContainerEntry(getInstanceKeysContainerDN());
      createAdminDataContainers();
    }
    catch(NamingException x)
    {
opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
@@ -1643,7 +1643,7 @@
        ADSContext adsContext = new ADSContext(ctx);
        if (createdRemoteAds)
        {
          adsContext.removeAdminData();
          adsContext.removeAdminData(true);
        }
        else
        {
opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java
@@ -7005,18 +7005,7 @@
        // Delete all contents from ADSContext.
        printProgress(formatter.getFormattedWithPoints(
            INFO_REPLICATION_REMOVE_ADS_CONTENTS.get()));
        adsCtx.removeAdminData();
        String adminBackendName = null;
        for (ReplicaDescriptor replica : server.getReplicas())
        {
          if (Utils.areDnsEqual(ADSContext.getAdministrationSuffixDN(),
              replica.getSuffix().getDN()))
          {
            adminBackendName = replica.getBackendName();
            break;
          }
        }
        adsCtx.createAdminData(adminBackendName);
        adsCtx.removeAdminData(false /* avoid self-disconnect */);
        printProgress(formatter.getFormattedDone());
        printlnProgress();
      }