Skip to content

Commit

Permalink
vars_setup(): When sourcing 'vars' restrict PATH to './'
Browse files Browse the repository at this point in the history
If '--vars=vars' is used, without specifying a path to 'vars', then
sourcing 'vars' fails to find './vars'. POSIX '.' searches the PATH
when the file-name does not contain a slash '/'. [man dot(1p)]

Since EasyRSA expects the 'vars' file to be within the current working
directory, setting 'PATH=./' forces '.' to search ONLY './'.

Signed-off-by: Richard T Bonhomme <[email protected]>
  • Loading branch information
TinCanTech committed Sep 14, 2023
1 parent 4095e33 commit 5a24fa7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions easyrsa3/easyrsa
Original file line number Diff line number Diff line change
Expand Up @@ -5788,16 +5788,21 @@ Remove 'unset' ('force_set_var' may also work)."
# Enable sourcing 'vars'
# shellcheck disable=SC2034 # appears unused
EASYRSA_CALLER=1
easyrsa_path="$PATH"
PATH=./

# Test sourcing 'vars' in a subshell
# shellcheck disable=1090 # can't follow .. vars
( . "$vars" ) || \
die "Failed to source the vars file."
die "Failed to dry-run the vars file."

# Source 'vars' now
# shellcheck disable=1090 # can't follow .. vars
. "$vars"
unset -v EASYRSA_CALLER
. "$vars" || \
die "Failed to source the vars file."

PATH="$easyrsa_path"
unset -v EASYRSA_CALLER easyrsa_path
verbose "vars_setup: sourced 'vars' OK"
fi

Expand Down

0 comments on commit 5a24fa7

Please sign in to comment.