From bb7cc6f660aed74d2018cb6b83d04d2674ef7154 Mon Sep 17 00:00:00 2001
From: Maxim Thomas <maxim.thomas@gmail.com>
Date: Thu, 26 Feb 2026 16:24:36 +0000
Subject: [PATCH] [#590] Fallback to $HOME/tmp dir as a temp if instance root is mounted as noexec (#591)
---
opendj-server-legacy/resource/bin/_script-util.sh | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/opendj-server-legacy/resource/bin/_script-util.sh b/opendj-server-legacy/resource/bin/_script-util.sh
index 0fb0d21..66f04f6 100644
--- a/opendj-server-legacy/resource/bin/_script-util.sh
+++ b/opendj-server-legacy/resource/bin/_script-util.sh
@@ -14,7 +14,7 @@
#
# Copyright 2008-2010 Sun Microsystems, Inc.
# Portions Copyright 2010-2016 ForgeRock AS.
-# Portions Copyright 2019-2025 3A Systems, LLC.
+# Portions Copyright 2019-2026 3A Systems, LLC.
#
# Display an error message
#
@@ -83,8 +83,62 @@
export OPENDJ_JAVA_BIN
}
+check_noexec() { #returns 0 if can execute files in the directory, otherwise 1
+ local DIR_TO_TEST=$1
+ local res=0
+ local remove_dir=0
+
+ if [ ! -d "${DIR_TO_TEST}" ]; then
+ remove_dir=1
+ mkdir ${DIR_TO_TEST}
+ fi
+
+ local TMP_FILE=`mktemp ${DIR_TO_TEST}/temp.XXXXXX`
+
+ chmod +x ${TMP_FILE}
+ if ! ${TMP_FILE} 2>/dev/null; then
+ res=1
+ fi
+
+ rm -rf ${TMP_FILE}
+
+ if [ $remove_dir = 1 ]; then
+ rm -rf $DIR_TO_TEST
+ fi
+
+ return $res
+}
+
+set_bc_dir() {
+ if echo "$OPENDJ_JAVA_ARGS" | grep -q -o "\-Dorg.bouncycastle.native.loader.install_dir=[^ ]*"; then
+ return # bc install dir already set
+ fi
+
+ check_noexec "${OPENDJ_TMP_DIR}"
+ local res=$?
+ if [ $res = 1 ]; then
+ if [ "$SCRIPT_NAME" = "setup" ]; then
+ echo "WARNING: $OPENDJ_TMP_DIR is mounted as noexec, try switching to $HOME for org.bouncycastle.native.loader.install_dir"
+ fi
+ check_noexec "${HOME}"
+ res=$?
+ if [ $res = 0 ]; then
+ OPENDJ_JAVA_ARGS="${OPENDJ_JAVA_ARGS} -Dorg.bouncycastle.native.loader.install_dir=${HOME}"
+ elif [ "$SCRIPT_NAME" = "setup" ]; then
+ echo "WARNING: $HOME is mounted as noexec, the OpenDJ installation could cause errors"
+ fi
+ fi
+}
+
set_temp_dir() {
+
+ if echo "$OPENDJ_JAVA_ARGS" | grep -q -o "\-Djava.io.tmpdir=[^ ]*"; then
+ OPENDJ_TMP_DIR=$(echo "$OPENDJ_JAVA_ARGS" | grep -o "\-Djava.io.tmpdir=[^ ]*" | cut -d'=' -f2)
+ return # temp dir already set
+ fi
+
OPENDJ_TMP_DIR="${INSTANCE_ROOT}/tmp"
+
if [ ! -d "${OPENDJ_TMP_DIR}" ]; then
mkdir ${OPENDJ_TMP_DIR}
fi
@@ -110,6 +164,7 @@
fi
fi
set_temp_dir
+ set_bc_dir
set_opendj_java_bin
}
@@ -333,4 +388,3 @@
then
test_java
fi
-
--
Gitblit v1.10.0