From 944def16fd96af13d1aa0c618ac24b1d794faa7c Mon Sep 17 00:00:00 2001
From: boli <boli@localhost>
Date: Mon, 11 Dec 2006 20:24:27 +0000
Subject: [PATCH] Added checks to see if file permissions can be set on the platform before setting file permissions on the directory containing the database files. No errors are produced if there are no way to set the file permissions (ie. Windows and Java < 6.0).

---
 opendj-sdk/opends/src/server/org/opends/server/backends/jeb/RootContainer.java |   28 ++++++++++++++++------------
 1 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/RootContainer.java b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/RootContainer.java
index e184040..61e450c 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/RootContainer.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/RootContainer.java
@@ -146,20 +146,23 @@
                     EnvironmentConfig envConfig) throws DatabaseException
   {
     // Get the backend database backendDirectory permissions and apply
-    try
+    if(FilePermission.canSetPermissions())
     {
-      if(!FilePermission.setPermissions(backendDirectory, backendPermission))
+      try
       {
-        throw new Exception();
+        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);
+      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);
+      }
     }
 
     // Open the database environment
@@ -559,7 +562,8 @@
     FilePermission oldPermission = config.getBackendPermission();
     FilePermission newPermission = newConfig.getBackendPermission();
 
-    if(!FilePermission.toUNIXMode(oldPermission).equals(
+    if(FilePermission.canSetPermissions() &&
+        !FilePermission.toUNIXMode(oldPermission).equals(
         FilePermission.toUNIXMode(newPermission)))
     {
       try

--
Gitblit v1.10.0