Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6259802

resolution of symlinks breaks if path component is a link

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 6
    • deploy
    • b42
    • x86
    • linux

      FULL PRODUCT VERSION :
      java version "1.6.0-ea"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-ea-b32)
      Java HotSpot(TM) Client VM (build 1.6.0-ea-b32, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Linux 2.6.7 #1 Tue Jul 20 20:47:06 EDT 2004 i686 GNU/Linux
      (irrelevant)

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Debian distribution, version "Sid" (irrelevant)

      A DESCRIPTION OF THE PROBLEM :
      The resolution of symlinks in the script $JAVA_HOME/bin/ControlPanel fails if one of the intermediate directories along the path to the java executable is a symlink. For example:

      /usr/local/bin/java -> ../stow/java/bin/java
      /usr/local/stow/java/bin -> ../jdk.1.6.0/bin

      The symlink resolution code following the comment "# Resolve symlinks. See 4152645." in ControlPanel first resolves /usr/local/bin/java to /usr/local/bin/../stow/java/bin/java, but fails to resolve this path to its true canonical location, which is /usr/local/stow/jdk1.6.0/bin/java.

      This can be fixed by replacing the entire while loop of the symlink resolution code with the single line

      PRG=`readlink -f "$PRG"`

      (Incidentally, the calls to "expr foo : bar" inside the link resolution loop produces error messages comlaining about the RE bar starting with a caret. Replacing the while loop with a call to readlink takes care of those error messages as well.)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      0) assume JDK is installed in $JAVA_HOME and that $JAVA_HOME is not /tmp
      1) cd /tmp
      2) rm -fr jre
      3) ln -s "$JAVA_HOME/bin" myjavabin
      4) ./myjavabin/ControlPanel
      5) rm myjavabin

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      ControlPanel starts.
      ACTUAL -
      ControlPanel does not start.

      Instead, it aborts with an error message "... cd: ./myjavabin/../jre: No such file or directory"


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      [...] cd: ./myjavabin/../jre: No such file or directory


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      see "Step to reproduce"
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      In the ControlPanel script, Insert the line

      PRG=`readlink -f "${PRG}"`

      before the following while loop:

      while [ "${linktest}" "${PRG}" ]; do

      (In fact, the while loop can then be removed.)
      ###@###.### 2005-04-21 23:47:41 GMT

            mromanchsunw Michael Romanchuk (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: