From 04ead8f1c81d759108686bbd4add4b9eee542c2e Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Wed, 11 Apr 2007 18:51:40 +0000
Subject: [PATCH] During schema and configuration upgrade, the server is started 'in process' without any connection handlers and the changes are made using an internal connection to the server. During configuration/schema updates:
---
opends/src/quicksetup/org/opends/quicksetup/util/Utils.java | 69 ++++++++++++++++++++++++++++++++++
1 files changed, 69 insertions(+), 0 deletions(-)
diff --git a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
index 2ac5655..92583af 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -679,6 +679,27 @@
return p.waitFor();
}
+ /**
+ * Sets the permissions of the provided paths with the provided permission
+ * String.
+ * @param path to set permissions on.
+ * @param permissions the UNIX-mode file system permission representation
+ * (for example "644" or "755")
+ * @return the return code of the chmod command.
+ * @throws IOException if something goes wrong.
+ * @throws InterruptedException if the Runtime.exec method is interrupted.
+ */
+ public static int setPermissionsUnix(String path,
+ String permissions) throws IOException, InterruptedException
+ {
+ String[] args = new String[3];
+ args[0] = "chmod";
+ args[1] = permissions;
+ args[2] = path;
+ Process p = Runtime.getRuntime().exec(args);
+ return p.waitFor();
+ }
+
// Very limited for the moment: apply only permissions to the current user and
// does not work in non-English environments... to work in non English we
// should use xcalcs but it does not come in the windows default install...
@@ -1204,4 +1225,52 @@
return sb.toString();
}
+ /**
+ * Returns the file system permissions for a file.
+ * @param path the file for which we want the file permissions.
+ * @return the file system permissions for the file.
+ */
+ static public String getFileSystemPermissions(String path)
+ {
+ return getFileSystemPermissions(new File(path));
+ }
+
+ /**
+ * Returns the file system permissions for a file.
+ * @param file the file for which we want the file permissions.
+ * @return the file system permissions for the file.
+ */
+ static public String getFileSystemPermissions(File file)
+ {
+ String perm;
+ String name = file.getName();
+ if (file.getParent().endsWith(
+ File.separator + Installation.WINDOWS_BINARIES_PATH_RELATIVE) ||
+ file.getParent().endsWith(
+ File.separator + Installation.UNIX_BINARIES_PATH_RELATIVE))
+ {
+ if (name.endsWith(".bat"))
+ {
+ perm = "644";
+ }
+ else
+ {
+ perm = "755";
+ }
+ }
+ else if (name.endsWith(".sh"))
+ {
+ perm = "755";
+ } else if (name.endsWith(Installation.UNIX_SETUP_FILE_NAME) ||
+ name.endsWith(Installation.UNIX_UNINSTALL_FILE_NAME) ||
+ name.endsWith(Installation.UNIX_UPGRADE_FILE_NAME))
+ {
+ perm = "755";
+ } else
+ {
+ perm = "644";
+ }
+ return perm;
+ }
+
}
--
Gitblit v1.10.0