Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,17 @@ jobs:
--baseDN dc=example,dc=com --sampleData 5000 --cli --acceptLicense --no-prompt \
--propertiesFilePath /tmp/opendj-setup.properties.bcfks --doNotStart

# start-ds sweeps the native libraries the BC FIPS loader leaves in tmp/ and nothing
# else: the rest of tmp/ belongs to tools that may still be running, setup among them
# (issue #1030). Without these two probes a sweep back to "tmp/*" passes every cell.
mkdir -p opendj-server-legacy/target/package/opendj/tmp/bc-fips-jni_123
touch opendj-server-legacy/target/package/opendj/tmp/keep.me

opendj-server-legacy/target/package/opendj/bin/start-ds

test ! -e opendj-server-legacy/target/package/opendj/tmp/bc-fips-jni_123
test -e opendj-server-legacy/target/package/opendj/tmp/keep.me

opendj-server-legacy/target/package/opendj/bin/status --hostname localhost --bindDN "cn=Directory Manager" --bindPassword password --trustAll
opendj-server-legacy/target/package/opendj/bin/ldapsearch --hostname localhost --port 1636 --bindDN "cn=Directory Manager" --bindPassword password --useSsl --trustAll --baseDN "dc=example,dc=com" --searchScope base "(objectClass=*)" 1.1
opendj-server-legacy/target/package/opendj/bin/ldapsearch --hostname localhost --port 1636 --bindDN "cn=Directory Manager" --bindPassword password --useSsl --trustAll --baseDN "ou=people,dc=example,dc=com" --searchScope sub "(uid=user.*)" dn | grep ^dn: | wc -l | grep -q 5000
Expand Down Expand Up @@ -394,7 +403,14 @@ jobs:
opendj-server-legacy\target\package\opendj\upgrade.bat
opendj-server-legacy\target\package\opendj\bat\import-ldif.bat --offline --ldifFile test.ldif --backendID=example2
opendj-server-legacy\target\package\opendj\bat\rebuild-index.bat --offline --bindDN "cn=Directory Manager" --bindPassword password --baseDN "dc=example2,dc=com" --rebuildAll
# The same probe as the Unix FIPS step, for start-ds.bat: the sweep takes the BC FIPS
# directories and leaves everything else in tmp\ alone (issue #1030). The runner's
# install path has no space in it, so this does not settle the quoting of the for /D line.
New-Item -ItemType Directory -Force opendj-server-legacy\target\package\opendj\tmp\bc-fips-jni_123 | Out-Null
New-Item -ItemType File -Force opendj-server-legacy\target\package\opendj\tmp\keep.me | Out-Null
opendj-server-legacy\target\package\opendj\bat\start-ds.bat
if (Test-Path opendj-server-legacy\target\package\opendj\tmp\bc-fips-jni_123) { throw "start-ds.bat left a bc-fips-jni_* directory behind" }
if (-not (Test-Path opendj-server-legacy\target\package\opendj\tmp\keep.me)) { throw "start-ds.bat removed a tmp file that is not its own" }
opendj-server-legacy\target\package\opendj\bat\rebuild-index.bat --bindDN "cn=Directory Manager" --bindPassword password --baseDN "dc=example2,dc=com" --rebuildAll --trustAll
opendj-server-legacy\target\package\opendj\bat\ldapsearch.bat --hostname localhost --port 1636 --bindDN "cn=Directory Manager" --bindPassword password --useSsl --trustAll --baseDN "dc=example2,dc=com" --searchScope sub "(uid=user.*)" dn | find /c '"dn:"' | findstr "10000"
opendj-server-legacy\target\package\opendj\bat\stop-ds.bat
Expand All @@ -409,6 +425,19 @@ jobs:
if ($LASTEXITCODE -ne 0) { throw "net stop 'OpenDJ Server' failed with exit code $LASTEXITCODE" }
opendj-server-legacy\target\package\opendj\bat\windows-service.bat --disableService

# A test step that fails leaves its instances behind. The server-side story of a
# failed start lives in logs/server.out and logs/errors, and nothing else prints it
# (setup only has the client-side view, see issue #1030).
- name: Dump the server logs of a failed test
if: failure()
shell: bash
run: |
for f in opendj-server-legacy/target/package/opendj*/logs/server.out opendj-server-legacy/target/package/opendj*/logs/errors; do
[ -f "$f" ] || continue
echo "===== $f"
cat "$f"
done

- name: Upload artifacts OpenDJ Server
uses: actions/upload-artifact@v7
with:
Expand Down
10 changes: 7 additions & 3 deletions opendj-server-legacy/resource/bin/start-ds
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#
# Copyright 2006-2009 Sun Microsystems, Inc.
# Portions Copyright 2011-2014 ForgeRock AS.
# Portions Copyright 2025 3A Systems LLC.
# Portions Copyright 2025-2026 3A Systems LLC.


# Capture the current working directory so that we can change to it later.
Expand Down Expand Up @@ -73,10 +73,14 @@ PID_FILE=${INSTANCE_ROOT}/logs/server.pid
LOG_FILE=${INSTANCE_ROOT}/logs/server.out
STARTING_FILE=${INSTANCE_ROOT}/logs/server.starting

# Cleanup the tmp directory
# Remove the native libraries the BC FIPS loader extracts into the tmp directory
# on every start, so that they do not pile up. Nothing else in there is ours to
# remove: the tmp directory is java.io.tmpdir for every tool, and a tool may
# still be running - setup starts the server through this script and keeps its
# own log open (issue #1030).
OPENDJ_TMP_DIR="${INSTANCE_ROOT}/tmp"
if [ -d "${OPENDJ_TMP_DIR}" ]; then
rm -rf ${OPENDJ_TMP_DIR}/*
rm -rf "${OPENDJ_TMP_DIR}"/bc-fips-jni_*
fi

# See if the provided set of arguments were sufficient for us to be able to
Expand Down
17 changes: 8 additions & 9 deletions opendj-server-legacy/resource/bin/start-ds.bat
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,15 @@ echo %SCRIPT%: CLASSPATH=%CLASSPATH% >> %LOG%

echo %SCRIPT%: PATH=%PATH% >> %LOG%

rem cleanup the tmp directory
set CUR_DIR=%CD%
rem Remove the native libraries the BC FIPS loader extracts into the tmp
rem directory on every start, so that they do not pile up. Nothing else in
rem there is ours to remove: the tmp directory is java.io.tmpdir for every
rem tool, and a tool may still be running - setup starts the server through
rem this script and keeps its own log open (issue #1030).
set OPENDJ_TMP_DIR=%INSTANCE_ROOT%\tmp
rem The paths must be quoted: an unquoted parenthesis (e.g. from
rem "C:\Program Files (x86)") terminates the ( ) block at parse time.
dir /b /s /a "%OPENDJ_TMP_DIR%" | findstr .>nul && (
cd /d "%OPENDJ_TMP_DIR%"
for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q>NUL 2>&1 || del "%%i" /s/q>NUL 2>&1)
cd /d "%CUR_DIR%"
)
rem %%~i drops the quotes cmd would hand back if it ever kept them: an install path with a
rem space would otherwise split the rmdir argument, and the redirect would hide it.
for /D %%i in ("%OPENDJ_TMP_DIR%\bc-fips-jni_*") do rmdir "%%~i" /s/q>NUL 2>&1

"%OPENDJ_JAVA_BIN%" -client %SCRIPT_NAME_ARG% org.opends.server.core.DirectoryServer --configFile "%INSTANCE_ROOT%\config\config.ldif" --checkStartability %*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*
* Copyright 2006-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2016 ForgeRock AS.
* Portions Copyright 2026 3A Systems, LLC.
*/
package org.opends.guitools.uninstaller;

Expand Down Expand Up @@ -129,8 +130,8 @@ protected void initializeParser()
@Override
protected void guiLaunchFailed() {
System.err.println(
tempLogFile.isEnabled() ? ERR_UNINSTALL_LAUNCHER_GUI_LAUNCHED_FAILED_DETAILS.get(tempLogFile.getPath())
: ERR_UNINSTALL_LAUNCHER_GUI_LAUNCHED_FAILED.get());
hasTempLogFile() ? ERR_UNINSTALL_LAUNCHER_GUI_LAUNCHED_FAILED_DETAILS.get(getTempLogFile().getPath())
: ERR_UNINSTALL_LAUNCHER_GUI_LAUNCHED_FAILED.get());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public final class Installation
/** The relative path where the database files are. */
private static final String DATABASES_PATH_RELATIVE = "db";
/** The relative path where the log files are. */
private static final String LOGS_PATH_RELATIVE = "logs";
public static final String LOGS_PATH_RELATIVE = "logs";
/** The relative path where the LDIF files are. */
private static final String LDIFS_PATH_RELATIVE = "ldif";
/** The relative path where the backup files are. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*
* Copyright 2008-2009 Sun Microsystems, Inc.
* Portions Copyright 2013-2016 ForgeRock AS.
* Portions Copyright 2026 3A Systems, LLC.
*/
package org.opends.quicksetup;

Expand All @@ -21,6 +22,7 @@
import static org.opends.messages.QuickSetupMessages.*;
import static org.opends.server.util.DynamicConstants.*;

import java.io.File;
import java.io.PrintStream;

import org.forgerock.i18n.LocalizableMessage;
Expand All @@ -40,8 +42,14 @@ public abstract class Launcher {
/** Arguments with which this launcher was invoked. */
protected final String[] args;

/** The temporary log file which will be kept if an error occurs. */
protected final TempLogFile tempLogFile;
private final String tempLogFilePrefix;
private final File tempLogFileDirectory;
/**
* The temporary log file which will be kept if an error occurs; see {@link #getTempLogFile()}.
* Volatile because the GUI road asks for it from the thread that runs the splash screen and
* the roads after it read it from the main thread.
*/
private volatile TempLogFile tempLogFile;

/**
* Creates a Launcher.
Expand All @@ -52,11 +60,55 @@ public abstract class Launcher {
* temporary log file path where messages will be logged
*/
public Launcher(final String[] args, final String tempLogFilePrefix) {
this(args, tempLogFilePrefix, null);
}

/**
* Creates a Launcher whose temporary log file lives in the given directory.
*
* @param args
* String[] of argument passes from the command line
* @param tempLogFilePrefix
* temporary log file path where messages will be logged
* @param tempLogFileDirectory
* the directory to create the temporary log file in, or {@code null} for the OS
* temporary directory
*/
public Launcher(final String[] args, final String tempLogFilePrefix, final File tempLogFileDirectory) {
if (args == null) {
throw new IllegalArgumentException("args cannot be null");
}
this.args = args;
this.tempLogFile = TempLogFile.newTempLogFile(tempLogFilePrefix);
this.tempLogFilePrefix = tempLogFilePrefix;
this.tempLogFileDirectory = tempLogFileDirectory;
}

/**
* The temporary log file of this launcher, created the first time it is asked for.
* <p>
* Creating it costs a file - and, with a directory of the caller's choosing, the directory
* as well - that nothing removes afterwards unless the operation succeeds. So it is created
* on the first road that can fail an operation and not before: {@code --help},
* {@code --version}, a usage error and the other roads that attempt nothing leave no log
* behind (issue #1030).
*
* @return the temporary log file, creating it if this is the first call.
*/
protected synchronized TempLogFile getTempLogFile() {
if (tempLogFile == null) {
tempLogFile = TempLogFile.newTempLogFile(tempLogFilePrefix, tempLogFileDirectory);
}
return tempLogFile;
}

/**
* Whether there is a log to name, without creating one to answer.
*
* @return {@code true} if a temporary log file has been created and can be used to log
* messages.
*/
protected boolean hasTempLogFile() {
return tempLogFile != null && tempLogFile.isEnabled();
}

/**
Expand Down Expand Up @@ -194,12 +246,12 @@ public void run()
{
try
{
SplashScreen.main(tempLogFile, args);
SplashScreen.main(getTempLogFile(), args);
returnValue[0] = 0;
}
catch (Throwable t)
{
if (tempLogFile.isEnabled())
if (hasTempLogFile())
{
logger.warn(LocalizableMessage.raw("Error launching GUI: "+t));
StringBuilder buf = new StringBuilder();
Expand Down Expand Up @@ -337,6 +389,9 @@ else if (shouldPrintUsage()) {
}
System.exit(ReturnCode.SUCCESSFUL.getReturnCode());
} else if (isCli()) {
// An operation is about to run: from here on there is something worth logging, and
// preExit() names the file. The roads above attempt nothing and leave no log behind.
getTempLogFile();
CliApplication cliApp = createCliApplication();
int exitCode = launchCli(cliApp);
preExit(cliApp);
Expand All @@ -361,8 +416,8 @@ private void preExit(CliApplication cliApp) {

// Add an extra space systematically
System.out.println();
if (tempLogFile.isEnabled()) {
System.out.println(INFO_GENERAL_SEE_FOR_DETAILS.get(tempLogFile.getPath()));
if (hasTempLogFile()) {
System.out.println(INFO_GENERAL_SEE_FOR_DETAILS.get(getTempLogFile().getPath()));
}
}
}
Expand Down
Loading
Loading