Skip to content

Commit

Permalink
vars_setup: Split into setup_vars() and source_vars()
Browse files Browse the repository at this point in the history
setup_vars: Determine which vars file to use.

source_vars: Validate and source accepted vars file.

Signed-off-by: Richard T Bonhomme <[email protected]>
  • Loading branch information
TinCanTech committed Sep 4, 2023
1 parent b75c8b0 commit 4a80b21
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions easyrsa3/easyrsa
Original file line number Diff line number Diff line change
Expand Up @@ -5590,7 +5590,7 @@ Use of --silent and --verbose is unresolvable."
# Here sourcing of 'vars' if present occurs.
# If not present, defaults are used to support
# running without a sourced config format
vars_setup() {
setup_vars() {
# Try to locate a 'vars' file in order of preference.
# If one is found then source it.
# NOTE: EASYRSA_PKI is never set here,
Expand Down Expand Up @@ -5633,7 +5633,7 @@ vars_setup() {

# Program dir
prog_dir="${0%/*}"
verbose "vars_setup: prog_dir=$prog_dir"
verbose "setup_vars: prog_dir = $prog_dir"

# If prog_dir is PWD then do not check prog_vars
if [ "$prog_dir" = . ] || [ "$prog_dir" = "$PWD" ]
Expand Down Expand Up @@ -5667,7 +5667,7 @@ vars_setup() {
found_vars="$((
e_pwd_vars + e_prog_vars + e_pki_vars
))"
verbose "vars_setup: found_vars = '$found_vars'"
verbose "setup_vars: found_vars = '$found_vars'"

# If found_vars greater than 1
# then output user info
Expand Down Expand Up @@ -5728,7 +5728,10 @@ or remove the 'vars' files which are not in use.${NL}"
unset -v prog_vars pwd_vars easy_vars pki_vars
# END: Find vars
fi
} # => setup_vars()

# Source vars file and set defaults
source_vars() {
# If EASYRSA_NO_VARS is defined then do not use vars
# If PKI is not required then located vars files are
# not required
Expand Down Expand Up @@ -5871,8 +5874,8 @@ Algorithm '$EASYRSA_ALGO' is invalid: Must be 'rsa', 'ec' or 'ed'"
if [ "$require_pki" ]; then
prefer_vars_in_pki_msg
fi
verbose "vars_setup: COMPLETED"
} # => vars_setup()
verbose "source_vars: COMPLETED"
} # => source_vars()

# Verify working environment
verify_working_env() {
Expand Down Expand Up @@ -7272,8 +7275,11 @@ case "$cmd" in
esac
esac

# Intelligent env-var detection and auto-loading:
vars_setup
# Determine which vars file to use
setup_vars

# Source the vars file
source_vars

# Check for conflicting input options
mutual_exclusions
Expand Down

0 comments on commit 4a80b21

Please sign in to comment.