From e95bc9423fe1de8ce5d83901d5b1fe8e69752ab2 Mon Sep 17 00:00:00 2001
From: boli <boli@localhost>
Date: Thu, 03 Jan 2008 17:51:53 +0000
Subject: [PATCH] Fixed the config change listeners for all log publishers so they will prevent changing the log file permissions to an invalid value. The listeners will now reject changes that will prevent OpenDS from writing to the log files.

---
 opends/src/messages/messages/config.properties                               |   14 +
 opends/src/server/org/opends/server/backends/jeb/RootContainer.java          |   13 +
 opends/src/server/org/opends/server/loggers/TextAuditLogPublisher.java       |  262 ++++++++++++++++----------------
 opends/src/server/org/opends/server/loggers/debug/TextDebugLogPublisher.java |   43 +++--
 opends/src/server/org/opends/server/loggers/TextAccessLogPublisher.java      |   41 +++--
 opends/src/server/org/opends/server/loggers/TextErrorLogPublisher.java       |   67 +++----
 6 files changed, 233 insertions(+), 207 deletions(-)

diff --git a/opends/src/messages/messages/config.properties b/opends/src/messages/messages/config.properties
index 104a964..09cd1e1 100644
--- a/opends/src/messages/messages/config.properties
+++ b/opends/src/messages/messages/config.properties
@@ -20,7 +20,7 @@
 #
 # CDDL HEADER END
 #
-#      Portions Copyright 2006-2007 Sun Microsystems, Inc.
+#      Portions Copyright 2006-2008 Sun Microsystems, Inc.
 
 
 
@@ -1686,9 +1686,9 @@
 SEVERE_ERR_CONFIG_BACKEND_MODE_INVALID_567=Configuration entry %s does not \
  contain a valid value for configuration attribute ds-cfg-db-directory-permissions (It \
  should be an UNIX permission mode in three-digit octal notation.)
-SEVERE_WARN_CONFIG_BACKEND_INSANE_MODE_568=Unable to set the requested file \
- permissions to the backend database directory. The requested permissions will \
- result in an inaccessible database
+SEVERE_ERR_CONFIG_BACKEND_INSANE_MODE_568=Invalid UNIX file permissions %s \
+  does not allow read and write access to the backend database directory by \
+  the backend
 INFO_CONFIG_CORE_DESCRIPTION_TIME_LIMIT_569=Default maximum \
  length of time that should be allowed when processing a search operation. \
  This may be overridden on a per-user basis by including the \
@@ -2130,10 +2130,14 @@
 SEVERE_ERR_CONFIG_WORKFLOW_CANNOT_CONFIGURE_MANUAL_713=An error occurred \
  while trying to configure in manual mode the workflows in the \
  Directory Server, and rollback to automatic configuration mode has failed \
- too. If the server is in an unstable state restart it with the last \
+ too. If the server is in an unstab\
+  le state restart it with the last \
  valid configuration
 SEVERE_ERR_CONFIG_WORKFLOW_CANNOT_CONFIGURE_AUTO_714=An error occurred \
  while trying to configure in automatic mode the workflows in the \
  Directory Server, and rollback to manual configuration mode has failed \
  too. If the server is in an unstable state restart it with the last \
  valid configuration
+SEVERE_ERR_CONFIG_LOGGING_INSANE_MODE_715=Invalid UNIX file permissions %s \
+  does not allow write access to the log file by the log publisher
+SEVERE_ERR_CONFIG_LOGGING_MODE_INVALID_716=Invalid UNIX file permissions %s: %s
\ No newline at end of file
diff --git a/opends/src/server/org/opends/server/backends/jeb/RootContainer.java b/opends/src/server/org/opends/server/backends/jeb/RootContainer.java
index 2fbd12b..42a0de5 100644
--- a/opends/src/server/org/opends/server/backends/jeb/RootContainer.java
+++ b/opends/src/server/org/opends/server/backends/jeb/RootContainer.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
+ *      Portions Copyright 2006-2008 Sun Microsystems, Inc.
  */
 package org.opends.server.backends.jeb;
 import org.opends.messages.Message;
@@ -56,7 +56,7 @@
 import static org.opends.messages.ConfigMessages.
     ERR_CONFIG_BACKEND_MODE_INVALID;
 import static org.opends.messages.ConfigMessages.
-    WARN_CONFIG_BACKEND_INSANE_MODE;
+    ERR_CONFIG_BACKEND_INSANE_MODE;
 import static org.opends.server.util.StaticUtils.*;
 import static org.opends.messages.ConfigMessages.*;
 
@@ -182,7 +182,8 @@
         !backendPermission.isOwnerReadable() ||
         !backendPermission.isOwnerExecutable())
     {
-      Message message = WARN_CONFIG_BACKEND_INSANE_MODE.get();
+      Message message = ERR_CONFIG_BACKEND_INSANE_MODE.get(
+          config.getDBDirectoryPermissions());
       throw new ConfigException(message);
     }
 
@@ -759,7 +760,8 @@
           !newBackendPermission.isOwnerReadable() ||
           !newBackendPermission.isOwnerExecutable())
       {
-        Message message = WARN_CONFIG_BACKEND_INSANE_MODE.get();
+        Message message = ERR_CONFIG_BACKEND_INSANE_MODE.get(
+            cfg.getDBDirectoryPermissions());
         unacceptableReasons.add(message);
         acceptable = false;
       }
@@ -932,7 +934,8 @@
             !backendPermission.isOwnerReadable() ||
             !backendPermission.isOwnerExecutable())
         {
-          messages.add(WARN_CONFIG_BACKEND_INSANE_MODE.get());
+          messages.add(ERR_CONFIG_BACKEND_INSANE_MODE.get(
+              cfg.getDBDirectoryPermissions()));
           ccr = new ConfigChangeResult(
               DirectoryServer.getServerErrorResultCode(),
               adminActionRequired,
diff --git a/opends/src/server/org/opends/server/loggers/TextAccessLogPublisher.java b/opends/src/server/org/opends/server/loggers/TextAccessLogPublisher.java
index 8ab5c89..37b810e 100644
--- a/opends/src/server/org/opends/server/loggers/TextAccessLogPublisher.java
+++ b/opends/src/server/org/opends/server/loggers/TextAccessLogPublisher.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
+ *      Portions Copyright 2006-2008 Sun Microsystems, Inc.
  */
 package org.opends.server.loggers;
 import org.opends.messages.Message;
@@ -34,6 +34,7 @@
 
 import org.opends.server.admin.server.ConfigurationChangeListener;
 import org.opends.server.admin.std.server.FileBasedAccessLogPublisherCfg;
+import org.opends.server.admin.std.server.AccessLogPublisherCfg;
 import org.opends.server.api.*;
 import org.opends.server.config.ConfigException;
 import org.opends.server.core.AbandonOperation;
@@ -96,6 +97,17 @@
   /**
    * {@inheritDoc}
    */
+  public boolean isConfigurationAcceptable(AccessLogPublisherCfg configuration,
+                                           List<Message> unacceptableReasons)
+  {
+    FileBasedAccessLogPublisherCfg config =
+        (FileBasedAccessLogPublisherCfg) configuration;
+    return isConfigurationChangeAcceptable(config, unacceptableReasons);
+  }
+
+  /**
+   * {@inheritDoc}
+   */
   public void initializeAccessLogPublisher(
       FileBasedAccessLogPublisherCfg config)
       throws ConfigException, InitializationException
@@ -184,30 +196,25 @@
      // Make sure the permission is valid.
      try
      {
-       if(!currentConfig.getLogFilePermissions().equalsIgnoreCase(
-           config.getLogFilePermissions()))
+       FilePermission filePerm =
+           FilePermission.decodeUNIXMode(config.getLogFilePermissions());
+       if(!filePerm.isOwnerWritable())
        {
-         FilePermission.decodeUNIXMode(config.getLogFilePermissions());
-       }
-       if(!currentConfig.getLogFile().equalsIgnoreCase(config.getLogFile()))
-       {
-         File logFile = getFileForPath(config.getLogFile());
-         if(logFile.createNewFile())
-         {
-           logFile.delete();
-         }
+         Message message = ERR_CONFIG_LOGGING_INSANE_MODE.get(
+             config.getLogFilePermissions());
+         unacceptableReasons.add(message);
+         return false;
        }
      }
-     catch(Exception e)
+     catch(DirectoryException e)
      {
-       Message message = ERR_CONFIG_LOGGING_CANNOT_CREATE_WRITER.get(
-               config.dn().toString(),
-               stackTraceToSingleLineString(e));
+       Message message = ERR_CONFIG_LOGGING_MODE_INVALID.get(
+               config.getLogFilePermissions(), String.valueOf(e));
        unacceptableReasons.add(message);
        return false;
      }
 
-     return isConfigurationAcceptable(config, unacceptableReasons);
+     return true;
    }
 
   /**
diff --git a/opends/src/server/org/opends/server/loggers/TextAuditLogPublisher.java b/opends/src/server/org/opends/server/loggers/TextAuditLogPublisher.java
index d78002c..0cd3cb9 100644
--- a/opends/src/server/org/opends/server/loggers/TextAuditLogPublisher.java
+++ b/opends/src/server/org/opends/server/loggers/TextAuditLogPublisher.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
+ *      Portions Copyright 2006-2008 Sun Microsystems, Inc.
  */
 package org.opends.server.loggers;
 import org.opends.messages.Message;
@@ -33,6 +33,7 @@
 import java.util.*;
 
 import org.opends.server.admin.std.server.FileBasedAccessLogPublisherCfg;
+import org.opends.server.admin.std.server.AccessLogPublisherCfg;
 import org.opends.server.admin.server.ConfigurationChangeListener;
 import org.opends.server.api.*;
 import org.opends.server.config.ConfigException;
@@ -75,13 +76,23 @@
 
   private FileBasedAccessLogPublisherCfg currentConfig;
 
+  /**
+   * {@inheritDoc}
+   */
+  public boolean isConfigurationAcceptable(AccessLogPublisherCfg configuration,
+                                           List<Message> unacceptableReasons)
+  {
+    FileBasedAccessLogPublisherCfg config =
+        (FileBasedAccessLogPublisherCfg) configuration;
+    return isConfigurationChangeAcceptable(config, unacceptableReasons);
+  }
 
   /**
    * {@inheritDoc}
    */
   @Override()
   public void initializeAccessLogPublisher(
-        FileBasedAccessLogPublisherCfg config)
+      FileBasedAccessLogPublisherCfg config)
       throws ConfigException, InitializationException
   {
     File logFile = getFileForPath(config.getLogFile());
@@ -101,14 +112,14 @@
       MultifileTextWriter writer =
           new MultifileTextWriter("Multifile Text Writer for " +
               config.dn().toNormalizedString(),
-                                  config.getTimeInterval(),
-                                  fnPolicy,
-                                  perm,
-                                  errorHandler,
-                                  "UTF-8",
-                                  writerAutoFlush,
-                                  config.isAppend(),
-                                  (int)config.getBufferSize());
+              config.getTimeInterval(),
+              fnPolicy,
+              perm,
+              errorHandler,
+              "UTF-8",
+              writerAutoFlush,
+              config.isAppend(),
+              (int)config.getBufferSize());
 
       // Validate retention and rotation policies.
       for(DN dn : config.getRotationPolicyDNs())
@@ -125,8 +136,8 @@
       {
         this.writer = new AsyncronousTextWriter("Asyncronous Text Writer for " +
             config.dn().toNormalizedString(), config.getQueueSize(),
-                                              config.isAutoFlush(),
-                                              writer);
+            config.isAutoFlush(),
+            writer);
       }
       else
       {
@@ -150,7 +161,7 @@
 
     suppressInternalOperations = config.isSuppressInternalOperations();
     suppressSynchronizationOperations =
-      config.isSuppressSynchronizationOperations();
+        config.isSuppressSynchronizationOperations();
 
     currentConfig = config;
 
@@ -163,140 +174,135 @@
    * {@inheritDoc}
    */
   public boolean isConfigurationChangeAcceptable(
-       FileBasedAccessLogPublisherCfg config, List<Message> unacceptableReasons)
-   {
-     // Make sure the permission is valid.
-     try
-     {
-       if(!currentConfig.getLogFilePermissions().equalsIgnoreCase(
-           config.getLogFilePermissions()))
-       {
-         FilePermission.decodeUNIXMode(config.getLogFilePermissions());
-       }
-       if(!currentConfig.getLogFile().equalsIgnoreCase(config.getLogFile()))
-       {
-         File logFile = getFileForPath(config.getLogFile());
-         if(logFile.createNewFile())
-         {
-           logFile.delete();
-         }
-       }
-     }
-     catch(Exception e)
-     {
-       Message message = ERR_CONFIG_LOGGING_CANNOT_CREATE_WRITER.get(
-               config.dn().toString(),
-               stackTraceToSingleLineString(e));
-       unacceptableReasons.add(message);
-       return false;
-     }
+      FileBasedAccessLogPublisherCfg config, List<Message> unacceptableReasons)
+  {
+    // Make sure the permission is valid.
+    try
+    {
+      FilePermission filePerm =
+          FilePermission.decodeUNIXMode(config.getLogFilePermissions());
+      if(!filePerm.isOwnerWritable())
+      {
+        Message message = ERR_CONFIG_LOGGING_INSANE_MODE.get(
+            config.getLogFilePermissions());
+        unacceptableReasons.add(message);
+        return false;
+      }
+    }
+    catch(DirectoryException e)
+    {
+      Message message = ERR_CONFIG_LOGGING_MODE_INVALID.get(
+          config.getLogFilePermissions(), String.valueOf(e));
+      unacceptableReasons.add(message);
+      return false;
+    }
 
-     return true;
-   }
+    return true;
+  }
 
   /**
    * {@inheritDoc}
    */
-   public ConfigChangeResult applyConfigurationChange(
-       FileBasedAccessLogPublisherCfg config)
-   {
-     // Default result code.
-     ResultCode resultCode = ResultCode.SUCCESS;
-     boolean adminActionRequired = false;
-     ArrayList<Message> messages = new ArrayList<Message>();
+  public ConfigChangeResult applyConfigurationChange(
+      FileBasedAccessLogPublisherCfg config)
+  {
+    // Default result code.
+    ResultCode resultCode = ResultCode.SUCCESS;
+    boolean adminActionRequired = false;
+    ArrayList<Message> messages = new ArrayList<Message>();
 
-     suppressInternalOperations = config.isSuppressInternalOperations();
-     suppressSynchronizationOperations =
-       config.isSuppressSynchronizationOperations();
+    suppressInternalOperations = config.isSuppressInternalOperations();
+    suppressSynchronizationOperations =
+        config.isSuppressSynchronizationOperations();
 
-     File logFile = getFileForPath(config.getLogFile());
-     FileNamingPolicy fnPolicy = new TimeStampNaming(logFile);
+    File logFile = getFileForPath(config.getLogFile());
+    FileNamingPolicy fnPolicy = new TimeStampNaming(logFile);
 
-     try
-     {
-       FilePermission perm =
-           FilePermission.decodeUNIXMode(config.getLogFilePermissions());
+    try
+    {
+      FilePermission perm =
+          FilePermission.decodeUNIXMode(config.getLogFilePermissions());
 
-       boolean writerAutoFlush =
+      boolean writerAutoFlush =
           config.isAutoFlush() && !config.isAsynchronous();
 
-       TextWriter currentWriter;
-       // Determine the writer we are using. If we were writing asyncronously,
-       // we need to modify the underlaying writer.
-       if(writer instanceof AsyncronousTextWriter)
-       {
-         currentWriter = ((AsyncronousTextWriter)writer).getWrappedWriter();
-       }
-       else
-       {
-         currentWriter = writer;
-       }
+      TextWriter currentWriter;
+      // Determine the writer we are using. If we were writing asyncronously,
+      // we need to modify the underlaying writer.
+      if(writer instanceof AsyncronousTextWriter)
+      {
+        currentWriter = ((AsyncronousTextWriter)writer).getWrappedWriter();
+      }
+      else
+      {
+        currentWriter = writer;
+      }
 
-       if(currentWriter instanceof MultifileTextWriter)
-       {
-         MultifileTextWriter mfWriter = (MultifileTextWriter)currentWriter;
+      if(currentWriter instanceof MultifileTextWriter)
+      {
+        MultifileTextWriter mfWriter = (MultifileTextWriter)currentWriter;
 
-         mfWriter.setNamingPolicy(fnPolicy);
-         mfWriter.setFilePermissions(perm);
-         mfWriter.setAppend(config.isAppend());
-         mfWriter.setAutoFlush(writerAutoFlush);
-         mfWriter.setBufferSize((int)config.getBufferSize());
-         mfWriter.setInterval(config.getTimeInterval());
+        mfWriter.setNamingPolicy(fnPolicy);
+        mfWriter.setFilePermissions(perm);
+        mfWriter.setAppend(config.isAppend());
+        mfWriter.setAutoFlush(writerAutoFlush);
+        mfWriter.setBufferSize((int)config.getBufferSize());
+        mfWriter.setInterval(config.getTimeInterval());
 
-         mfWriter.removeAllRetentionPolicies();
-         mfWriter.removeAllRotationPolicies();
+        mfWriter.removeAllRetentionPolicies();
+        mfWriter.removeAllRotationPolicies();
 
-         for(DN dn : config.getRotationPolicyDNs())
-         {
-           mfWriter.addRotationPolicy(DirectoryServer.getRotationPolicy(dn));
-         }
+        for(DN dn : config.getRotationPolicyDNs())
+        {
+          mfWriter.addRotationPolicy(DirectoryServer.getRotationPolicy(dn));
+        }
 
-         for(DN dn: config.getRetentionPolicyDNs())
-         {
-           mfWriter.addRetentionPolicy(DirectoryServer.getRetentionPolicy(dn));
-         }
+        for(DN dn: config.getRetentionPolicyDNs())
+        {
+          mfWriter.addRetentionPolicy(DirectoryServer.getRetentionPolicy(dn));
+        }
 
-         if(writer instanceof AsyncronousTextWriter && !config.isAsynchronous())
-         {
-           // The asynronous setting is being turned off.
-           AsyncronousTextWriter asyncWriter = ((AsyncronousTextWriter)writer);
-           writer = mfWriter;
-           asyncWriter.shutdown(false);
-         }
+        if(writer instanceof AsyncronousTextWriter && !config.isAsynchronous())
+        {
+          // The asynronous setting is being turned off.
+          AsyncronousTextWriter asyncWriter = ((AsyncronousTextWriter)writer);
+          writer = mfWriter;
+          asyncWriter.shutdown(false);
+        }
 
-         if(!(writer instanceof AsyncronousTextWriter) &&
-             config.isAsynchronous())
-         {
-           // The asynronous setting is being turned on.
-           AsyncronousTextWriter asyncWriter =
-               new AsyncronousTextWriter("Asyncronous Text Writer for " +
-                   config.dn().toNormalizedString(), config.getQueueSize(),
-                                                     config.isAutoFlush(),
-                                                     mfWriter);
-           writer = asyncWriter;
-         }
+        if(!(writer instanceof AsyncronousTextWriter) &&
+            config.isAsynchronous())
+        {
+          // The asynronous setting is being turned on.
+          AsyncronousTextWriter asyncWriter =
+              new AsyncronousTextWriter("Asyncronous Text Writer for " +
+                  config.dn().toNormalizedString(), config.getQueueSize(),
+                  config.isAutoFlush(),
+                  mfWriter);
+          writer = asyncWriter;
+        }
 
-         if((currentConfig.isAsynchronous() && config.isAsynchronous()) &&
-             (currentConfig.getQueueSize() != config.getQueueSize()))
-         {
-           adminActionRequired = true;
-         }
+        if((currentConfig.isAsynchronous() && config.isAsynchronous()) &&
+            (currentConfig.getQueueSize() != config.getQueueSize()))
+        {
+          adminActionRequired = true;
+        }
 
-         currentConfig = config;
-       }
-     }
-     catch(Exception e)
-     {
-       Message message = ERR_CONFIG_LOGGING_CANNOT_CREATE_WRITER.get(
-               config.dn().toString(),
-               stackTraceToSingleLineString(e));
-       resultCode = DirectoryServer.getServerErrorResultCode();
-       messages.add(message);
+        currentConfig = config;
+      }
+    }
+    catch(Exception e)
+    {
+      Message message = ERR_CONFIG_LOGGING_CANNOT_CREATE_WRITER.get(
+          config.dn().toString(),
+          stackTraceToSingleLineString(e));
+      resultCode = DirectoryServer.getServerErrorResultCode();
+      messages.add(message);
 
-     }
+    }
 
-     return new ConfigChangeResult(resultCode, adminActionRequired, messages);
-   }
+    return new ConfigChangeResult(resultCode, adminActionRequired, messages);
+  }
 
 
 
@@ -431,7 +437,7 @@
       }
 
       for (List<Attribute> attrList :
-        addOperation.getOperationalAttributes().values())
+          addOperation.getOperationalAttributes().values())
       {
         for (Attribute a : attrList)
         {
@@ -777,7 +783,7 @@
    */
   @Override()
   public void logSearchResultEntry(SearchOperation searchOperation,
-                                     SearchResultEntry searchEntry)
+                                   SearchResultEntry searchEntry)
   {
   }
 
@@ -788,7 +794,7 @@
    */
   @Override()
   public void logSearchResultReference(SearchOperation searchOperation,
-                            SearchResultReference searchReference)
+                                       SearchResultReference searchReference)
   {
   }
 
diff --git a/opends/src/server/org/opends/server/loggers/TextErrorLogPublisher.java b/opends/src/server/org/opends/server/loggers/TextErrorLogPublisher.java
index 72791c4..41c8026 100644
--- a/opends/src/server/org/opends/server/loggers/TextErrorLogPublisher.java
+++ b/opends/src/server/org/opends/server/loggers/TextErrorLogPublisher.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
+ *      Portions Copyright 2006-2008 Sun Microsystems, Inc.
  */
 package org.opends.server.loggers;
 import org.opends.messages.Message;
@@ -273,6 +273,36 @@
     FileBasedErrorLogPublisherCfg config =
          (FileBasedErrorLogPublisherCfg) configuration;
 
+    return isConfigurationChangeAcceptable(config, unacceptableReasons);
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public boolean isConfigurationChangeAcceptable(
+      FileBasedErrorLogPublisherCfg config, List<Message> unacceptableReasons)
+  {
+    // Make sure the permission is valid.
+    try
+    {
+      FilePermission filePerm =
+          FilePermission.decodeUNIXMode(config.getLogFilePermissions());
+      if(!filePerm.isOwnerWritable())
+      {
+        Message message = ERR_CONFIG_LOGGING_INSANE_MODE.get(
+            config.getLogFilePermissions());
+        unacceptableReasons.add(message);
+        return false;
+      }
+    }
+    catch(DirectoryException e)
+    {
+      Message message = ERR_CONFIG_LOGGING_MODE_INVALID.get(
+          config.getLogFilePermissions(), String.valueOf(e));
+      unacceptableReasons.add(message);
+      return false;
+    }
+
     for(String overrideSeverity : config.getOverrideSeverity())
     {
       if(overrideSeverity != null)
@@ -329,41 +359,6 @@
   /**
    * {@inheritDoc}
    */
-  public boolean isConfigurationChangeAcceptable(
-      FileBasedErrorLogPublisherCfg config, List<Message> unacceptableReasons)
-  {
-    // Make sure the permission is valid.
-    try
-    {
-      if(!currentConfig.getLogFilePermissions().equalsIgnoreCase(
-          config.getLogFilePermissions()))
-      {
-        FilePermission.decodeUNIXMode(config.getLogFilePermissions());
-      }
-      if(!currentConfig.getLogFile().equalsIgnoreCase(config.getLogFile()))
-      {
-        File logFile = getFileForPath(config.getLogFile());
-        if(logFile.createNewFile())
-        {
-          logFile.delete();
-        }
-      }
-    }
-    catch(Exception e)
-    {
-      Message message = ERR_CONFIG_LOGGING_CANNOT_CREATE_WRITER.get(
-              config.dn().toString(),
-              stackTraceToSingleLineString(e));
-      unacceptableReasons.add(message);
-      return false;
-    }
-
-    return isConfigurationAcceptable(config, unacceptableReasons);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
   public ConfigChangeResult applyConfigurationChange(
       FileBasedErrorLogPublisherCfg config)
   {
diff --git a/opends/src/server/org/opends/server/loggers/debug/TextDebugLogPublisher.java b/opends/src/server/org/opends/server/loggers/debug/TextDebugLogPublisher.java
index ecf600e..7b669e9 100644
--- a/opends/src/server/org/opends/server/loggers/debug/TextDebugLogPublisher.java
+++ b/opends/src/server/org/opends/server/loggers/debug/TextDebugLogPublisher.java
@@ -38,6 +38,7 @@
 import static org.opends.server.util.ServerConstants.PROPERTY_DEBUG_TARGET;
 import org.opends.server.admin.std.server.DebugTargetCfg;
 import org.opends.server.admin.std.server.FileBasedDebugLogPublisherCfg;
+import org.opends.server.admin.std.server.DebugLogPublisherCfg;
 import org.opends.server.admin.std.meta.DebugLogPublisherCfgDefn;
 import org.opends.server.admin.server.ConfigurationChangeListener;
 import org.opends.server.admin.server.ConfigurationDeleteListener;
@@ -48,6 +49,10 @@
     ERR_CONFIG_LOGGING_CANNOT_CREATE_WRITER;
 import static org.opends.messages.ConfigMessages.
    ERR_CONFIG_LOGGING_CANNOT_OPEN_FILE;
+import static org.opends.messages.ConfigMessages.
+    ERR_CONFIG_LOGGING_INSANE_MODE;
+import static org.opends.messages.ConfigMessages.
+    ERR_CONFIG_LOGGING_MODE_INVALID;
 
 
 import java.util.*;
@@ -120,6 +125,17 @@
   /**
    * {@inheritDoc}
    */
+  public boolean isConfigurationAcceptable(DebugLogPublisherCfg configuration,
+                                           List<Message> unacceptableReasons)
+  {
+    FileBasedDebugLogPublisherCfg config =
+        (FileBasedDebugLogPublisherCfg) configuration;
+    return isConfigurationChangeAcceptable(config, unacceptableReasons);
+  }
+
+  /**
+   * {@inheritDoc}
+   */
   public void initializeDebugLogPublisher(FileBasedDebugLogPublisherCfg config)
       throws ConfigException, InitializationException
   {
@@ -237,30 +253,25 @@
     // Make sure the permission is valid.
     try
     {
-      if(!currentConfig.getLogFilePermissions().equalsIgnoreCase(
-          config.getLogFilePermissions()))
+      FilePermission filePerm =
+          FilePermission.decodeUNIXMode(config.getLogFilePermissions());
+      if(!filePerm.isOwnerWritable())
       {
-        FilePermission.decodeUNIXMode(config.getLogFilePermissions());
-      }
-      if(!currentConfig.getLogFile().equalsIgnoreCase(config.getLogFile()))
-      {
-        File logFile = getFileForPath(config.getLogFile());
-        if(logFile.createNewFile())
-        {
-          logFile.delete();
-        }
+        Message message = ERR_CONFIG_LOGGING_INSANE_MODE.get(
+            config.getLogFilePermissions());
+        unacceptableReasons.add(message);
+        return false;
       }
     }
-    catch(Exception e)
+    catch(DirectoryException e)
     {
-      Message message = ERR_CONFIG_LOGGING_CANNOT_CREATE_WRITER.get(
-              config.dn().toString(),
-              stackTraceToSingleLineString(e));
+      Message message = ERR_CONFIG_LOGGING_MODE_INVALID.get(
+          config.getLogFilePermissions(), String.valueOf(e));
       unacceptableReasons.add(message);
       return false;
     }
 
-    return isConfigurationAcceptable(config, unacceptableReasons);
+    return true;
   }
 
   /**

--
Gitblit v1.10.0