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
37 ■■■■■ changed files
opends/resource/bin/_script-util.sh 14 ●●●● 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
@@ -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());
    }