Skip to content

Commit 3c233d2

Browse files
committedOct 10, 2023
Merge branch 'TinCanTech-reuse-select_vars'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2 parents d958f1b + a858d1b commit 3c233d2

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed
 

‎easyrsa3/easyrsa

+15-10
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,8 @@ A vars file has not been created in your new PKI because
13761376
conflicting vars files have been found elsewhere."
13771377
prefer_vars_in_pki_msg
13781378
else
1379+
unset -v EASYRSA_VARS_FILE
1380+
select_vars
13791381
information "
13801382
Using Easy-RSA configuration:
13811383
* ${EASYRSA_VARS_FILE:-undefined}"
@@ -5678,9 +5680,6 @@ select_vars() {
56785680
No Easy-RSA 'vars' configuration file exists!"
56795681
EASYRSA_NO_VARS=1
56805682
fi
5681-
5682-
# source the vars file
5683-
source_vars "$EASYRSA_VARS_FILE"
56845683
} # => select_vars()
56855684

56865685
# Source a vars file
@@ -5754,13 +5753,15 @@ Remove 'unset' ('force_set_var' may also work)."
57545753

57555754
# Test sourcing 'vars' in a subshell
57565755
# shellcheck disable=1090 # can't follow .. vars
5757-
( . "$target_file" ) || \
5756+
if ( . "$target_file" ); then
5757+
# Source 'vars' now
5758+
# shellcheck disable=1090 # can't follow .. vars
5759+
. "$target_file" || \
5760+
die "Failed to source the '$target_file' file."
5761+
else
5762+
PATH="$easyrsa_path"
57585763
die "Failed to dry-run the '$target_file' file."
5759-
5760-
# Source 'vars' now
5761-
# shellcheck disable=1090 # can't follow .. vars
5762-
. "$target_file" || \
5763-
die "Failed to source the '$target_file' file."
5764+
fi
57645765

57655766
PATH="$easyrsa_path"
57665767
verbose "source_vars: sourced OK '$target_file'"
@@ -7218,8 +7219,12 @@ case "$cmd" in
72187219
esac
72197220

72207221
# Intelligent env-var detection and auto-loading:
7221-
# Select and source vars file
7222+
# Select vars file as EASYRSA_VARS_FILE
72227223
select_vars
7224+
7225+
# source the vars file
7226+
source_vars "$EASYRSA_VARS_FILE"
7227+
72237228
# then set defaults
72247229
default_vars
72257230

0 commit comments

Comments
 (0)
Please sign in to comment.