From 1e9ad7aa5cb6ca6b42185faf075a6c12b47aa433 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Fri, 18 Jan 2008 15:03:27 +0000
Subject: [PATCH] Fix for issue 2822 (Config file should be read-protected) Update the permissions of the root file of the installation (in the diffs is proposed to be 700).  This is done in build.xml when generating the zip file and in the web start installer.

---
 opends/src/quicksetup/org/opends/quicksetup/util/ZipExtractor.java |   18 ++++++++++++++----
 opends/build.xml                                                   |    2 ++
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/opends/build.xml b/opends/build.xml
index 65315a1..ef9e2ad 100644
--- a/opends/build.xml
+++ b/opends/build.xml
@@ -948,6 +948,8 @@
   <target name="package" depends="prepackage"
        description="Package the Directory Server for distribution.">
     <zip destfile="${package.dir}/${SHORT_NAME}-${VERSION_NUMBER_STRING}.zip">
+      <zipfileset dir="${package.dir}" includes="${SHORT_NAME}-${VERSION_NUMBER_STRING}"
+           filemode="644" dirmode="700" />
       <zipfileset dir="${package.dir}" includes="${SHORT_NAME}-${VERSION_NUMBER_STRING}/**/*"
            excludes="${SHORT_NAME}-${VERSION_NUMBER_STRING}/bin/*,${SHORT_NAME}-${VERSION_NUMBER_STRING}/lib/_client-script.sh,${SHORT_NAME}-${VERSION_NUMBER_STRING}/lib/_script-util.sh,${SHORT_NAME}-${VERSION_NUMBER_STRING}/lib/_server-script.sh,${SHORT_NAME}-${VERSION_NUMBER_STRING}/lib/_mixed-script.sh,${SHORT_NAME}-${VERSION_NUMBER_STRING}/setup,${SHORT_NAME}-${VERSION_NUMBER_STRING}/uninstall,${SHORT_NAME}-${VERSION_NUMBER_STRING}/upgrade,${SHORT_NAME}-${VERSION_NUMBER_STRING}/QuickSetup.app/Contents/MacOS/JavaApplicationStub,${SHORT_NAME}-${VERSION_NUMBER_STRING}/Uninstall.app/Contents/MacOS/JavaApplicationStub,${SHORT_NAME}-${VERSION_NUMBER_STRING}/bin/StatusPanel.app/Contents/MacOS/JavaApplicationStub"
            filemode="644" dirmode="755" />
diff --git a/opends/src/quicksetup/org/opends/quicksetup/util/ZipExtractor.java b/opends/src/quicksetup/org/opends/quicksetup/util/ZipExtractor.java
index 21d4781..e226d14 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/util/ZipExtractor.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/util/ZipExtractor.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Portions Copyright 2007 Sun Microsystems, Inc.
+ *      Portions Copyright 2007-2008 Sun Microsystems, Inc.
  */
 
 package org.opends.quicksetup.util;
@@ -109,7 +109,6 @@
       zipFile.getName(),
       app);
     if (!zipFile.getName().endsWith(".zip")) {
-      // TODO i18n
       throw new IllegalArgumentException("File must have extension .zip");
     }
   }
@@ -158,7 +157,7 @@
    * @param destDir String representing the directory where the zip file will
    * be extracted
    * @param removeFirstPath when true removes each zip entry's initial path
-   * when copied to the destination folder.  So for instance if the zip enty's
+   * when copied to the destination folder.  So for instance if the zip entry's
    * name was /OpenDS-0.8/some_file the file would appear in the destination
    * directory as 'some_file'.
    * @throws ApplicationException if something goes wrong
@@ -178,7 +177,9 @@
      */
     Map<String, ArrayList<String>> permissions =
         new HashMap<String, ArrayList<String>>();
-
+    ArrayList<String> list = new ArrayList<String>();
+    list.add(destDir);
+    permissions.put(getProtectedDirectoryPermissionUnix(), list);
     try {
       if(application != null)
          application.checkAbort();
@@ -329,6 +330,15 @@
   }
 
   /**
+   * Returns the UNIX permissions to be applied to a protected directory.
+   * @return the UNIX permissions to be applied to a protected directory.
+   */
+  private String getProtectedDirectoryPermissionUnix()
+  {
+    return "700";
+  }
+
+  /**
    * Returns the file system permissions for a directory.
    * @param path the directory for which we want the file permissions.
    * @return the file system permissions for the directory.

--
Gitblit v1.10.0