Opened 4 years ago

Last modified 4 years ago

#22088 closed defect

[RFC PATCH] Debian start script does not properly check if a path does not exist or is not executable — at Version 1

Reported by: taylor.smock Owned by: team
Priority: normal Milestone: 22.06
Component: Core Version:
Keywords: linux Cc:

Description (last modified by taylor.smock)

I've been working on getting downstreams to use our start script (with some minor patches) to hopefully avoid future issues where we get bug reports that we've fixed in the start script.

Steps to reproduce (on Debian/Ubuntu):

  1. If /usr/lib/jvm/default-java/bin/java exists, move it (example: mv /usr/lib/jvm/default-java/bin/java /usr/lib/jvm/default-java/bin/java.bak)
  2. Attempt to run the start script
  3. If you moved /usr/lib/jvm/default-java/bin/java in step 1, move it back (example: mv /usr/lib/jvm/default-java/bin/java.bak /usr/lib/jvm/default-java/bin/java)

You may also be able to reproduce by unsetting JAVA_HOME or setting it to an empty string (e.g., JOSM_HOME="" ./josm)

From https://github.com/flathub/org.openstreetmap.josm/issues/55,

➜  ~ flatpak install flathub org.openstreetmap.josm                                                       
Looking for matches…

org.openstreetmap.josm permissions:
    ipc   network   x11   file access [1]

    [1] xdg-download


        ID                              Branch          Op          Remote          Download
 1. [✓] org.openstreetmap.josm          stable          i           flathub         78.5 MB / 76.9 MB

Installation complete.
➜  ~ flatpak run org.openstreetmap.josm
which: no dpkg in (/usr/bin:/app/bin:/app/jre/bin)
Using /usr/lib/jvm/default-java/bin/java to execute josm.
/app/bin/josm: line 91: /usr/lib/jvm/default-java/bin/java: No such file or directory

This is due to source:trunk/native/linux/tested/usr/bin/josm@18297:33,41-57#L33

Change History (3)

by taylor.smock, 4 years ago

Attachment: 22088.patch added

comment:1 by taylor.smock, 4 years ago

Description: modified (diff)
Milestone: 22.06
Summary: Debian start script does not properly check if a path does not exist or is not executable[RFC PATCH] Debian start script does not properly check if a path does not exist or is not executable

attachment:22088.patch does the following:

  • Ensure that the java command will be executable (L43)
  • Makes the script more resistant to missing links or executables (dpkg and /etc/alternatives/java specifically)

This will hopefully allow us to encourage downstream distributors to use the start script, with minor modifications (hopefully just L71).

by taylor.smock, 4 years ago

Attachment: 22088.2.patch added

Use java -version to determine JAVA_OPTS. This fixes an issue where the JAVACMD path did not include java-\d+, and should work with minimal modification for Java 20+ (presuming we do not have to add additional default JAVA_OPTS in the future). java -version is used since it works with Java 8.

Note: See TracTickets for help on using tickets.