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

jvergara
16.41.2007 c1621947fe4af5e189f440d711f855a51850712a
Fix for issue 1618 unable to install to folder with DN syntax.

There is a problem in windows when we launch scripts using Runtime.exec if the script path contains a '=' character. The fix consists on quoting the script paths on windows when we launch them using Runtime.exec.
9 files modified
67 ■■■■ changed files
opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelController.java 6 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java 3 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java 6 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ExternalTools.java 5 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java 7 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java 12 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/tools/ConfigureWindowsService.java 3 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/util/CertificateManager.java 2 ●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/util/SetupUtils.java 23 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelController.java
@@ -560,7 +560,8 @@
    ArrayList<String> argList = new ArrayList<String>();
    Installation installation = Installation.getLocal();
    argList.add(Utils.getPath(installation.getServerStartCommandFile()));
    argList.add(Utils.getScriptPath(
        Utils.getPath(installation.getServerStartCommandFile())));
    String[] args = new String[argList.size()];
    argList.toArray(args);
@@ -674,7 +675,8 @@
    ArrayList<String> argList = new ArrayList<String>();
    Installation installation = Installation.getLocal();
    argList.add(Utils.getPath(installation.getServerStopCommandFile()));
    argList.add(Utils.getScriptPath(
        Utils.getPath(installation.getServerStopCommandFile())));
    String[] args = new String[argList.size()];
    argList.toArray(args);
    ProcessBuilder pb = new ProcessBuilder(args);
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java
@@ -90,7 +90,8 @@
          throws ApplicationException {
    BuildInformation bi = new BuildInformation();
    List<String> args = new ArrayList<String>();
    args.add(Utils.getPath(installation.getServerStartCommandFile()));
    args.add(Utils.getScriptPath(
        Utils.getPath(installation.getServerStartCommandFile())));
    args.add("-F"); // full verbose
    ProcessBuilder pb = new ProcessBuilder(args);
    InputStream is = null;
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java
@@ -398,10 +398,12 @@
          if (isMacOS()) {
            ArrayList<String> cmd = new ArrayList<String>();
            cmd.add(MAC_APPLICATIONS_OPENER);
            cmd.add(getPath(installation.getStatusPanelCommandFile()));
            cmd.add(getScriptPath(
                getPath(installation.getStatusPanelCommandFile())));
            pb = new ProcessBuilder(cmd);
          } else {
            String cmd = getPath(installation.getStatusPanelCommandFile());
            String cmd = getScriptPath(
                getPath(installation.getStatusPanelCommandFile()));
            pb = new ProcessBuilder(cmd);
          }
          Map<String, String> env = pb.environment();
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ExternalTools.java
@@ -72,7 +72,8 @@
          throws IOException, InterruptedException {
    String toolName = Installation.BACKUP;
    List<String> args = new ArrayList<String>();
    args.add(Utils.getPath(installation.getCommandFile(toolName)));
    args.add(Utils.getScriptPath(
        Utils.getPath(installation.getCommandFile(toolName))));
    args.add("-a"); // backup all
    args.add("-d"); // backup to directory
    args.add(Utils.getPath(backupDir));
@@ -94,7 +95,7 @@
    List<String> args = new ArrayList<String>();
    args.add(Utils.getPath(installation.getCommandFile(toolName)));
    args.add("-s"); // source LDIF
    args.add(Utils.getPath(source));
    args.add(Utils.getScriptPath(Utils.getPath(source)));
    args.add("-t"); // target LDIF
    args.add(Utils.getPath(target));
    if (otherArgs != null) {
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java
@@ -124,7 +124,8 @@
      LOG.log(Level.INFO, "stopping server");
      ArrayList<String> argList = new ArrayList<String>();
      argList.add(Utils.getPath(installation.getServerStopCommandFile()));
      argList.add(Utils.getScriptPath(
          Utils.getPath(installation.getServerStopCommandFile())));
      String[] args = new String[argList.size()];
      argList.toArray(args);
      ProcessBuilder pb = new ProcessBuilder(args);
@@ -285,7 +286,8 @@
    LOG.log(Level.INFO, "starting server");
    ArrayList<String> argList = new ArrayList<String>();
    argList.add(Utils.getPath(installation.getServerStartCommandFile()));
    argList.add(Utils.getScriptPath(
        Utils.getPath(installation.getServerStartCommandFile())));
    String[] args = new String[argList.size()];
    argList.toArray(args);
    ProcessBuilder pb = new ProcessBuilder(args);
@@ -298,7 +300,6 @@
    // when it starts.  Since we're just calling the start-ds script
    // it will figure out the correct classpath for the server.
    env.remove("CLASSPATH");
    try
    {
      String startedId = getStartedId();
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -134,6 +134,18 @@
  }
  /**
   * Returns the String that can be used to launch an script using Runtime.exec.
   * This method is required because in Windows the script that contain a "="
   * in their path must be quoted.
   * @param script the script name
   * @return the absolute path for the given parentPath and relativePath.
   */
  public static String getScriptPath(String script)
  {
    return SetupUtils.getScriptPath(script);
  }
  /**
   * Returns the absolute path for the given parentPath and relativePath.
   * @param f File to get the path
   * @return the absolute path for the given parentPath and relativePath.
opendj-sdk/opends/src/server/org/opends/server/tools/ConfigureWindowsService.java
@@ -773,7 +773,8 @@
   */
  private static String getBinaryFullPath()
  {
    return getServerRoot()+"\\lib\\opends_service.exe";
    return SetupUtils.getScriptPath(
        getServerRoot()+"\\lib\\opends_service.exe");
  }
  /**
opendj-sdk/opends/src/server/org/opends/server/util/CertificateManager.java
@@ -152,7 +152,7 @@
      keytoolCommand = null;
    }
    KEYTOOL_COMMAND = keytoolCommand;
    KEYTOOL_COMMAND = SetupUtils.getScriptPath(keytoolCommand);
  }
opendj-sdk/opends/src/server/org/opends/server/util/SetupUtils.java
@@ -487,5 +487,28 @@
  {
    return "true".equals(System.getProperty(IS_WEBSTART));
  }
  /**
   * Returns the String that can be used to launch an script using Runtime.exec.
   * This method is required because in Windows the script that contain a "="
   * in their path must be quoted.
   * @param script the script name
   * @return the absolute path for the given parentPath and relativePath.
   */
  public static String getScriptPath(String script)
  {
    String s = script;
    if (isWindows())
    {
      if (s != null)
      {
        if (!s.startsWith("\"") || !s.endsWith("\""))
        {
          s = "\""+script+"\"";
        }
      }
    }
    return s;
  }
}