Allow vars file to exist in current directory (Fix make-cadir)

The utility script 'make-cadir' creates a CA directory with a vars file.
This vars file conflicts with the preferred PKI-vars file.

This patch changes 'init-pki' to allow make-cadir vars file to over-ride
the preferred PKI-vars file, without error.

Closes: #633

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
This commit is contained in:
Richard T Bonhomme 2022-08-13 20:40:57 +01:00
parent 5b4fd2b484
commit f4a604438d
No known key found for this signature in database
GPG Key ID: 2D767DB92FB6C246

View File

@ -977,7 +977,7 @@ and initialize a fresh PKI here."
Your newly created PKI dir is:
* $EASYRSA_PKI"
if [ "$user_vars_true" ]; then
if [ "$user_vars_true" ] || [ "$old_vars_true" ]; then
: # ok - No message required
else
message "\
@ -1079,12 +1079,18 @@ install_data_to_pki () {
fi
# Create PKI/vars from PKI/example
unset -v old_vars_true
case "$context" in
init-pki)
if [ -e "${EASYRSA_PKI}/${vars_file_example}" ]; then
[ -e "${EASYRSA_PKI}/${vars_file}" ] || \
cp "${EASYRSA_PKI}/${vars_file_example}" \
"${EASYRSA_PKI}/${vars_file}" || :
if [ -e ./vars ]; then
# If the old vars exists then do nothing
old_vars_true=1
else
if [ -e "${EASYRSA_PKI}/${vars_file_example}" ]; then
[ -e "${EASYRSA_PKI}/${vars_file}" ] || \
cp "${EASYRSA_PKI}/${vars_file_example}" \
"${EASYRSA_PKI}/${vars_file}" || :
fi
fi
;;
vars-setup)