@@ -5558,48 +5558,38 @@ select_vars() {
5558
5558
5559
5559
# User specified PKI; if vars exists, use it ONLY
5560
5560
if [ "$EASYRSA_PKI" ]; then
5561
- if [ -f "$EASYRSA_PKI/vars" ]; then
5561
+ if [ -f "$EASYRSA_PKI"/vars ]; then
5562
+ set_var EASYRSA_VARS_FILE "$EASYRSA_PKI"/vars
5562
5563
verbose "select_vars: source EASYRSA_PKI/vars"
5563
- set_var EASYRSA_VARS_FILE "$EASYRSA_PKI/vars"
5564
5564
fi
5565
5565
fi
5566
5566
5567
5567
# User specified EASYRSA; if vars exists, use it ONLY
5568
5568
if [ "$EASYRSA" ]; then
5569
- if [ -f "$EASYRSA/vars" ]; then
5569
+ if [ -f "$EASYRSA"/vars ]; then
5570
+ set_var EASYRSA_VARS_FILE "$EASYRSA"/vars
5570
5571
verbose "select_vars: EASYRSA/vars"
5571
- set_var EASYRSA_VARS_FILE "$EASYRSA/vars"
5572
5572
fi
5573
5573
fi
5574
5574
5575
5575
# Default PKI; if vars exists, use it ONLY
5576
- if [ -f "$PWD/pki/vars" ] && \
5576
+ if [ -f "$PWD" /pki/vars ] && \
5577
5577
[ -z "$EASYRSA_PKI" ] && \
5578
5578
[ -z "$EASYRSA" ]
5579
5579
then
5580
- # Prevent vars from changing expected PKI.
5580
+ # Prevent vars from changing ' expected' PKI.
5581
5581
# A vars in the PKI MUST always imply EASYRSA_PKI
5582
- # This is NOT backward compatible
5583
- # Use expected value comparison for v3.1.7
5584
- if [ -z "$EASYRSA_VARS_FILE" ]; then
5585
- expected_EASYRSA="$PWD"
5586
- expected_EASYRSA_PKI="$PWD/pki"
5587
- fi
5588
-
5589
- # Use this for v3.2.0
5590
- # If the pki/vars sets a different PKI then
5591
- # there will be no PKI in the default /pki
5592
- #set_var EASYRSA "$PWD"
5593
- #set_var EASYRSA_PKI "$EASYRSA/pki"
5582
+ expected_EASYRSA="$PWD"
5583
+ expected_EASYRSA_PKI="$PWD"/pki
5594
5584
5585
+ set_var EASYRSA_VARS_FILE "$PWD"/pki/vars
5595
5586
verbose "select_vars: PWD/pki/vars"
5596
- set_var EASYRSA_VARS_FILE "$PWD/pki/vars"
5597
5587
fi
5598
5588
5599
5589
# Default working dir; if vars exists, use it ONLY
5600
- if [ -f "$PWD/vars" ]; then
5590
+ if [ -f "$PWD"/vars ]; then
5591
+ set_var EASYRSA_VARS_FILE "$PWD"/vars
5601
5592
verbose "select_vars: PWD/vars"
5602
- set_var EASYRSA_VARS_FILE "$PWD/vars"
5603
5593
fi
5604
5594
fi
5605
5595
@@ -5615,17 +5605,12 @@ source_vars() {
5615
5605
# File to be sourced
5616
5606
target_file="$1"
5617
5607
5618
- # 'vars' MUST not be a directory
5619
- [ -d "$target_file" ] && user_error "\
5620
- Missing vars file:
5621
- * $target_file"
5622
-
5623
- # 'vars' now MUST exist
5608
+ # target_file MUST exist
5624
5609
[ -f "$target_file" ] || user_error "\
5625
5610
Missing vars file:
5626
5611
* $target_file"
5627
5612
5628
- # Sanitize vars
5613
+ # Sanitize target_file
5629
5614
if grep -q \
5630
5615
-e 'EASYRSA_PASSIN' -e 'EASYRSA_PASSOUT' \
5631
5616
-e '[^(]`[^)]' \
@@ -5685,28 +5670,23 @@ Please, correct these errors and try again."
5685
5670
verbose "source_vars: CLEAN '$target_file'"
5686
5671
fi
5687
5672
5688
- # Enable sourcing 'vars'
5689
- # shellcheck disable=SC2034 # appears unused - source_vars()
5673
+ # Enable sourcing target_file
5674
+ # shellcheck disable=SC2034 # EASYRSA_CALLER appears unused
5690
5675
EASYRSA_CALLER=1
5691
- easyrsa_path="$PATH"
5692
- # shellcheck disable=SC2123 # PATH is - source_vars()
5693
- PATH=./
5694
5676
5695
- # Test sourcing 'vars' in a subshell
5677
+ # Test sourcing target_file in a subshell
5696
5678
# shellcheck disable=1090 # can't follow - source_vars()
5697
5679
if ( . "$target_file" ); then
5698
- # Source 'vars' now
5680
+ # Source target_file now
5699
5681
# shellcheck disable=1090 # can't follow - source_vars()
5700
5682
. "$target_file" || \
5701
5683
die "Failed to source the '$target_file' file."
5702
5684
else
5703
- PATH="$easyrsa_path"
5704
5685
die "Failed to dry-run the '$target_file' file."
5705
5686
fi
5706
5687
5707
- PATH="$easyrsa_path"
5708
5688
verbose "source_vars: sourced OK '$target_file'"
5709
- unset -v EASYRSA_CALLER easyrsa_path target_file
5689
+ unset -v EASYRSA_CALLER target_file
5710
5690
} # => source_vars()
5711
5691
5712
5692
# Set defaults
0 commit comments