Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

escape_hazarrd(): Reuse source_vars() #1037

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 49 additions & 36 deletions easyrsa3/easyrsa
Original file line number Diff line number Diff line change
Expand Up @@ -996,13 +996,8 @@ export EASYRSA_REQ_SERIAL=\"$EASYRSA_REQ_SERIAL\"\
escape_hazard - Failed to write temp-file"

# Reload fields from fully escaped temp-file
# shellcheck disable=SC1090 # can't follow ...
(. "$escape_hazard_tmp") || die "\
escape_hazard - Failed to source temp-file"

source_vars "$escape_hazard_tmp"
verbose "escape_hazard: COMPLETED"
# shellcheck disable=SC1090 # can't follow ...
. "$escape_hazard_tmp"
} # => escape_hazard()

# Replace environment variable names with current value
Expand Down Expand Up @@ -5684,12 +5679,6 @@ No Easy-RSA 'vars' configuration file exists!"

# Source a vars file
source_vars() {
# Never use vars file
if [ "$EASYRSA_NO_VARS" ]; then
verbose "source_vars: EASYRSA_NO_VARS"
return
fi

# File to be sourced
target_file="$1"

Expand All @@ -5712,36 +5701,60 @@ Using Easy-RSA 'vars' configuration:
if grep -q \
-e 'EASYRSA_PASSIN' -e 'EASYRSA_PASSOUT' \
-e '[^(]`[^)]' \
-e '[[:blank:]]export[[:blank:]]*' \
-e '[[:blank:]]unset[[:blank:]]*' \
"$target_file"
then
user_error "\
One or more of these problems has been found in your 'vars' file:
* $target_file

* Use of 'EASYRSA_PASSIN' or 'EASYRSA_PASSOUT':
Storing password information in the 'vars' file is not permitted.
# here we go ..
err_msg="\
These problems have been found in your 'vars' settings:${NL}"

# No passwords!
if grep -q \
-e 'EASYRSA_PASSIN' -e 'EASYRSA_PASSOUT' \
"$target_file"
then
err_msg="${err_msg}
Use of 'EASYRSA_PASSIN' or 'EASYRSA_PASSOUT':
Storing password information in the 'vars' file is not permitted."
fi

* Use of unsupported characters:
These characters are not supported: \` backtick
# No backticks
if grep -q \
-e '[^(]`[^)]' \
"$target_file"
then
err_msg="${err_msg}
Use of unsupported characters:
These characters are not supported: \` backtick"
fi

Please, correct these errors and try again."
fi
# No export
if grep -q \
-e '[[:blank:]]export[[:blank:]]*' \
"$target_file"
then
err_msg="${err_msg}
Use of 'export':
Remove 'export' or replace it with 'set_var'."
fi

# Sanitize vars
if grep -q \
-e '[[:blank:]]export[[:blank:]]*' \
-e '[[:blank:]]unset[[:blank:]]*' \
"$target_file"
then
user_error "\
One or more of these problems has been found in your 'vars' file:
* $target_file
# No unset
if grep -q \
-e '[[:blank:]]unset[[:blank:]]*' \
"$target_file"
then
err_msg="${err_msg}
Use of 'unset':
Remove 'unset' ('force_set_var' may also work)."
fi

* Use of 'export':
Remove 'export' or replace it with 'set_var'.
# Fatal error
user_error "${err_msg}${NL}
Please, correct these errors and try again."

* Use of 'unset':
Remove 'unset' ('force_set_var' may also work)."
else
verbose "source_vars: CLEAN '$target_file'"
fi

# Enable sourcing 'vars'
Expand Down Expand Up @@ -7223,7 +7236,7 @@ esac
select_vars

# source the vars file
source_vars "$EASYRSA_VARS_FILE"
[ "$EASYRSA_NO_VARS" ] || source_vars "$EASYRSA_VARS_FILE"

# then set defaults
default_vars
Expand Down