Кубок И.Н. Векуа - 2008

Ilya N.Vekua
 

Используемая на сервере реализация Java - Java 1.6.0_10

Компиляция программ на Java осуществляется следующим скриптом:

prefix="/home/ejudge/system"
exec_prefix="${prefix}"
libexecdir="${exec_prefix}/libexec"

infile="$1"
outfile="$2"

JAVACRUN="/usr/java/jdk1.6.0_04/bin/javac"
JAVADIR="/usr/java/jdk1.6.0_04"
JAVAVER="1.6"

if [ x"${JAVACRUN}" = x -o x"${JAVACRUN}" = xno ]
then
  echo "This language is not supported." >&2
  exit 1
fi

# avoid setting JAVA_HOME if it is already set
if [ "${JAVA_HOME}" = "" ]
then
    JAVA_HOME="${JAVADIR}"
    PATH="${JAVA_HOME}/bin:${PATH}"
    export JAVA_HOME PATH
fi

rm -f *.class
exec "${libexecdir}/ejudge/lang/ej-javac" "${infile}" "${outfile}" "${JAVACRUN}" "${JAVAVER}" "${JAVA_HOME}"

Запуск программ на Java осуществляется следующим скриптом:

# assume that we have single argument
# EJUDGE_JAVA_FLAGS may be used to pass additional flags
# EJUDGE_JAVA_POLICY is the policy name
# EJUDGE_PREFIX_DIR is used to create the full path

runfile="$1"

JAVARUN="/usr/java/jdk1.6.0_04/bin/java"
JAVADIR="/usr/java/jdk1.6.0_04"
JAVAVER="1.6"

# avoid setting JAVA_HOME if it is already set
if [ "${JAVA_HOME}" = "" ]
then
    JAVA_HOME="${JAVADIR}"
    PATH="${JAVA_HOME}/bin:${PATH}"
    export JAVA_HOME PATH
fi

if [ x"${EJUDGE_JAVA_POLICY}" = xnone ]
then
  # no security policy, use with caution!
  mv "$1" Main.jar || exit 128
  exec "${JAVARUN}" ${EJUDGE_JAVA_FLAGS} -jar ./Main.jar
fi

[ x"${EJUDGE_JAVA_POLICY}" = x ] && EJUDGE_JAVA_POLICY=default.policy

if [ -f "${EJUDGE_JAVA_POLICY}" ]
then
  policy_file="${EJUDGE_JAVA_POLICY}"
else
  if [ x"${EJUDGE_PREFIX_DIR}" = x ]
  then
    echo "EJUDGE_PREFIX_DIR is not set - impossible to set security policy" >&2
    exit 128
  fi
  policy_file="${EJUDGE_PREFIX_DIR}/share/ejudge/${EJUDGE_JAVA_POLICY}"
fi

if [ ! -f "${policy_file}" ]
then
  echo "Java policy file does not exist" >&2
  exit 128
fi

mv "$1" Main.jar || exit 128
exec "${JAVARUN}" -server ${EJUDGE_JAVA_FLAGS} -Djava.security.manager -Duser.language=us -Duser.country=US -Duser.variant=US -Djava.security.policy="${policy_file}" -jar ./Main.jar