From 5d5960536579bb86cf025323185acf4aa8f7b7f3 Mon Sep 17 00:00:00 2001 From: Richard T Bonhomme Date: Tue, 3 Jan 2023 19:19:30 +0000 Subject: [PATCH] init-pki: Add new inline directory (Wrap long lines) Signed-off-by: Richard T Bonhomme --- easyrsa3/easyrsa | 59 ++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/easyrsa3/easyrsa b/easyrsa3/easyrsa index 0a235d6..2552274 100755 --- a/easyrsa3/easyrsa +++ b/easyrsa3/easyrsa @@ -1009,7 +1009,7 @@ init_pki() { shift done - # If EASYRSA_PKI exists, confirm before we rm -rf (skipped with EASYRSA_BATCH) + # If EASYRSA_PKI exists, confirm before deletion if [ -e "$EASYRSA_PKI" ]; then confirm "Confirm removal: " "yes" "\ WARNING!!! @@ -1018,6 +1018,7 @@ You are about to remove the EASYRSA_PKI at: * $EASYRSA_PKI and initialize a fresh PKI here." + # now remove it: case "$reset" in hard) @@ -1028,31 +1029,30 @@ and initialize a fresh PKI here." * This will remove everything in your current PKI directory. To keep your current settings use 'init-pki soft' instead. - Using 'init-pki soft' is recommended. -" + Using 'init-pki soft' is recommended." - # # # shellcheck disable=SC2115 # Use "${var:?}" to ensure - rm -rf "$EASYRSA_PKI" || \ - die "init-pki hard reset failed." - # If vars was in the old pki then it has been removed - # If vars was somewhere else then it is user defined - # Clear found_vars because we MUST not find pki/vars - if [ "$vars_in_pki" ]; then unset -v found_vars; fi + # # # shellcheck disable=SC2115 # Use "${var:?}" to + rm -rf "$EASYRSA_PKI" || \ + die "init-pki hard reset failed." + + # If vars was in the old pki, it has been removed + # If vars was somewhere else, it is user defined + # Clear found_vars, we MUST not find pki/vars + [ "$vars_in_pki" ] && unset -v found_vars ;; soft) # There is no unit test for a soft reset for i in ca.crt \ - issued private reqs certs_by_serial revoked renewed \ - serial serial.old ecparams index.txt index.txt.old \ - index.txt.attr index.txt.attr.old + issued private reqs inline revoked renewed \ + serial serial.old index.txt index.txt.old \ + index.txt.attr index.txt.attr.old \ + ecparams certs_by_serial do - # # # shellcheck disable=SC2115 # Use "${var:?}" to ensure + # # # shellcheck disable=SC2115 # Use "${var:?}" rm -rf "$EASYRSA_PKI/${i}" || \ die "init-pki soft reset failed." done ;; - # More modes could be added here, e.g. only remove - # issued certs (and clean database), but keep CA intact. *) die "Unknown reset type: $reset" esac @@ -1061,15 +1061,18 @@ and initialize a fresh PKI here." # new dirs: for i in private reqs; do mkdir -p "$EASYRSA_PKI/$i" || \ - die "Failed to create PKI file structure (permissions?)" + die "\ +Failed to create PKI file structure (permissions?)" done # for 'init-pki' create a secure_session - secure_session || die "init_pki - secure_session failed." + secure_session || die "\ +init_pki - secure_session failed." # Install data-files into ALL new PKIs install_data_to_pki init-pki || \ - warn "Failed to install required data-files to PKI. (init)" + warn "\ +Failed to install required data-files to PKI. (init)" notice "\ 'init-pki' complete; you may now create a CA or requests. @@ -1081,15 +1084,21 @@ Your newly created PKI dir is: # if $no_new_vars then there are one or more known vars # which are not in the PKI. All further commands will fail # until vars is manually corrected - [ "$no_new_vars" ] || information "Using Easy-RSA configuration: $vars" - # For new PKIs where pki/vars was auto-created, show user message + [ "$no_new_vars" ] || information "\ +Using Easy-RSA configuration: $vars" + + # For new PKIs , pki/vars was auto-created, show message if [ "$new_vars_true" ]; then information "\ -IMPORTANT: Easy-RSA 'vars' template file has been created in your new PKI. - Edit this 'vars' file to customise the settings for your PKI. - To use a global vars file, use global option --vars=" +IMPORTANT: \ +Easy-RSA 'vars' template file has been created in your new PKI. + \ +Edit this 'vars' file to customise the settings for your PKI. + \ +To use a global vars file, use global option --vars=" - elif [ "$user_vars_true" ] || [ "$old_vars_true" ] || [ "$no_new_vars" ] + elif [ "$user_vars_true" ] || [ "$old_vars_true" ] || \ + [ "$no_new_vars" ] then : # ok - User defined, old or no vars file exist else