select_vars: Set "expected" values ONLY when "$PWD/pki/vars" is used

Vars 'expected_EASYRSA' and 'expected_EASYRSA_PKI' must only be set
when "$PWD/pki/vars" is used. This is the only file which can set the
PKI to an "unexpected" location.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
This commit is contained in:
Richard T Bonhomme 2023-09-29 03:02:34 +01:00
parent 302fa37a79
commit 29bd64ceb0
No known key found for this signature in database
GPG Key ID: 2D767DB92FB6C246

View File

@ -5616,13 +5616,14 @@ select_vars() {
unset -v EASYRSA_VARS_FILE unset -v EASYRSA_VARS_FILE
# skip the rest of this function # skip the rest of this function
return return
fi
# User specified vars file will be used ONLY # User specified vars file will be used ONLY
if [ "$EASYRSA_VARS_FILE" ]; then elif [ "$EASYRSA_VARS_FILE" ]; then
# Takes priority, nothing to do # Takes priority, nothing to do
verbose "select_vars: EASYRSA_VARS_FILE" verbose "select_vars: EASYRSA_VARS_FILE"
fi
# This is where auto-load goes bananas
else
# User specified PKI; if vars exists, use it ONLY # User specified PKI; if vars exists, use it ONLY
if [ "$EASYRSA_PKI" ]; then if [ "$EASYRSA_PKI" ]; then
@ -5646,9 +5647,11 @@ select_vars() {
# A vars in the PKI MUST always imply EASYRSA_PKI # A vars in the PKI MUST always imply EASYRSA_PKI
# This is NOT backward compatible # This is NOT backward compatible
# Use expected value comparison for v3.1.7 # Use expected value comparison for v3.1.7
if [ -z "$EASYRSA_VARS_FILE" ]; then
expected_EASYRSA="$PWD" expected_EASYRSA="$PWD"
expected_EASYRSA_PKI="$PWD/pki" expected_EASYRSA_PKI="$PWD/pki"
# fi
# Use this for v3.2.0 # Use this for v3.2.0
# If the pki/vars sets a different PKI then # If the pki/vars sets a different PKI then
# there will be no PKI in the default /pki # there will be no PKI in the default /pki
@ -5664,7 +5667,9 @@ select_vars() {
verbose "select_vars: PWD/vars" verbose "select_vars: PWD/vars"
set_var EASYRSA_VARS_FILE="$PWD/vars" set_var EASYRSA_VARS_FILE="$PWD/vars"
fi fi
fi
# User info
if [ -z "$EASYRSA_VARS_FILE" ]; then if [ -z "$EASYRSA_VARS_FILE" ]; then
[ "$require_pki" ] && information "\ [ "$require_pki" ] && information "\
No Easy-RSA 'vars' configuration file exists!" No Easy-RSA 'vars' configuration file exists!"