From 9cb96f973ab1bb0d36bd4960eb243c5db839e988 Mon Sep 17 00:00:00 2001 From: Gilles Querret Date: Wed, 1 Feb 2023 13:15:10 +0100 Subject: [PATCH] IndexRebuild task: don't use passphrase if envVar or CmdLine is an empty string --- src/java/com/phenix/pct/PCTIndexRebuild.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/java/com/phenix/pct/PCTIndexRebuild.java b/src/java/com/phenix/pct/PCTIndexRebuild.java index b4d62c419..ec96615e5 100644 --- a/src/java/com/phenix/pct/PCTIndexRebuild.java +++ b/src/java/com/phenix/pct/PCTIndexRebuild.java @@ -163,9 +163,9 @@ private ExecTask idxBuildCmdLine() { exec.createArg().setValue(cpInternal); } - if ((passphraseEnvVar != null) || (passphraseCmdLine != null)) { + if (hasCmdLinePassphrase() || hasEnvPassphrase()) { exec.createArg().setValue("-Passphrase"); - if (passphraseEnvVar != null) { + if (hasEnvPassphrase()) { exec.setInputString(System.getenv(passphraseEnvVar) + System.lineSeparator() + generateInputString()); } else { exec.setInputString(getPassphraseFromCmdLine(passphraseCmdLine) + System.lineSeparator() + generateInputString()); @@ -182,4 +182,12 @@ private ExecTask idxBuildCmdLine() { return exec; } + private boolean hasCmdLinePassphrase() { + return (passphraseCmdLine != null) && !passphraseCmdLine.trim().isEmpty(); + } + + private boolean hasEnvPassphrase() { + return (passphraseEnvVar != null) && !passphraseEnvVar.trim().isEmpty(); + } + } \ No newline at end of file