From 93bface962b1d23ccc5dc6a94515b25e3f9af5a2 Mon Sep 17 00:00:00 2001 From: maximthomas Date: Tue, 10 Feb 2026 14:42:57 +0300 Subject: [PATCH 1/4] Fallback to $HOME/tmp dir as a temp if instance root is mounted as noexec --- opendj-server-legacy/resource/bin/_script-util.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/opendj-server-legacy/resource/bin/_script-util.sh b/opendj-server-legacy/resource/bin/_script-util.sh index 0fb0d21267..fb08edf0cf 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 # @@ -85,6 +85,18 @@ set_opendj_java_bin() { set_temp_dir() { OPENDJ_TMP_DIR="${INSTANCE_ROOT}/tmp" + # check if instance root is mounted as noexec + if volume=`df -P ${INSTANCE_ROOT} | tail -1 | awk '{print $6}'` && mount | grep "$volume " | grep -q noexec; then + OPENDJ_TMP_DIR=${HOME}/tmp + if [ ! -d "${OPENDJ_TMP_DIR}" ]; then #show warning if temp directory does not exist + echo "WARNING: instance root $INSTANCE_ROOT is mounted as noexec, switching to $HOME/tmp as a tmpdir" + fi + fi + + if volume=`df -P ${HOME} | tail -1 | awk '{print $6}'` && mount | grep "$volume " | grep -q noexec; then + echo "WARNING: $HOME/tmp is mounted as noexec, the OpenDJ installation could cause errors" + fi + if [ ! -d "${OPENDJ_TMP_DIR}" ]; then mkdir ${OPENDJ_TMP_DIR} fi From 86db5b5bfa822b2fb799ac32582983d0cfd0e5a2 Mon Sep 17 00:00:00 2001 From: maximthomas Date: Wed, 11 Feb 2026 13:16:20 +0300 Subject: [PATCH 2/4] Add a file execution possibility check --- opendj-server-legacy/resource/bin/_script-util.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/opendj-server-legacy/resource/bin/_script-util.sh b/opendj-server-legacy/resource/bin/_script-util.sh index fb08edf0cf..b58a61e8be 100644 --- a/opendj-server-legacy/resource/bin/_script-util.sh +++ b/opendj-server-legacy/resource/bin/_script-util.sh @@ -85,17 +85,23 @@ set_opendj_java_bin() { set_temp_dir() { OPENDJ_TMP_DIR="${INSTANCE_ROOT}/tmp" - # check if instance root is mounted as noexec - if volume=`df -P ${INSTANCE_ROOT} | tail -1 | awk '{print $6}'` && mount | grep "$volume " | grep -q noexec; then + # check if instance root is mounted as noexec & current user is able to execute files + TMP_FILE=`mktemp ${INSTANCE_ROOT}/temp.XXXXXX` + chmod +x ${TMP_FILE} + if ! ${TMP_FILE} 2>/dev/null; then OPENDJ_TMP_DIR=${HOME}/tmp if [ ! -d "${OPENDJ_TMP_DIR}" ]; then #show warning if temp directory does not exist echo "WARNING: instance root $INSTANCE_ROOT is mounted as noexec, switching to $HOME/tmp as a tmpdir" fi fi + rm -rf ${TMP_FILE} - if volume=`df -P ${HOME} | tail -1 | awk '{print $6}'` && mount | grep "$volume " | grep -q noexec; then + TMP_FILE=`mktemp ${HOME}/temp.XXXXXX` + chmod +x ${TMP_FILE} + if ! ${TMP_FILE} 2>/dev/null; then echo "WARNING: $HOME/tmp is mounted as noexec, the OpenDJ installation could cause errors" fi + rm -rf ${TMP_FILE} if [ ! -d "${OPENDJ_TMP_DIR}" ]; then mkdir ${OPENDJ_TMP_DIR} From 166ffb9fb164fafcd845f7229f6a81eafba88f11 Mon Sep 17 00:00:00 2001 From: maximthomas Date: Fri, 13 Feb 2026 08:52:57 +0300 Subject: [PATCH 3/4] Add a temporary file execution possibility check for tmp directory --- .../resource/bin/_script-util.sh | 54 +++++++++++++------ 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/opendj-server-legacy/resource/bin/_script-util.sh b/opendj-server-legacy/resource/bin/_script-util.sh index b58a61e8be..6d71592fbb 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-2026 3A Systems, LLC. +# Portions Copyright 2019-2025 3A Systems, LLC. # # Display an error message # @@ -83,26 +83,51 @@ set_opendj_java_bin() { export OPENDJ_JAVA_BIN } -set_temp_dir() { - OPENDJ_TMP_DIR="${INSTANCE_ROOT}/tmp" - # check if instance root is mounted as noexec & current user is able to execute files - TMP_FILE=`mktemp ${INSTANCE_ROOT}/temp.XXXXXX` - chmod +x ${TMP_FILE} - if ! ${TMP_FILE} 2>/dev/null; then - OPENDJ_TMP_DIR=${HOME}/tmp - if [ ! -d "${OPENDJ_TMP_DIR}" ]; then #show warning if temp directory does not exist - echo "WARNING: instance root $INSTANCE_ROOT is mounted as noexec, switching to $HOME/tmp as a tmpdir" - fi +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 - rm -rf ${TMP_FILE} - TMP_FILE=`mktemp ${HOME}/temp.XXXXXX` + local TMP_FILE=`mktemp ${DIR_TO_TEST}/temp.XXXXXX` + chmod +x ${TMP_FILE} if ! ${TMP_FILE} 2>/dev/null; then - echo "WARNING: $HOME/tmp is mounted as noexec, the OpenDJ installation could cause errors" + res=1 fi + rm -rf ${TMP_FILE} + if [ $remove_dir = 1 ]; then + rm -rf $DIR_TO_TEST + fi + + return $res +} + +set_temp_dir() { + + OPENDJ_TMP_DIR="${INSTANCE_ROOT}/tmp" + + check_noexec "${OPENDJ_TMP_DIR}" + local res=$? + if [ $res = 1 ]; then + if [ "$SCRIPT_NAME" = "setup" ] ; then + echo "WARNING: instance root $INSTANCE_ROOT is mounted as noexec, switching to $HOME/tmp as a tmpdir" + fi + OPENDJ_TMP_DIR=${HOME}/tmp + check_noexec "${OPENDJ_TMP_DIR}" + res=$? + if [ $res = 1 ] && [ "$SCRIPT_NAME" = "setup" ]; then + echo "WARNING: $HOME/tmp is mounted as noexec, the OpenDJ installation could cause errors" + fi + fi + + if [ ! -d "${OPENDJ_TMP_DIR}" ]; then mkdir ${OPENDJ_TMP_DIR} fi @@ -351,4 +376,3 @@ elif test "${SCRIPT_UTIL_CMD}" = "test-java" then test_java fi - From 2922dc167b75ae99ce22fcc621dafa70581c878c Mon Sep 17 00:00:00 2001 From: maximthomas Date: Fri, 13 Feb 2026 10:39:41 +0300 Subject: [PATCH 4/4] update copyright --- opendj-server-legacy/resource/bin/_script-util.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opendj-server-legacy/resource/bin/_script-util.sh b/opendj-server-legacy/resource/bin/_script-util.sh index 6d71592fbb..6f6176480f 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 #