Skip to content

Commit

Permalink
Reorder initial setup commands
Browse files Browse the repository at this point in the history
Place selecting and sourcing vars-file before assigning PKI and CA
requirements to the command to be executed.

This is more logical because the command requirements are assigned
directly before handing off to the requested command, while external
variables have already been assigned.

Move 'make-vars' to the standard 'case' command selection list.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
  • Loading branch information
TinCanTech committed Dec 8, 2023
1 parent ac8407d commit 81b381f
Showing 1 changed file with 21 additions and 25 deletions.
46 changes: 21 additions & 25 deletions easyrsa3/easyrsa
Original file line number Diff line number Diff line change
Expand Up @@ -6055,6 +6055,23 @@ done
cmd="$1"
[ "$1" ] && shift # scrape off command

# Intelligent env-var detection and auto-loading:
# Select vars file as EASYRSA_VARS_FILE
# then source the vars file, if found
# otherwise, ignore no vars file
select_vars && source_vars "$EASYRSA_VARS_FILE"

# then set defaults
default_vars

# Check for unexpected changes to EASYRSA or EASYRSA_PKI
# This will be resolved in v3.2.0
# https://github.com/OpenVPN/easy-rsa/issues/1006
validate_default_vars

# Check for conflicting input options
mutual_exclusions

# Establish PKI and CA initialisation requirements
# This avoids unnecessary warnings and notices
unset -v require_pki require_ca ignore_vars
Expand All @@ -6078,31 +6095,6 @@ case "$cmd" in
esac
esac

# Run these commands with NO setup
case "$cmd" in
make-vars)
create_vars_example
cleanup ok
;;
esac

# Intelligent env-var detection and auto-loading:
# Select vars file as EASYRSA_VARS_FILE
# then source the vars file, if found
# otherwise, ignore no vars file
select_vars && source_vars "$EASYRSA_VARS_FILE"

# then set defaults
default_vars

# Check for unexpected changes to EASYRSA or EASYRSA_PKI
# This will be resolved in v3.2.0
# https://github.com/OpenVPN/easy-rsa/issues/1006
validate_default_vars

# Check for conflicting input options
mutual_exclusions

# Hand off to the function responsible
# ONLY verify_working_env() for valid commands
case "$cmd" in
Expand Down Expand Up @@ -6247,6 +6239,10 @@ case "$cmd" in
verify_working_env
make_safe_ssl "$@"
;;
make-vars)
# verify_working_env - Not required
create_vars_example
;;
serial|check-serial)
verify_working_env
# Called with --batch, this will return error
Expand Down

0 comments on commit 81b381f

Please sign in to comment.