From f4a604438d3ce5fe67a1f4db956dc42fc4ae5588 Mon Sep 17 00:00:00 2001 From: Richard T Bonhomme Date: Sat, 13 Aug 2022 20:40:57 +0100 Subject: [PATCH] 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 --- easyrsa3/easyrsa | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/easyrsa3/easyrsa b/easyrsa3/easyrsa index 46de7dd..525a116 100755 --- a/easyrsa3/easyrsa +++ b/easyrsa3/easyrsa @@ -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)