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

boli
15.54.2006 ef1631c00cf0376998a026f97ad5c141e4b1d03c
opendj-sdk/opends/src/server/org/opends/server/backends/jeb/BackendImpl.java
@@ -79,6 +79,7 @@
import org.opends.server.types.LDIFExportConfig;
import org.opends.server.types.RestoreConfig;
import org.opends.server.types.ResultCode;
import org.opends.server.types.FilePermission;
import org.opends.server.monitors.DatabaseEnvironmentMonitor;
import org.opends.server.util.LDIFException;
import org.opends.server.loggers.Debug;
@@ -121,6 +122,12 @@
  private File backendDirectory;
  /**
   * The permissions mode for the directory containing persistent storage for
   * the backend.
   */
  private FilePermission backendPermission;
  /**
   * The base DNs contained in this backend.
   */
  private ConcurrentHashMap<DN, EntryContainer> baseDNs;
@@ -374,6 +381,24 @@
                                        message);
    }
    // Get the backend database directory permissions and apply
    try
    {
      backendPermission = config.getBackendPermission();
      if(!FilePermission.setPermissions(backendDirectory, backendPermission))
      {
        throw new Exception();
      }
    }
    catch(Exception e)
    {
      // Log an warning that the permissions were not set.
      int msgID = MSGID_JEB_SET_PERMISSIONS_FAILED;
      String message = getMessage(msgID, backendDirectory.getPath());
      logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_WARNING,
               message, msgID);
    }
    // FIXME: Currently assuming every base DN is also a suffix.
    for (DN dn : baseDNs)
    {
@@ -1577,6 +1602,31 @@
        }
      }
      // Check for changes to the database directory permissions
      FilePermission oldPermission = config.getBackendPermission();
      FilePermission newPermission = newConfig.getBackendPermission();
      if(!FilePermission.toUNIXMode(oldPermission).equals(
          FilePermission.toUNIXMode(newPermission)))
      {
        try
        {
          if(!FilePermission.setPermissions(newConfig.getBackendDirectory(),
              newPermission))
          {
            throw new Exception();
          }
        }
        catch(Exception e)
        {
          // Log an warning that the permissions were not set.
          int msgID = MSGID_JEB_SET_PERMISSIONS_FAILED;
          String message = getMessage(msgID, backendDirectory.getPath());
          logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_WARNING,
                   message, msgID);
        }
      }
      // Check if any JE non-mutable properties were changed.
      EnvironmentConfig oldEnvConfig = config.getEnvironmentConfig();
      EnvironmentConfig newEnvConfig = newConfig.getEnvironmentConfig();