aboutsummaryrefslogtreecommitdiff
path: root/java/javavmwrapper/src
diff options
context:
space:
mode:
authorGreg Lewis <glewis@FreeBSD.org>2004-12-07 20:18:04 +0000
committerGreg Lewis <glewis@FreeBSD.org>2004-12-07 20:18:04 +0000
commit5e2e151b0ff0009c83d18a44cb9f564d41a25a59 (patch)
tree978a5f604d9cd60066581cc7a3c382bfc023e5dd /java/javavmwrapper/src
parentbe0393db47a7519e941b46f7b6b1f14ced70d82e (diff)
downloadports-5e2e151b0ff0009c83d18a44cb9f564d41a25a59.tar.gz
ports-5e2e151b0ff0009c83d18a44cb9f564d41a25a59.zip
. 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 <josh@elsasser.org> [1]
Notes
Notes: svn path=/head/; revision=123409
Diffstat (limited to 'java/javavmwrapper/src')
-rw-r--r--java/javavmwrapper/src/javavmwrapper.sh38
1 files changed, 31 insertions, 7 deletions
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}"