Separate silent-mode from batch-mode - Respect batch-mode
Introduce EASYRSA_SILENT to enhance the use of EASYRSA_BATCH. Effected functions: warn() The change in behaviour is that warn() can ONLY be silenced by option --silent. Batch-mode is still respected but silence is not. For scripts which rely on EasyRSA, if they use option --batch then the change to restore prevous bevaviour is to use option --sbatch. Otherwise, export EASYRSA_SILENT=1. This is a minimal change that preserves batch-mode functionality but also heeds Warnings, unless NEW option --sbatch is specifcally used. Warnings should not be silenced by batch-mode. Closes: #512 Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
This commit is contained in:
parent
9970d626c1
commit
ec1bac96cb
@ -226,6 +226,9 @@ non-empty values to options are mandatory.
|
|||||||
General options:
|
General options:
|
||||||
|
|
||||||
--batch : set automatic (no-prompts when possible) mode
|
--batch : set automatic (no-prompts when possible) mode
|
||||||
|
--silent : Disable all Warnings and Notices
|
||||||
|
--sbatch : Combined --silent and --batch operating mode
|
||||||
|
|
||||||
--passin=ARG : set -passin ARG for openssl
|
--passin=ARG : set -passin ARG for openssl
|
||||||
--passout=ARG : set -passout ARG for openssl
|
--passout=ARG : set -passout ARG for openssl
|
||||||
--pki-dir=DIR : declares the PKI directory
|
--pki-dir=DIR : declares the PKI directory
|
||||||
@ -280,20 +283,18 @@ $1" 1>&2
|
|||||||
|
|
||||||
# non-fatal warning output
|
# non-fatal warning output
|
||||||
warn() {
|
warn() {
|
||||||
[ ! "$EASYRSA_BATCH" ] && \
|
[ "$EASYRSA_SILENT" ] && return
|
||||||
print "
|
print "* Warning:
|
||||||
$1" 1>&2
|
|
||||||
|
|
||||||
return 0
|
$1" 1>&2
|
||||||
} # => warn()
|
} # => warn()
|
||||||
|
|
||||||
# informational notices to stdout
|
# informational notices to stdout
|
||||||
notice() {
|
notice() {
|
||||||
[ ! "$EASYRSA_BATCH" ] && \
|
[ "$EASYRSA_SILENT" ] && return
|
||||||
print "
|
[ "$EASYRSA_BATCH" ] && return
|
||||||
|
print "
|
||||||
$1"
|
$1"
|
||||||
|
|
||||||
return 0
|
|
||||||
} # => notice()
|
} # => notice()
|
||||||
|
|
||||||
# yes/no case-insensitive match (operates on stdin pipe)
|
# yes/no case-insensitive match (operates on stdin pipe)
|
||||||
@ -984,7 +985,7 @@ gen_dh() {
|
|||||||
|
|
||||||
# check to see if we already have a dh parameters file
|
# check to see if we already have a dh parameters file
|
||||||
if [ -e "$EASYRSA_PKI/dh.pem" ]; then
|
if [ -e "$EASYRSA_PKI/dh.pem" ]; then
|
||||||
if [ "$EASYRSA_BATCH" = "1" ]; then
|
if [ "$EASYRSA_BATCH" ]; then
|
||||||
# if batch is enabled, die
|
# if batch is enabled, die
|
||||||
die "file $EASYRSA_PKI/dh.pem already exists!"
|
die "file $EASYRSA_PKI/dh.pem already exists!"
|
||||||
else
|
else
|
||||||
@ -1063,7 +1064,7 @@ $EASYRSA_EXTRA_EXTS"
|
|||||||
key_out_tmp="$(easyrsa_mktemp)" || die "Failed to create temporary file"
|
key_out_tmp="$(easyrsa_mktemp)" || die "Failed to create temporary file"
|
||||||
req_out_tmp="$(easyrsa_mktemp)" || die "Failed to create temporary file"
|
req_out_tmp="$(easyrsa_mktemp)" || die "Failed to create temporary file"
|
||||||
# generate request
|
# generate request
|
||||||
[ $EASYRSA_BATCH ] && opts="$opts -batch"
|
[ "$EASYRSA_BATCH" ] && opts="$opts -batch"
|
||||||
# shellcheck disable=2086,2148
|
# shellcheck disable=2086,2148
|
||||||
algo_opts=""
|
algo_opts=""
|
||||||
if [ "ed" = "$EASYRSA_ALGO" ]; then
|
if [ "ed" = "$EASYRSA_ALGO" ]; then
|
||||||
@ -2743,6 +2744,13 @@ while :; do
|
|||||||
--batch)
|
--batch)
|
||||||
empty_ok=1
|
empty_ok=1
|
||||||
export EASYRSA_BATCH=1 ;;
|
export EASYRSA_BATCH=1 ;;
|
||||||
|
--silent)
|
||||||
|
empty_ok=1
|
||||||
|
export EASYRSA_SILENT=1 ;;
|
||||||
|
--silent-batch|--sbatch)
|
||||||
|
empty_ok=1
|
||||||
|
export EASYRSA_SILENT=1
|
||||||
|
export EASYRSA_BATCH=1 ;;
|
||||||
--passin)
|
--passin)
|
||||||
export EASYRSA_PASSIN="$val";;
|
export EASYRSA_PASSIN="$val";;
|
||||||
--passout)
|
--passout)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user