From 5e2e151b0ff0009c83d18a44cb9f564d41a25a59 Mon Sep 17 00:00:00 2001 From: Greg Lewis Date: Tue, 7 Dec 2004 20:18:04 +0000 Subject: . Some minor comment and formatting fixes (should have probably have been done separately). . Much more stringent checks on VMs that we are trying to register. This prevents most bogus and circular registrations. [1] Suggested by: Josh Elsasser [1] --- java/javavmwrapper/src/javavmwrapper.sh | 38 +++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'java') diff --git a/java/javavmwrapper/src/javavmwrapper.sh b/java/javavmwrapper/src/javavmwrapper.sh index b3685bd7e17c..ac2ade91d5cf 100644 --- a/java/javavmwrapper/src/javavmwrapper.sh +++ b/java/javavmwrapper/src/javavmwrapper.sh @@ -2,9 +2,9 @@ # # javawrapper.sh # -# Allows to install several Java Virtual Machines -# on the same system and use config file/or environment -# variable to select wichever to use +# Allow the installation of several Java Virtual Machines on the system. +# They can then be selected from based on environment variables and the +# configuration file. # # ---------------------------------------------------------------------------- # "THE BEER-WARE LICENSE" (Revision 42, (c) Poul-Henning Kamp): @@ -58,8 +58,8 @@ tryJavaCommand () { createJavaLinks () { for exe in "${1}"/bin/* "${1}"/jre/bin/*; do if [ -x "${exe}" -a \ - ! -d "${exe}" -a \ - "`basename "${exe}"`" = "`basename "${exe}" .so`" -a \ + ! -d "${exe}" -a \ + "`basename "${exe}"`" = "`basename "${exe}" .so`" -a \ ! -e "${PREFIX}/bin/`basename "${exe}"`" -a \ -w "${PREFIX}/bin" ]; then ln -s "${PREFIX}/bin/javavm" \ @@ -88,10 +88,22 @@ sortConfiguration () { export JAVAVMS while read JAVAVM; do VM=`echo "${JAVAVM}" | sed -E 's|[[:space:]]*#.*||' 2>/dev/null` - # Check the VM actually exists + # Check that the VM exists and is "sane" if [ ! -e "${VM}" ]; then continue fi + if [ -d "${VM}" ]; then + continue + fi + if [ ! -x "${VM}" ]; then + continue + fi + if [ `basename "${VM}"` != "java" ]; then + continue + fi + if [ "`realpath "${VM}" 2>/dev/null `" = "${PREFIX}/bin/javavm" ]; then + continue + fi # Skip duplicate VMs if [ ! -z "${JAVAVMS}" ]; then for _JAVAVM in ${JAVAVMS}; do @@ -266,15 +278,27 @@ registerVM () { exit 1 fi - # Check that the VM exists and is executable + # Check that the VM exists and is "sane" if [ ! -e "${VM}" ]; then echo "${IAM}: error: JavaVM \"${VM}\" does not exist" 1>&2 exit 1 fi + if [ -d "${VM}" ]; then + echo "${IAM}: error: JavaVM \"${VM}\" is a directory" 1>&2 + exit 1 + fi if [ ! -x "${VM}" ]; then echo "${IAM}: error: JavaVM \"${VM}\" is not executable" 1>&2 exit 1 fi + if [ `basename "${VM}"` != "java" ]; then + echo "${IAM}: error: JavaVM \"${VM}\" is not valid" 1>&2 + exit 1 + fi + if [ "`realpath "${VM}" 2>/dev/null `" = "${PREFIX}/bin/javavm" ]; then + echo "${IAM}: error: JavaVM \"${VM}\" is javavm!" 1>&2 + exit 1 + fi # Add the VM to the configuration file echo "${1}" >> "${CONF}" -- cgit v1.2.3