From 006982fba689b10a553f4327fa52c9461c392307 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Tue, 27 Oct 2026 08:34:32 +0000
Subject: [PATCH] [#1229] Look for java on the PATH of the caller in upgrade, before it narrows PATH to /bin:/usr/bin (#1230)
---
.github/workflows/build.yml | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index af01eed..d65e40c 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -711,6 +711,15 @@
test "$(docker exec test grep -c "The Directory Server is now stopped" /opt/opendj/data/logs/errors)" -gt "$stopped"
docker exec test 'sh' '-c' '/opt/opendj/bin/rebuild-index --hostname localhost --port 4444 --bindDN "cn=Directory Manager" --bindPassword password --baseDN "dc=example2,dc=com" --rebuildAll --trustAll'
docker exec test 'sh' '-c' '/opt/opendj/bin/ldapsearch --hostname localhost --port 1636 --bindDN "cn=Directory Manager" --bindPassword password --useSsl --trustAll --baseDN "ou=people,dc=example2,dc=com" --searchScope sub "(uid=user.*)" dn | grep ^dn: | wc -l | grep -q 10000'
+ # upgrade looks for java before it narrows PATH to /bin:/usr/bin, as the other tools do:
+ # the java of the default image is on the PATH from /opt/java/openjdk/bin alone (alpine has
+ # /usr/bin/java, so only the default row can fail), and run.sh runs upgrade on every start of a volume (#1229)
+ docker exec test sh -c 'unset JAVA_HOME; sh /opt/opendj/upgrade -n --force'
+ # upgrade runs set_environment_vars twice: the module flags reach the JVM once
+ docker exec test sh -c 'OPENDJ_JAVA_BIN=$(command -v java) INSTALL_ROOT=/opt/opendj INSTANCE_ROOT=/opt/opendj SCRIPT_NAME=upgrade; export OPENDJ_JAVA_BIN INSTALL_ROOT INSTANCE_ROOT SCRIPT_NAME; SCRIPT_UTIL_CMD=set-environment-vars; . /opt/opendj/lib/_script-util.sh; . /opt/opendj/lib/_script-util.sh; test "$(echo " $OPENDJ_JAVA_ARGS " | tr " " "\n" | grep -c -- "^--add-opens$")" -eq 1'
+ # a java found nowhere is reported without a shell error about the empty lookup
+ out=$(docker exec test sh -c 'unset JAVA_HOME; PATH=/bin:/usr/bin /opt/opendj/bin/ldapsearch --version' 2>&1 || true)
+ if grep -F "unexpected operator" <<<"$out"; then echo "::error::The lookup of java on the PATH fails with a shell error where it finds no java"; false; fi
docker rm -f test
- name: Docker test custom password
shell: bash
--
Gitblit v1.10.0