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

jvergara
02.16.2009 fd10db6b0cbd40d3803e466e5e8c53bd85de9d64
Fix for issue 4332 (Tools fail when instance path contains whitespace)
The problem is in the code in charge of checking the install and instance paths and contents. There are issues both in the scripts and in the code of org.opends.server.tools.configurator.CheckInstance. Using quotes fixes the issue in the script and using an array of String instead of a single command-line to launch the "ls" process.

Apart from that some error messages have also been fixed.
2 files modified
39 ■■■■■ changed files
opends/resource/bin/_script-util.sh 16 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/configurator/CheckInstance.java 23 ●●●● patch | view | raw | blame | history
opends/resource/bin/_script-util.sh
@@ -145,18 +145,18 @@
# Configure the appropriate CLASSPATH.
set_classpath() {
  CLASSPATH=${INSTANCE_ROOT}/classes
  for JAR in ${INSTALL_ROOT}/resources/*.jar
  CLASSPATH="${INSTANCE_ROOT}/classes"
  for JAR in "${INSTALL_ROOT}/resources/"*.jar
  do
    CLASSPATH=${CLASSPATH}:${JAR}
  done
  for JAR in ${INSTALL_ROOT}/lib/*.jar
  for JAR in "${INSTALL_ROOT}/lib/"*.jar
  do
    CLASSPATH=${CLASSPATH}:${JAR}
  done
  if [ "${INSTALL_ROOT}" != "${INSTANCE_ROOT}" ]
  then
    for JAR in ${INSTANCE_ROOT}/lib/*.jar
    for JAR in "${INSTANCE_ROOT}/lib/"*.jar
    do
      CLASSPATH=${CLASSPATH}:${JAR}
    done
@@ -192,7 +192,7 @@
if test "${INSTANCE_ROOT}" = ""
then
  if [ -f ${INSTALL_ROOT}/configure ]
  if [ -f "${INSTALL_ROOT}/configure" ]
  then
    if [ -f /etc/opends/instance.loc ]
    then
@@ -218,7 +218,7 @@
      fi
    fi
  else
    if [ -f ${INSTALL_ROOT}/instance.loc ]
    if [ -f "${INSTALL_ROOT}/instance.loc" ]
    then
      read location < ${INSTALL_ROOT}/instance.loc
      case `echo ${location}` in
@@ -256,7 +256,7 @@
  set_java_home_and_args
  set_environment_vars
  set_classpath
elif test "${SCRIPT_UTIL_CMD}" = "set-java-home-and-args"
 elif test "${SCRIPT_UTIL_CMD}" = "set-java-home-and-args"
then
  set_java_home_and_args
elif test "${SCRIPT_UTIL_CMD}" = "set-environment-vars"
@@ -308,7 +308,7 @@
      OPT_CHECK_VERSION=""
      fi
  # Launch the CheckInstance process.
      "${OPENDS_JAVA_BIN}" ${SCRIPT_NAME_ARG} -DINSTALL_ROOT=${INSTALL_ROOT} -DINSTANCE_ROOT=${INSTANCE_ROOT} org.opends.server.tools.configurator.CheckInstance --currentUser ${CURRENT_USER} ${OPT_CHECK_VERSION}
      "${OPENDS_JAVA_BIN}" ${SCRIPT_NAME_ARG} "-DINSTALL_ROOT=${INSTALL_ROOT}" "-DINSTANCE_ROOT=${INSTANCE_ROOT}" org.opends.server.tools.configurator.CheckInstance --currentUser ${CURRENT_USER} ${OPT_CHECK_VERSION}
  # return part
      RETURN_CODE=$?
      if [ ${RETURN_CODE} -ne 0 ]
opends/src/server/org/opends/server/tools/configurator/CheckInstance.java
@@ -213,16 +213,24 @@
     if (!isWin) {
    // Check user
    File conf = new File (confDir, Installation.CURRENT_CONFIG_FILE_NAME);
    String cmd = null;
    Process proc = null;
    int exit = 0;
    InputStreamReader reader = null;
    int c;
    StringBuffer sb = new StringBuffer();
    cmd = "ls -l " + conf.getAbsolutePath();
    String[] cmdArgs = {"ls", "-l", conf.getAbsolutePath()};
    StringBuilder cmd = new StringBuilder();
    for (String arg : cmdArgs)
    {
      if (cmd.length() > 0)
      {
        cmd.append(" ");
      }
      cmd.append(arg);
    }
    try {
      proc = Runtime.getRuntime().exec(cmd);
      proc = Runtime.getRuntime().exec(cmdArgs);
      proc.waitFor();
      reader = new InputStreamReader(proc.getInputStream());
      while (((c = reader.read()) != -1)) {
@@ -231,18 +239,21 @@
      exit = proc.exitValue();
      if (exit != 0) {
        LOG.log(Level.FINEST, cmd + " error= " + exit);
        System.err.println(ERR_CONFIG_LDIF_NOT_FOUND.get(conf.getAbsolutePath(),
        System.err.println(ERR_CONFIG_LDIF_NOT_FOUND.get(
            confDir.getAbsolutePath(),
            installRootFromSystem + File.separator + "instance.loc"));
        System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode());
      }
    } catch (InterruptedException ex) {
      LOG.log(Level.SEVERE, "InterruptedException" + ex.getMessage());
      System.err.println(ERR_CONFIG_LDIF_NOT_FOUND.get(conf.getAbsolutePath(),
      System.err.println(
          ERR_CONFIG_LDIF_NOT_FOUND.get(confDir.getAbsolutePath(),
          installRootFromSystem + File.separator + "instance.loc"));
      System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode());
    } catch (IOException ex) {
      LOG.log(Level.SEVERE, "IOException" + ex.getMessage() );
      System.err.println(ERR_CONFIG_LDIF_NOT_FOUND.get(conf.getAbsolutePath(),
      System.err.println(ERR_CONFIG_LDIF_NOT_FOUND.get(
          confDir.getAbsolutePath(),
          installRootFromSystem + File.separator + "instance.loc"));
      System.exit(ReturnCode.APPLICATION_ERROR.getReturnCode());
    }