Skip to content

Commit

Permalink
Switch to using heredoc expansion for openssl-easyrsa.cnf
Browse files Browse the repository at this point in the history
This replaces use of:
* 'sed' for expanding openssl-easyrsa.cnf
* 'sed' for sanitizing Distinguished Name fields

.. by using heredoc expansion of the built-in openssl-easyrsa.cnf

Signed-off-by: Richard T Bonhomme <[email protected]>
  • Loading branch information
TinCanTech committed Jan 15, 2024
1 parent bd44e3a commit 93b28ad
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions easyrsa3/easyrsa
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,14 @@ escape_hazard() {
verbose "escape_hazard: RUN-ONCE"
fi

# Only use if old 'sed' version is requested
if [ "$EASYRSA_SAFE_CNF_SED" ]; then
: # ok
else
verbose "escape_hazard: REPLACED by heredoc expansion"
return
fi

# Set run once
working_safe_org_conf=1

Expand Down Expand Up @@ -1060,8 +1068,10 @@ expand_ssl_config - \
easyrsa_mktemp safe_ssl_cnf_tmp"

# Rewrite
# Only use if old 'sed' version is requested
# shellcheck disable=SC2016 # No expand '' - expand_ssl_config()
if sed \
if [ "$EASYRSA_SAFE_CNF_SED" ]; then
if sed \
\
-e s\`'$dir'\`\
\""$EASYRSA_PKI"\"\`g \
Expand Down Expand Up @@ -1108,11 +1118,17 @@ easyrsa_mktemp safe_ssl_cnf_tmp"
-e s\`'$ENV::EASYRSA_REQ_SERIAL'\`\
\""$EASYRSA_REQ_SERIAL"\"\`g \
\
"$EASYRSA_SSL_CONF" > "$safe_ssl_cnf_tmp"
then
verbose "expand_ssl_config: COMPLETED"
"$EASYRSA_SSL_CONF" > "$safe_ssl_cnf_tmp"
then
verbose "expand_ssl_config: via 'sed' COMPLETED"
else
return 1
fi

else
return 1
write safe-cnf > "$safe_ssl_cnf_tmp" || \
die "expand_ssl_config - write safe-cnf temp-file"
verbose "expand_ssl_config: via 'write' COMPLETED"
fi
} # => expand_ssl_config()

Expand Down

0 comments on commit 93b28ad

Please sign in to comment.